Skip to content

Commit 57cbb08

Browse files
authored
Merge pull request haskell#10319 from haskell/mergify/bp/3.14/pr-10236
Fix Windows tests depending on scripts (backport haskell#10236)
2 parents 1eaa6af + 7d2a6b5 commit 57cbb08

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+228
-36
lines changed

.github/workflows/validate.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ jobs:
133133
key: ${{ runner.os }}-${{ matrix.ghc }}-${{ github.sha }}
134134
restore-keys: ${{ runner.os }}-${{ matrix.ghc }}-
135135

136-
- name: Work around git problem https://bugs.launchpad.net/ubuntu/+source/git/+bug/1993586 (cabal PR #8546)
136+
- name: "Work around git problem https://bugs.launchpad.net/ubuntu/+source/git/+bug/1993586 (cabal PR #8546)"
137137
run: git config --global protocol.file.allow always
138138

139139
# The tool is not essential to the rest of the test suite. If
@@ -146,10 +146,15 @@ jobs:
146146
run: cabal install --ignore-project hackage-repo-tool
147147

148148
# Needed by cabal-testsuite/PackageTests/Configure/setup.test.hs
149-
- name: Install Autotools
149+
- name: "MAC: Install Autotools"
150150
if: runner.os == 'macOS'
151151
run: brew install automake
152152

153+
# Needed by cabal-testsuite/PackageTests/Configure/setup.test.hs
154+
- name: "WIN: Install Autotools"
155+
if: runner.os == 'Windows'
156+
run: /usr/bin/pacman --noconfirm -S autotools
157+
153158
- name: Set validate inputs
154159
run: |
155160
FLAGS="${{ env.COMMON_FLAGS }}"

cabal-testsuite/PackageTests/Configure/cabal.test.hs

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,26 @@ import Test.Cabal.Prelude
22
import Control.Monad.IO.Class
33
import Data.Maybe
44
import System.Directory
5+
import System.Environment
6+
import Data.List (isSuffixOf)
7+
58
-- Test for 'build-type: Configure' example from the setup manual.
69
main = cabalTest $ do
7-
hasAutoreconf <- liftIO $ fmap isJust $ findExecutable "autoreconf"
8-
skipUnless "no autoreconf" hasAutoreconf
9-
_ <- shell "autoreconf" ["-i"]
10-
cabal "v2-build" []
10+
if isWindows
11+
then do
12+
(mCI, mSh) <- liftIO $ (,) <$> lookupEnv "CI" <*> lookupEnv "SHELL"
13+
case (mCI, mSh) of
14+
(Nothing, Nothing) -> skip "Missing $SHELL"
15+
(Nothing, Just sh) -> do
16+
env <- getTestEnv
17+
void $ shell sh [ "-l", "-c", "cd $(cygpath -m '" <> testTmpDir env <> "') && autoreconf -i"]
18+
cabal "v2-build" []
19+
(Just{}, _) -> do
20+
env <- getTestEnv
21+
void $ shell "C:\\msys64\\usr\\bin\\bash.exe" [ "-l", "-c", "cd $(cygpath -m '" <> testTmpDir env <> "') && autoreconf -i"]
22+
cabal "v2-build" []
23+
else do
24+
hasAutoreconf <- liftIO $ fmap isJust $ findExecutable "autoreconf"
25+
skipUnless "no autoreconf" hasAutoreconf
26+
_ <- shell "autoreconf" ["-i"]
27+
cabal "v2-build" []

cabal-testsuite/PackageTests/Configure/setup.test.hs

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,25 @@ import Test.Cabal.Prelude
22
import Control.Monad.IO.Class
33
import Data.Maybe
44
import System.Directory
5+
import System.Environment
6+
57
-- Test for 'build-type: Configure' example from the setup manual.
6-
main = setupTest $ do
7-
hasAutoreconf <- liftIO $ fmap isJust $ findExecutable "autoreconf"
8-
skipUnless "no autoreconf" hasAutoreconf
9-
_ <- shell "autoreconf" ["-i"]
10-
setup_build []
8+
main = setupTest $
9+
if isWindows
10+
then do
11+
(mCI, mSh) <- liftIO $ (,) <$> lookupEnv "CI" <*> lookupEnv "SHELL"
12+
case (mCI, mSh) of
13+
(Nothing, Nothing) -> skip "Missing $SHELL"
14+
(Nothing, Just sh) -> do
15+
env <- getTestEnv
16+
void $ shell sh [ "-l", "-c", "cd $(cygpath -m '" <> testTmpDir env <> "') && autoreconf -i"]
17+
setup_build []
18+
(Just{}, _) -> do
19+
env <- getTestEnv
20+
void $ shell "C:\\msys64\\usr\\bin\\bash.exe" [ "-l", "-c", "cd $(cygpath -m '" <> testTmpDir env <> "') && autoreconf -i"]
21+
setup_build []
22+
else do
23+
hasAutoreconf <- liftIO $ fmap isJust $ findExecutable "autoreconf"
24+
skipUnless "no autoreconf" hasAutoreconf
25+
_ <- shell "autoreconf" ["-i"]
26+
setup_build []

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"
Binary file not shown.

0 commit comments

Comments
 (0)