Skip to content

Commit a092bc8

Browse files
authored
Merge pull request #10236 from jasagredo/js/win-scripts
Fix Windows tests depending on scripts
2 parents 39b6924 + e420708 commit a092bc8

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.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
path = "FINDSH\sh.exe"
2+
args = "ghc-pkg"
Binary file not shown.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
path = "FINDSH\sh.exe"
2+
args = "ghc"
Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
11
import Test.Cabal.Prelude
2+
import System.Directory
23

3-
main = setupAndCabalTest $ expectBrokenIfWindows 10179 $ do
4+
main = setupAndCabalTest $ do
5+
when isWindows $ do
6+
sh <- fmap takeDirectory <$> liftIO (findExecutable "sh")
7+
case sh of
8+
Nothing -> skip "no sh"
9+
Just sh' -> do
10+
let sh'' = concatMap (\c -> case c of
11+
'\\' -> "\\\\\\\\"
12+
x -> [x]) sh'
13+
void $ shell "sed" [ "-i", "-e", "s/FINDSH/" <> sh'' <> "/g", "ghc.shim", "ghc-pkg.shim"]
414
env <- getTestEnv
515
let cwd = testCurrentDir env
616
ghc_path <- programPathM ghcProgram
717
r <- withEnv [("WITH_GHC", Just ghc_path)]
8-
. fails $ setup' "configure" ["-w", cwd </> "ghc"]
18+
. fails $ setup' "configure" ["-w", cwd </> if isWindows then "ghc.exe" else "ghc" ]
919
assertOutputContains "is version 9999999" r
Binary file not shown.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
path = "FINDSH\sh.exe"
2+
args = "ghc-7.10"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
path = "FINDSH\sh.exe"
2+
args = "ghc-pkg-ghc-7.10"
Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
11
import Test.Cabal.Prelude
2+
import System.Directory
23

3-
main = setupAndCabalTest $ expectBrokenIfWindows 10179 $ do
4+
main = setupAndCabalTest $ do
5+
when isWindows $ do
6+
sh <- fmap takeDirectory <$> liftIO (findExecutable "sh")
7+
case sh of
8+
Nothing -> skip "no sh"
9+
Just sh' -> do
10+
let sh'' = concatMap (\c -> case c of
11+
'\\' -> "\\\\\\\\"
12+
x -> [x]) sh'
13+
void $ shell "sed" [ "-i", "-e", "s/FINDSH/" <> sh'' <> "/g", "ghc-7.10.shim", "ghc-pkg-ghc-7.10.shim"]
414
env <- getTestEnv
515
let cwd = testCurrentDir env
616
ghc_path <- programPathM ghcProgram
717
r <- withEnv [("WITH_GHC", Just ghc_path)]
8-
. fails $ setup' "configure" ["-w", cwd </> "ghc-7.10"]
18+
. fails $ setup' "configure" ["-w", cwd </> if isWindows then "ghc-7.10.exe" else "ghc-7.10"]
919
assertOutputContains "is version 9999999" r
Binary file not shown.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
path = "FINDSH\sh.exe"
2+
args = "ghc-7.10"
Binary file not shown.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
path = "FINDSH\sh.exe"
2+
args = "ghc-pkg-7.10"
Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
11
import Test.Cabal.Prelude
2+
import System.Directory
23

3-
main = setupAndCabalTest $ expectBrokenIfWindows 10179 $ do
4+
main = setupAndCabalTest $ do
5+
when isWindows $ do
6+
sh <- fmap takeDirectory <$> liftIO (findExecutable "sh")
7+
case sh of
8+
Nothing -> skip "no sh"
9+
Just sh' -> do
10+
let sh'' = concatMap (\c -> case c of
11+
'\\' -> "\\\\\\\\"
12+
x -> [x]) sh'
13+
void $ shell "sed" [ "-i", "-e", "s/FINDSH/" <> sh'' <> "/g", "ghc-7.10.shim", "ghc-pkg-7.10.shim"]
414
env <- getTestEnv
515
let cwd = testCurrentDir env
616
ghc_path <- programPathM ghcProgram
717
r <- withEnv [("WITH_GHC", Just ghc_path)]
8-
. fails $ setup' "configure" ["-w", cwd </> "ghc-7.10"]
18+
. fails $ setup' "configure" ["-w", cwd </> if isWindows then "ghc-7.10.exe" else "ghc-7.10"]
919
assertOutputContains "is version 9999999" r
Binary file not shown.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
path = "FINDSH\sh.exe"
2+
args = "bin\ghc-pkg"
Binary file not shown.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
path = "FINDSH\sh.exe"
2+
args = "ghc"
Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,22 @@
11
import Test.Cabal.Prelude
2+
import System.Directory
23

