Skip to content

Commit

Permalink
Add shims on tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jasagredo committed Sep 2, 2024
1 parent d3e589d commit 7e0db76
Show file tree
Hide file tree
Showing 30 changed files with 105 additions and 15 deletions.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
path = "FINDSH\sh.exe"
args = "ghc-pkg"
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
path = "FINDSH\sh.exe"
args = "ghc"
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
import Test.Cabal.Prelude
import System.Directory

main = setupAndCabalTest $ expectBrokenIfWindows 10179 $ do
main = setupAndCabalTest $ do
when isWindows $ do
sh <- fmap takeDirectory <$> liftIO (findExecutable "sh")
case sh of
Nothing -> skip "no sh"
Just sh' -> do
let sh'' = concatMap (\c -> case c of
'\\' -> "\\\\\\\\"
x -> [x]) sh'
void $ shell "sed" [ "-i", "-e", "s/FINDSH/" <> sh'' <> "/g", "ghc.shim", "ghc-pkg.shim"]
env <- getTestEnv
let cwd = testCurrentDir env
ghc_path <- programPathM ghcProgram
r <- withEnv [("WITH_GHC", Just ghc_path)]
. fails $ setup' "configure" ["-w", cwd </> "ghc"]
. fails $ setup' "configure" ["-w", cwd </> if isWindows then "ghc.exe" else "ghc" ]
assertOutputContains "is version 9999999" r
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
path = "FINDSH\sh.exe"
args = "ghc-7.10"
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
path = "FINDSH\sh.exe"
args = "ghc-pkg-ghc-7.10"
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
import Test.Cabal.Prelude
import System.Directory

main = setupAndCabalTest $ expectBrokenIfWindows 10179 $ do
main = setupAndCabalTest $ do
when isWindows $ do
sh <- fmap takeDirectory <$> liftIO (findExecutable "sh")
case sh of
Nothing -> skip "no sh"
Just sh' -> do
let sh'' = concatMap (\c -> case c of
'\\' -> "\\\\\\\\"
x -> [x]) sh'
void $ shell "sed" [ "-i", "-e", "s/FINDSH/" <> sh'' <> "/g", "ghc-7.10.shim", "ghc-pkg-ghc-7.10.shim"]
env <- getTestEnv
let cwd = testCurrentDir env
ghc_path <- programPathM ghcProgram
r <- withEnv [("WITH_GHC", Just ghc_path)]
. fails $ setup' "configure" ["-w", cwd </> "ghc-7.10"]
. fails $ setup' "configure" ["-w", cwd </> if isWindows then "ghc-7.10.exe" else "ghc-7.10"]
assertOutputContains "is version 9999999" r
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
path = "FINDSH\sh.exe"
args = "ghc-7.10"
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
path = "FINDSH\sh.exe"
args = "ghc-pkg-7.10"
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
import Test.Cabal.Prelude
import System.Directory

main = setupAndCabalTest $ expectBrokenIfWindows 10179 $ do
main = setupAndCabalTest $ do
when isWindows $ do
sh <- fmap takeDirectory <$> liftIO (findExecutable "sh")
case sh of
Nothing -> skip "no sh"
Just sh' -> do
let sh'' = concatMap (\c -> case c of
'\\' -> "\\\\\\\\"
x -> [x]) sh'
void $ shell "sed" [ "-i", "-e", "s/FINDSH/" <> sh'' <> "/g", "ghc-7.10.shim", "ghc-pkg-7.10.shim"]
env <- getTestEnv
let cwd = testCurrentDir env
ghc_path <- programPathM ghcProgram
r <- withEnv [("WITH_GHC", Just ghc_path)]
. fails $ setup' "configure" ["-w", cwd </> "ghc-7.10"]
. fails $ setup' "configure" ["-w", cwd </> if isWindows then "ghc-7.10.exe" else "ghc-7.10"]
assertOutputContains "is version 9999999" r
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
path = "FINDSH\sh.exe"
args = "bin\ghc-pkg"
Binary file not shown.
2 changes: 2 additions & 0 deletions cabal-testsuite/PackageTests/GhcPkgGuess/Symlink/bin/ghc.shim
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
path = "FINDSH\sh.exe"
args = "ghc"
18 changes: 15 additions & 3 deletions cabal-testsuite/PackageTests/GhcPkgGuess/Symlink/setup.test.hs
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
import Test.Cabal.Prelude
import System.Directory

main = setupAndCabalTest $ expectBrokenIfWindows 10179 $ do
withSymlink "bin/ghc" "ghc" $ do
main = setupAndCabalTest $ do
when isWindows $ do
sh <- fmap takeDirectory <$> liftIO (findExecutable "sh")
case sh of
Nothing -> skip "no sh"
Just sh' -> do
let sh'' = concatMap (\c -> case c of
'\\' -> "\\\\\\\\"
x -> [x]) sh'
void $ shell "sed" [ "-i", "-e", "s/FINDSH/" <> sh'' <> "/g", "bin/ghc.shim", "bin/ghc-pkg.shim"]
(if isWindows
then withSymlink "bin/ghc.exe" "ghc.exe" . withSymlink "bin/ghc.shim" "ghc.shim" . withSymlink "bin/ghc" "ghc"
else withSymlink "bin/ghc" "ghc") $ do
env <- getTestEnv
let cwd = testCurrentDir env
ghc_path <- programPathM ghcProgram
r <- withEnv [("WITH_GHC", Just ghc_path)]
. fails $ setup' "configure" ["-w", cwd </> "ghc"]
. fails $ setup' "configure" ["-w", cwd </> if isWindows then "ghc.exe" else "ghc"]
assertOutputContains "is version 9999999" r
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
path = "FINDSH\sh.exe"
args = "ghc"
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
path = "FINDSH\sh.exe"
args = "bin\ghc-pkg-7.10"
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
import Test.Cabal.Prelude
import System.Directory

main = setupAndCabalTest $ expectBrokenIfWindows 10179 $ do
withSymlink "bin/ghc-7.10" "ghc" $ do
main = setupAndCabalTest $ do
when isWindows $ do
sh <- fmap takeDirectory <$> liftIO (findExecutable "sh")
case sh of
Nothing -> skip "no sh"
Just sh' -> do
let sh'' = concatMap (\c -> case c of
'\\' -> "\\\\\\\\"
x -> [x]) sh'
void $ shell "sed" [ "-i", "-e", "s/FINDSH/" <> sh'' <> "/g", "bin/ghc-7.10.shim", "bin/ghc-pkg-7.10.shim"]
(if isWindows
then withSymlink "bin/ghc-7.10.exe" "ghc.exe" . withSymlink "bin/ghc-7.10.shim" "ghc.shim" . withSymlink "bin/ghc-7.10" "ghc"
else withSymlink "bin/ghc-7.10" "ghc") $ do
env <- getTestEnv
let cwd = testCurrentDir env
ghc_path <- programPathM ghcProgram
r <- withEnv [("WITH_GHC", Just ghc_path)]
. fails $ setup' "configure" ["-w", cwd </> "ghc"]
. fails $ setup' "configure" ["-w", cwd </> if isWindows then "ghc.exe" else "ghc"]
assertOutputContains "is version 9999999" r
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
path = "FINDSH\sh.exe"
args = "ghc"
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
path = "FINDSH\sh.exe"
args = "bin\ghc-pkg-ghc-7.10"
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
import Test.Cabal.Prelude
import System.Directory

main = setupAndCabalTest $ expectBrokenIfWindows 10179 $ do
withSymlink "bin/ghc-7.10" "ghc" $ do
main = setupAndCabalTest $ do
when isWindows $ do
sh <- fmap takeDirectory <$> liftIO (findExecutable "sh")
case sh of
Nothing -> skip "no sh"
Just sh' -> do
let sh'' = concatMap (\c -> case c of
'\\' -> "\\\\\\\\"
x -> [x]) sh'
void $ shell "sed" [ "-i", "-e", "s/FINDSH/" <> sh'' <> "/g", "bin/ghc-7.10.shim", "bin/ghc-pkg-ghc-7.10.shim"]
(if isWindows
then withSymlink "bin/ghc-7.10.exe" "ghc.exe" . withSymlink "bin/ghc-7.10.shim" "ghc.shim" . withSymlink "bin/ghc-7.10" "ghc"
else withSymlink "bin/ghc-7.10" "ghc") $ do
env <- getTestEnv
let cwd = testCurrentDir env
ghc_path <- programPathM ghcProgram
r <- withEnv [("WITH_GHC", Just ghc_path)]
. fails $ setup' "configure" ["-w", cwd </> "ghc"]
. fails $ setup' "configure" ["-w", cwd </> if isWindows then "ghc.exe" else "ghc"]
assertOutputContains "is version 9999999" r

0 comments on commit 7e0db76

Please sign in to comment.