Files
runner-images-temp/images/win/scripts/Tests/Haskell.Tests.ps1
T

63 lines
2.1 KiB
PowerShell
Raw Normal View History

2020-07-10 14:29:54 +03:00
Describe "Haskell" {
$ghcPackagesPath = "c:\ghcup\ghc"
[array]$ghcVersionList = Get-ChildItem -Path $ghcPackagesPath -Filter "*" | ForEach-Object { $_.Name.Trim() }
2020-07-10 14:29:54 +03:00
$ghcCount = $ghcVersionList.Count
2020-07-13 11:44:04 +03:00
$defaultGhcVersion = $ghcVersionList | Sort-Object {[Version]$_} | Select-Object -Last 1
2020-10-18 21:14:39 +03:00
$ghcDefaultCases = @{
defaultGhcVersion = $defaultGhcVersion
defaultGhcShortVersion = ([version]$defaultGhcVersion).ToString(3)
}
2020-07-13 11:44:04 +03:00
$ghcTestCases = $ghcVersionList | ForEach-Object {
$ghcVersion = $_
2020-10-18 20:07:40 +03:00
$ghcShortVersion = ([version]$ghcVersion).ToString(3)
$binGhcPath = Join-Path $ghcPackagesPath "$ghcShortVersion\bin\ghc.exe"
2020-07-13 11:44:04 +03:00
@{
2020-10-18 20:52:32 +03:00
ghcVersion = $ghcVersion
ghcShortVersion = $ghcShortVersion
binGhcPath = $binGhcPath
2020-07-13 11:44:04 +03:00
}
}
2020-07-10 14:29:54 +03:00
$ghcupEnvExists = @(
@{envVar = "GHCUP_INSTALL_BASE_PREFIX"}
@{envVar = "GHCUP_MSYS2"}
)
It "<envVar> environment variable exists" -TestCases $ghcupEnvExists {
Test-Path env:\$envVar
}
2020-07-10 14:29:54 +03:00
It "Accurate 3 versions of GHC are installed" -TestCases @{ghcCount = $ghcCount} {
$ghcCount | Should -BeExactly 3
}
2020-07-13 11:44:04 +03:00
It "GHC <ghcVersion> is installed" -TestCases $ghcTestCases {
2020-10-18 20:52:32 +03:00
"$binGhcPath --version" | Should -MatchCommandOutput $ghcShortVersion
2020-07-10 14:29:54 +03:00
}
2020-10-18 21:45:48 +03:00
It "GHC <defaultGhcVersion> is the default version and should be the latest installed" -TestCases $ghcDefaultCases {
2020-10-18 20:52:32 +03:00
"ghc --version" | Should -MatchCommandOutput $defaultGhcShortVersion
2020-07-10 14:29:54 +03:00
}
2020-07-13 11:44:04 +03:00
It "Cabal is installed" {
"cabal --version" | Should -ReturnZeroExitCode
}
2022-02-22 19:20:26 +03:00
It "cabal folder does not exist" {
$env:CABAL_DIR | Should -Not -Exist
}
It "CABAL_DIR environment variable exists" {
Get-EnvironmentVariable CABAL_DIR | Should -BeExactly "C:\cabal"
}
It "ghcup is installed" {
"ghcup --version" | Should -ReturnZeroExitCode
}
It "ghcup can access msys2" {
"ghcup run --mingw-path -- pacman --version" | Should -ReturnZeroExitCode
}
}