Skip to content

Commit 13e15d7

Browse files
jasagredoMikolaj
authored andcommitted
Fix GHCJS BuildRunner test on Windows
(cherry picked from commit de9d229)
1 parent 8fa4a27 commit 13e15d7

File tree

6 files changed

+53
-2
lines changed

6 files changed

+53
-2
lines changed

cabal-testsuite/PackageTests/GHCJS/BuildRunner/cabal.test.hs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Test.Cabal.Prelude
22

33
main = do
4-
cabalTest . expectBrokenIfWindows 10179 . recordMode DoNotRecord $ do
4+
cabalTest . recordMode DoNotRecord $ do
55
cwd <- fmap testCurrentDir getTestEnv
66
testInvokedWithBuildRunner cwd "test" []
77
testInvokedWithBuildRunner cwd "run" ["ghcjs-exe"]
@@ -14,6 +14,8 @@ testInvokedWithBuildRunner cwd cabalCmd extraArgs = do
1414
[ "--ghcjs"
1515
, "--with-compiler", cwd </> fakeGhcjsPath
1616
]
17+
-- On windows point cabal to the right cc
18+
++ if isWindows then ["--with-gcc", "scripts/cc.bat"] else []
1719
assertOutputContains magicString output
1820
where
19-
fakeGhcjsPath = "scripts/fake-ghcjs.sh"
21+
fakeGhcjsPath = if isWindows then "scripts/fake-ghcjs.exe" else "scripts/fake-ghcjs.sh"
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
@ECHO off
2+
3+
FOR /f "delims=" %%A in ('call ghc.exe --print-libdir') do set "libdir=%%A"
4+
FOR /f "delims=" %%A in ('call ghc.exe --numeric-version') do set "numVersion=%%A"
5+
setlocal EnableDelayedExpansion
6+
7+
call :compareVersions 9.4.1 %numVersion%
8+
if %errorlevel% == 1 (set "cc=gcc.exe") else (set "cc=clang.exe")
9+
CALL !libdir:lib=mingw\bin\!%cc% %*
10+
EXIT /B %ERRORLEVEL%
11+
12+
REM taken from https://stackoverflow.com/questions/15807762/compare-version-numbers-in-batch-file
13+
14+
:compareVersions version1 version2
15+
::
16+
:: Compares two version numbers and returns the result in the ERRORLEVEL
17+
::
18+
:: Returns 1 if version1 > version2
19+
:: 0 if version1 = version2
20+
:: -1 if version1 < version2
21+
::
22+
:: The nodes must be delimited by . or , or -
23+
::
24+
:: Nodes are normally strictly numeric, without a 0 prefix. A letter suffix
25+
:: is treated as a separate node
26+
::
27+
setlocal enableDelayedExpansion
28+
set "v1=%~1"
29+
set "v2=%~2"
30+
:loop
31+
call :parseNode "%v1%" n1 v1
32+
call :parseNode "%v2%" n2 v2
33+
if %n1% gtr %n2% exit /b 1
34+
if %n1% lss %n2% exit /b -1
35+
if not defined v1 if not defined v2 exit /b 0
36+
if not defined v1 exit /b -1
37+
if not defined v2 exit /b 1
38+
goto :loop
39+
40+
41+
:parseNode version nodeVar remainderVar
42+
for /f "tokens=1* delims=." %%A in ("%~1") do (
43+
set "%~2=%%A"
44+
set "%~3=%%B"
45+
)
Binary file not shown.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
path = "sh.exe"
2+
args = "scripts/fake-ghcjs.sh"
Binary file not shown.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
path = "sh.exe"
2+
args = "scripts/ghcjs-pkg"

0 commit comments

Comments
 (0)