3-
main = setupAndCabalTest $ expectBrokenIfWindows 10179 $ do
4-
withSymlink "bin/ghc" "ghc" $ do
4+
main = setupAndCabalTest $ do
5+
when isWindows $ do
6+
sh <- fmap takeDirectory <$> liftIO (findExecutable "sh")
7+
case sh of
8+
Nothing -> skip "no sh"
9+
Just sh' -> do
10+
let sh'' = concatMap (\c -> case c of
11+
'\\' -> "\\\\\\\\"
12+
x -> [x]) sh'
13+
void $ shell "sed" [ "-i", "-e", "s/FINDSH/" <> sh'' <> "/g", "bin/ghc.shim", "bin/ghc-pkg.shim"]
14+
(if isWindows
15+
then withSymlink "bin/ghc.exe" "ghc.exe" . withSymlink "bin/ghc.shim" "ghc.shim" . withSymlink "bin/ghc" "ghc"
16+
else withSymlink "bin/ghc" "ghc") $ do
517
env <- getTestEnv
618
let cwd = testCurrentDir env
719
ghc_path <- programPathM ghcProgram
820
r <- withEnv [("WITH_GHC", Just ghc_path)]
9-
. fails $ setup' "configure" ["-w", cwd </> "ghc"]
21+
. fails $ setup' "configure" ["-w", cwd </> if isWindows then "ghc.exe" else "ghc"]
1022
assertOutputContains "is version 9999999" r
Binary file not shown.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
path = "FINDSH\sh.exe"
2+
args = "ghc"
Binary file not shown.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
path = "FINDSH\sh.exe"
2+
args = "bin\ghc-pkg-7.10"
Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,22 @@
11
import Test.Cabal.Prelude
2+
import System.Directory
23

3-
main = setupAndCabalTest $ expectBrokenIfWindows 10179 $ do
4-
withSymlink "bin/ghc-7.10" "ghc" $ do
4+
main = setupAndCabalTest $ do
5+
when isWindows $ do
6+
sh <- fmap takeDirectory <$> liftIO (findExecutable "sh")
7+
case sh of
8+
Nothing -> skip "no sh"
9+
Just sh' -> do
10+
let sh'' = concatMap (\c -> case c of
11+
'\\' -> "\\\\\\\\"
12+
x -> [x]) sh'
13+
void $ shell "sed" [ "-i", "-e", "s/FINDSH/" <> sh'' <> "/g", "bin/ghc-7.10.shim", "bin/ghc-pkg-7.10.shim"]
14+
(if isWindows
15+
then withSymlink "bin/ghc-7.10.exe" "ghc.exe" . withSymlink "bin/ghc-7.10.shim" "ghc.shim" . withSymlink "bin/ghc-7.10" "ghc"
16+
else withSymlink "bin/ghc-7.10" "ghc") $ do
517
env <- getTestEnv
618
let cwd = testCurrentDir env
719
ghc_path <- programPathM ghcProgram
820
r <- withEnv [("WITH_GHC", Just ghc_path)]
9-
. fails $ setup' "configure" ["-w", cwd </> "ghc"]
21+
. fails $ setup' "configure" ["-w", cwd </> if isWindows then "ghc.exe" else "ghc"]
1022
assertOutputContains "is version 9999999" r
Binary file not shown.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
path = "FINDSH\sh.exe"
2+
args = "ghc"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
path = "FINDSH\sh.exe"
2+
args = "bin\ghc-pkg-ghc-7.10"
Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,22 @@
11
import Test.Cabal.Prelude
2+
import System.Directory
23

3-
main = setupAndCabalTest $ expectBrokenIfWindows 10179 $ do
4-
withSymlink "bin/ghc-7.10" "ghc" $ do
4+
main = setupAndCabalTest $ do
5+
when isWindows $ do
6+
sh <- fmap takeDirectory <$> liftIO (findExecutable "sh")
7+
case sh of
8+
Nothing -> skip "no sh"
9+
Just sh' -> do
10+
let sh'' = concatMap (\c -> case c of
11+
'\\' -> "\\\\\\\\"
12+
x -> [x]) sh'
13+
void $ shell "sed" [ "-i", "-e", "s/FINDSH/" <> sh'' <> "/g", "bin/ghc-7.10.shim", "bin/ghc-pkg-ghc-7.10.shim"]
14+
(if isWindows
15+
then withSymlink "bin/ghc-7.10.exe" "ghc.exe" . withSymlink "bin/ghc-7.10.shim" "ghc.shim" . withSymlink "bin/ghc-7.10" "ghc"
16+
else withSymlink "bin/ghc-7.10" "ghc") $ do
517
env <- getTestEnv
618
let cwd = testCurrentDir env
719
ghc_path <- programPathM ghcProgram
820
r <- withEnv [("WITH_GHC", Just ghc_path)]
9-
. fails $ setup' "configure" ["-w", cwd </> "ghc"]
21+
. fails $ setup' "configure" ["-w", cwd </> if isWindows then "ghc.exe" else "ghc"]
1022
assertOutputContains "is version 9999999" r
Binary file not shown.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
path = "FINDSH\sh.exe"
2+
args = "pkg-config"
Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
1+
import System.Directory
12
import Test.Cabal.Prelude
23

34
-- Test that invalid unicode in pkg-config output doesn't trip up cabal very much
4-
main = cabalTest $ expectBrokenIfWindows 10179 $ do
5+
main = cabalTest $ do
6+
when isWindows $ do
7+
sh <- fmap takeDirectory <$> liftIO (findExecutable "sh")
8+
case sh of
9+
Nothing -> skip "no sh"
10+
Just sh' -> do
11+
let sh'' = concatMap (\c -> case c of
12+
'\\' -> "\\\\\\\\"
13+
x -> [x]) sh'
14+
void $ shell "sed" [ "-i", "-e", "s/FINDSH/" <> sh'' <> "/g", "pkg-config.shim"]
515
cdir <- testCurrentDir `fmap` getTestEnv
616
res <- cabal' "v2-build" ["--extra-prog-path="++cdir, "-v2"]
717
assertOutputContains "Some pkg-config packages have names containing invalid unicode: or" res

0 commit comments

Comments
 (0)