Skip to content
Snippets Groups Projects
Commit de9d2295 authored by Javier Sagredo's avatar Javier Sagredo
Browse files

Fix GHCJS BuildRunner test on Windows

parent b2e4856e
No related branches found
Tags cabal-install-3.4.0.0-rc1
No related merge requests found
import Test.Cabal.Prelude import Test.Cabal.Prelude
main = do main = do
cabalTest . expectBrokenIfWindows 10179 . recordMode DoNotRecord $ do cabalTest . recordMode DoNotRecord $ do
cwd <- fmap testCurrentDir getTestEnv cwd <- fmap testCurrentDir getTestEnv
testInvokedWithBuildRunner cwd "test" [] testInvokedWithBuildRunner cwd "test" []
testInvokedWithBuildRunner cwd "run" ["ghcjs-exe"] testInvokedWithBuildRunner cwd "run" ["ghcjs-exe"]
...@@ -14,6 +14,8 @@ testInvokedWithBuildRunner cwd cabalCmd extraArgs = do ...@@ -14,6 +14,8 @@ testInvokedWithBuildRunner cwd cabalCmd extraArgs = do
[ "--ghcjs" [ "--ghcjs"
, "--with-compiler", cwd </> fakeGhcjsPath , "--with-compiler", cwd </> fakeGhcjsPath
] ]
-- On windows point cabal to the right cc
++ if isWindows then ["--with-gcc", "scripts/cc.bat"] else []
assertOutputContains magicString output assertOutputContains magicString output
where where
fakeGhcjsPath = "scripts/fake-ghcjs.sh" fakeGhcjsPath = if isWindows then "scripts/fake-ghcjs.exe" else "scripts/fake-ghcjs.sh"
@ECHO off
FOR /f "delims=" %%A in ('call ghc.exe --print-libdir') do set "libdir=%%A"
FOR /f "delims=" %%A in ('call ghc.exe --numeric-version') do set "numVersion=%%A"
setlocal EnableDelayedExpansion
call :compareVersions 9.4.1 %numVersion%
if %errorlevel% == 1 (set "cc=gcc.exe") else (set "cc=clang.exe")
CALL !libdir:lib=mingw\bin\!%cc% %*
EXIT /B %ERRORLEVEL%
REM taken from https://stackoverflow.com/questions/15807762/compare-version-numbers-in-batch-file
:compareVersions version1 version2
::
:: Compares two version numbers and returns the result in the ERRORLEVEL
::
:: Returns 1 if version1 > version2
:: 0 if version1 = version2
:: -1 if version1 < version2
::
:: The nodes must be delimited by . or , or -
::
:: Nodes are normally strictly numeric, without a 0 prefix. A letter suffix
:: is treated as a separate node
::
setlocal enableDelayedExpansion
set "v1=%~1"
set "v2=%~2"
:loop
call :parseNode "%v1%" n1 v1
call :parseNode "%v2%" n2 v2
if %n1% gtr %n2% exit /b 1
if %n1% lss %n2% exit /b -1
if not defined v1 if not defined v2 exit /b 0
if not defined v1 exit /b -1
if not defined v2 exit /b 1
goto :loop
:parseNode version nodeVar remainderVar
for /f "tokens=1* delims=." %%A in ("%~1") do (
set "%~2=%%A"
set "%~3=%%B"
)
File added
path = "sh.exe"
args = "scripts/fake-ghcjs.sh"
File added
path = "sh.exe"
args = "scripts/ghcjs-pkg"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment