diff --git a/cabal-testsuite/PackageTests/GHCJS/BuildRunner/cabal.test.hs b/cabal-testsuite/PackageTests/GHCJS/BuildRunner/cabal.test.hs index 245901c8bef..da8afae103e 100644 --- a/cabal-testsuite/PackageTests/GHCJS/BuildRunner/cabal.test.hs +++ b/cabal-testsuite/PackageTests/GHCJS/BuildRunner/cabal.test.hs @@ -1,7 +1,7 @@ import Test.Cabal.Prelude main = do - cabalTest . expectBrokenIfWindows 10179 . recordMode DoNotRecord $ do + cabalTest . recordMode DoNotRecord $ do cwd <- fmap testCurrentDir getTestEnv testInvokedWithBuildRunner cwd "test" [] testInvokedWithBuildRunner cwd "run" ["ghcjs-exe"] @@ -14,6 +14,8 @@ testInvokedWithBuildRunner cwd cabalCmd extraArgs = do [ "--ghcjs" , "--with-compiler", cwd fakeGhcjsPath ] + -- On windows point cabal to the right cc + ++ if isWindows then ["--with-gcc", "scripts/cc.bat"] else [] assertOutputContains magicString output where - fakeGhcjsPath = "scripts/fake-ghcjs.sh" + fakeGhcjsPath = if isWindows then "scripts/fake-ghcjs.exe" else "scripts/fake-ghcjs.sh" diff --git a/cabal-testsuite/PackageTests/GHCJS/BuildRunner/scripts/cc.bat b/cabal-testsuite/PackageTests/GHCJS/BuildRunner/scripts/cc.bat new file mode 100644 index 00000000000..b2300d2fd6b --- /dev/null +++ b/cabal-testsuite/PackageTests/GHCJS/BuildRunner/scripts/cc.bat @@ -0,0 +1,45 @@ +@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" +) diff --git a/cabal-testsuite/PackageTests/GHCJS/BuildRunner/scripts/fake-ghcjs.exe b/cabal-testsuite/PackageTests/GHCJS/BuildRunner/scripts/fake-ghcjs.exe new file mode 100644 index 00000000000..537023174dc Binary files /dev/null and b/cabal-testsuite/PackageTests/GHCJS/BuildRunner/scripts/fake-ghcjs.exe differ diff --git a/cabal-testsuite/PackageTests/GHCJS/BuildRunner/scripts/fake-ghcjs.shim b/cabal-testsuite/PackageTests/GHCJS/BuildRunner/scripts/fake-ghcjs.shim new file mode 100644 index 00000000000..725429e82d7 --- /dev/null +++ b/cabal-testsuite/PackageTests/GHCJS/BuildRunner/scripts/fake-ghcjs.shim @@ -0,0 +1,2 @@ +path = "sh.exe" +args = "scripts/fake-ghcjs.sh" diff --git a/cabal-testsuite/PackageTests/GHCJS/BuildRunner/scripts/ghcjs-pkg.exe b/cabal-testsuite/PackageTests/GHCJS/BuildRunner/scripts/ghcjs-pkg.exe new file mode 100644 index 00000000000..537023174dc Binary files /dev/null and b/cabal-testsuite/PackageTests/GHCJS/BuildRunner/scripts/ghcjs-pkg.exe differ diff --git a/cabal-testsuite/PackageTests/GHCJS/BuildRunner/scripts/ghcjs-pkg.shim b/cabal-testsuite/PackageTests/GHCJS/BuildRunner/scripts/ghcjs-pkg.shim new file mode 100644 index 00000000000..d330fc23e3e --- /dev/null +++ b/cabal-testsuite/PackageTests/GHCJS/BuildRunner/scripts/ghcjs-pkg.shim @@ -0,0 +1,2 @@ +path = "sh.exe" +args = "scripts/ghcjs-pkg"