Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose ghcup binary to PATH on windows #4264

Merged
15 changes: 12 additions & 3 deletions images/win/scripts/Installers/Install-Haskell.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,17 @@ Add-MachinePathItem -PathItem $DefaultGhcPath
Write-Host 'Installing cabal...'
Choco-Install -PackageName cabal

Invoke-PesterTests -TestFile 'Haskell'

# install minimal ghcup, utilizing pre-installed msys2 at C:\msys64
Write-Host 'Installing ghcup...'
$msysPath = "C:\msys64"
$ghcupPrefix = "C:\"
$cabalDir = "C:\cabal"
$bootstrapHaskell = Invoke-WebRequest https://www.haskell.org/ghcup/sh/bootstrap-haskell.ps1 -UseBasicParsing
Invoke-Command -ScriptBlock ([ScriptBlock]::Create($bootstrapHaskell)) -ArgumentList $false, $true, $true, $false, $false, $false, $false, C:\, "", C:\msys64, C:\cabal
Invoke-Command -ScriptBlock ([ScriptBlock]::Create($bootstrapHaskell)) -ArgumentList $false, $true, $true, $false, $true, $false, $false, $ghcupPrefix, "", $msysPath, $cabalDir
Set-SystemVariable "GHCUP_INSTALL_BASE_PREFIX" $ghcupPrefix
Set-SystemVariable "GHCUP_MSYS2" $msysPath
Set-SystemVariable "CABAL_DIR" $cabalDir
Add-MachinePathItem "$ghcupPrefix\ghcup\bin"
Add-MachinePathItem "$cabalDir\bin"

Invoke-PesterTests -TestFile 'Haskell'
20 changes: 19 additions & 1 deletion images/win/scripts/Tests/Haskell.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ Describe "Haskell" {
}
}

$ghcupEnvExists = @(
@{envVar = "GHCUP_INSTALL_BASE_PREFIX"}
@{envVar = "GHCUP_MSYS2"}
)

It "<envVar> environment variable exists" -TestCases $ghcupEnvExists {
Test-Path env:\$envVar
}

It "Accurate 3 versions of GHC are installed" -TestCases @{ghcCount = $ghcCount} {
$ghcCount | Should -BeExactly 3
}
Expand All @@ -39,4 +48,13 @@ Describe "Haskell" {
It "Cabal is installed" {
"cabal --version" | Should -ReturnZeroExitCode
}
}

It "cabal config was modified and exists" {
$env:CABAL_DIR | Should -Exist
"cabal user-config diff" | Should -ReturnZeroExitCode
}

It "ghcup is installed" {
"ghcup --version" | Should -ReturnZeroExitCode
}
}