Skip to content

Commit 39b6924

Browse files
Various cabal-testsuite improvements (#10225)
* Improve bat scripts for CCompilerOverride * Ensure Windows tests can cleanup the temp directory * Implement `flaky` combinator * Remove outdated tests * Remove broken tests These tests were testing for messages that were removed with the `cabal check` rework. * Make `skip` and `broken` messages uniform * Mark flaky tests * Re-enable DeterministicTrivial * Fix MacOS canonical paths * Extend cabal-testsuite readme with `flaky` * Skip non-terminating tests in Windows CI --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
1 parent 474d698 commit 39b6924

File tree

82 files changed

+365
-492
lines changed

Some content is hidden

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

82 files changed

+365
-492
lines changed

Cabal-tests/lib/Test/Utils/TempTestDir.hs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22

33
module Test.Utils.TempTestDir
44
( withTestDir
5+
, withTestDir'
56
, removeDirectoryRecursiveHack
67
) where
78

89
import Distribution.Compat.Internal.TempFile (createTempDirectory)
9-
import Distribution.Simple.Utils (warn)
10+
import Distribution.Simple.Utils (warn, TempFileOptions (..), defaultTempFileOptions)
1011
import Distribution.Verbosity
1112

1213
import Control.Concurrent (threadDelay)
@@ -23,12 +24,26 @@ import qualified System.Info (os)
2324
-- | Much like 'withTemporaryDirectory' but with a number of hacks to make
2425
-- sure on windows that we can clean up the directory at the end.
2526
withTestDir :: (MonadIO m, MonadMask m) => Verbosity -> String -> (FilePath -> m a) -> m a
26-
withTestDir verbosity template action = do
27-
systmpdir <- liftIO getTemporaryDirectory
27+
withTestDir verbosity template action = withTestDir' verbosity defaultTempFileOptions template action
28+
29+
withTestDir' :: (MonadIO m, MonadMask m) => Verbosity -> TempFileOptions -> String -> (FilePath -> m a) -> m a
30+
withTestDir' verbosity tempFileOpts template action = do
31+
systmpdir <-
32+
-- MacOS returns /var/folders/... which is a symlink (/var -> /private/var),
33+
-- so the test-suite struggles to make the build cwd-agnostic in particular
34+
-- for the ShowBuildInfo tests. This canonicalizePath call makes it
35+
-- /private/var/folders/... which will work.
36+
liftIO $ canonicalizePath =<< getTemporaryDirectory
2837
bracket
2938
( do { tmpRelDir <- liftIO $ createTempDirectory systmpdir template
3039
; return $ systmpdir </> tmpRelDir } )
31-
(liftIO . removeDirectoryRecursiveHack verbosity)
40+
(liftIO
41+
-- This ensures that the temp files are not deleted at the end of the test.
42+
-- It replicates the behavior of @withTempDirectoryEx@.
43+
. when (not (optKeepTempFiles tempFileOpts))
44+
-- This is the bit that helps with Windows deleting all files.
45+
. removeDirectoryRecursiveHack verbosity
46+
)
3247
action
3348

3449
-- | On Windows, file locks held by programs we run (in this case VCSs)

cabal-testsuite/PackageTests/Backpack/Includes2/cabal-internal.test.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import Test.Cabal.Prelude
22

33
main = cabalTest $ do
44
skipUnlessGhcVersion ">= 8.1"
5-
expectBrokenIf isWindows 10191 $ withProjectFile "cabal.internal.project" $ do
5+
expectBrokenIfWindowsCI 10191 $ withProjectFile "cabal.internal.project" $ do
66
cabal "v2-build" ["exe"]
77
withPlan $ do
88
r <- runPlanExe' "I" "exe" []

cabal-testsuite/PackageTests/Backpack/Includes2/setup-external.test.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import Test.Cabal.Prelude
22
main = setupAndCabalTest $ do
33
skipUnlessGhcVersion ">= 8.1"
4-
ghc <- isGhcVersion "== 9.0.2 || == 9.2.* || == 9.4.* || == 9.6.*"
5-
expectBrokenIf ghc 7987 $ do
4+
expectBrokenIfGhc "== 9.0.2 || == 9.2.* || == 9.4.* || == 9.6.*" 7987 $ do
65
withPackageDb $ do
76
withDirectory "mylib" $ setup_install_with_docs ["--ipid", "mylib-0.1.0.0"]
87
withDirectory "mysql" $ setup_install_with_docs ["--ipid", "mysql-0.1.0.0"]

cabal-testsuite/PackageTests/Backpack/Includes2/setup-per-component.test.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ import Test.Cabal.Prelude
22
main = setupTest $ do
33
-- No cabal test because per-component is broken with it
44
skipUnlessGhcVersion ">= 8.1"
5-
ghc <- isGhcVersion "== 9.0.2 || == 9.2.* || == 9.4.* || == 9.6.*"
6-
expectBrokenIf ghc 7987 $
5+
expectBrokenIfGhc "== 9.0.2 || == 9.2.* || == 9.4.* || == 9.6.*" 7987 $
76
withPackageDb $
87
withDirectory "Includes2" $ do
98
let setup_install' args = setup_install_with_docs args

cabal-testsuite/PackageTests/Backpack/Includes3/cabal-external.test.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import Test.Cabal.Prelude
22

33
main = cabalTest $ do
4-
ghcVer <- isGhcVersion ">= 9.10"
54
skipUnlessGhcVersion ">= 8.1"
5+
ghcVer <- isGhcVersion ">= 9.10"
66
skipIf "Windows + 9.10.1 (#10191)" (isWindows && ghcVer)
77
withProjectFile "cabal.external.project" $ do
88
cabal "v2-build" ["exe"]

cabal-testsuite/PackageTests/Backpack/Includes3/cabal-internal.test.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import Test.Cabal.Prelude
22

33
main = cabalTest $ do
44
skipUnlessGhcVersion ">= 8.1"
5-
expectBrokenIf isWindows 10191 $ withProjectFile "cabal.internal.project" $ do
5+
expectBrokenIfWindowsCI 10191 $ withProjectFile "cabal.internal.project" $ do
66
cabal "v2-build" ["exe"]
77
withPlan $ do
88
r <- runPlanExe' "I" "exe" []

cabal-testsuite/PackageTests/Backpack/Includes3/setup-external-ok.test.hs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ import Data.List
33
import qualified Data.Char as Char
44
main = setupAndCabalTest $ do
55
skipUnlessGhcVersion ">= 8.1"
6-
ghc <- isGhcVersion "== 9.0.2 || == 9.2.* || == 9.4.* || == 9.6.*"
7-
expectBrokenIf ghc 7987 $
6+
expectBrokenIfGhc "== 9.0.2 || == 9.2.* || == 9.4.* || == 9.6.*" 7987 $
87
withPackageDb $ do
98
containers_id <- getIPID "containers"
109
withDirectory "repo/sigs-0.1.0.0" $ setup_install_with_docs ["--ipid", "sigs-0.1.0.0"]
@@ -21,4 +20,3 @@ main = setupAndCabalTest $ do
2120
withDirectory "repo/exe-0.1.0.0" $ do
2221
setup_install []
2322
runExe' "exe" [] >>= assertOutputContains "fromList [(0,2),(2,4)]"
24-
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Test.Cabal.Prelude
22
main = setupAndCabalTest $ do
33
skipUnlessGhcVersion ">= 8.1"
4-
skipUnless "no profiling libs" =<< hasProfiledLibraries
4+
skipIfNoProfiledLibraries
55
setup "configure" ["--enable-profiling"]
66
setup "build" []
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Test.Cabal.Prelude
22
main =
3-
cabalTest $ expectBrokenIf isWindows 10191 $ withShorterPathForNewBuildStore $ do
3+
cabalTest $ expectBrokenIfWindows 10191 $ withShorterPathForNewBuildStore $ do
44
skipUnlessGhcVersion ">= 8.1"
55
withRepo "repo" $ do
66
cabal "v2-build" ["T6385"]
Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
@echo OFF
22

3-
where /q clang.exe
4-
5-
IF %ERRORLEVEL% EQU 0 (
6-
call clang.exe -DNOERROR6 %*
7-
EXIT /B %ERRORLEVEL%
8-
)
9-
10-
ECHO "Cannot find C compiler"
11-
EXIT /B 1
3+
REM replace the libdir with the path to the compiler
4+
FOR /f "delims=" %%A in ('call ghc.exe --print-libdir') do set "var=%%A"
5+
setlocal EnableDelayedExpansion
6+
CALL !var:lib=mingw\bin\clang.exe! -DNOERROR6 %*
7+
EXIT /B %ERRORLEVEL%
Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
@echo OFF
22

3-
where /q gcc.exe
4-
5-
IF %ERRORLEVEL% EQU 0 (
6-
call gcc.exe -DNOERROR6 %*
7-
EXIT /B %ERRORLEVEL%
8-
)
9-
10-
ECHO "Cannot find C compiler"
11-
EXIT /B 1
3+
REM replace the libdir with the path to the compiler
4+
FOR /f "delims=" %%A in ('call ghc.exe --print-libdir') do set "var=%%A"
5+
setlocal EnableDelayedExpansion
6+
CALL !var:lib=mingw\bin\gcc.exe! -DNOERROR6 %*
7+
EXIT /B %ERRORLEVEL%
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Test.Cabal.Prelude
22

33
main = setupTest $ do
4-
skipIf "ghc < 7.8" =<< isGhcVersion "< 7.8"
4+
skipIfGhcVersion "< 7.8"
55
setup "configure" []
66
res <- setup' "build" []
77
assertOutputContains "= Post common block elimination =" res

cabal-testsuite/PackageTests/CustomDep/cabal.project

Lines changed: 0 additions & 1 deletion
This file was deleted.

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

Lines changed: 0 additions & 10 deletions
This file was deleted.

cabal-testsuite/PackageTests/CustomDep/client/B.hs

Lines changed: 0 additions & 2 deletions
This file was deleted.

cabal-testsuite/PackageTests/CustomDep/client/Setup.hs

Lines changed: 0 additions & 2 deletions
This file was deleted.

cabal-testsuite/PackageTests/CustomDep/client/client.cabal

Lines changed: 0 additions & 12 deletions
This file was deleted.

cabal-testsuite/PackageTests/CustomDep/custom/A.hs

Lines changed: 0 additions & 1 deletion
This file was deleted.

cabal-testsuite/PackageTests/CustomDep/custom/Setup.hs

Lines changed: 0 additions & 2 deletions
This file was deleted.

cabal-testsuite/PackageTests/CustomDep/custom/custom.cabal

Lines changed: 0 additions & 15 deletions
This file was deleted.

cabal-testsuite/PackageTests/CustomPlain/A.hs

Lines changed: 0 additions & 1 deletion
This file was deleted.

cabal-testsuite/PackageTests/CustomPlain/Setup.hs

Lines changed: 0 additions & 3 deletions
This file was deleted.

cabal-testsuite/PackageTests/CustomPlain/cabal.project

Lines changed: 0 additions & 1 deletion
This file was deleted.

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

Lines changed: 0 additions & 11 deletions
This file was deleted.

cabal-testsuite/PackageTests/CustomPlain/plain.cabal

Lines changed: 0 additions & 11 deletions
This file was deleted.

cabal-testsuite/PackageTests/CustomPlain/setup.cabal.out

Lines changed: 0 additions & 7 deletions
This file was deleted.

cabal-testsuite/PackageTests/CustomPlain/setup.out

Lines changed: 0 additions & 6 deletions
This file was deleted.

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

Lines changed: 0 additions & 4 deletions
This file was deleted.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Test.Cabal.Prelude
22

33
main = do
4-
cabalTest . expectBrokenIf isWindows 10179 . recordMode DoNotRecord $ do
4+
cabalTest . expectBrokenIfWindows 10179 . recordMode DoNotRecord $ do
55
cwd <- fmap testCurrentDir getTestEnv
66
testInvokedWithBuildRunner cwd "test" []
77
testInvokedWithBuildRunner cwd "run" ["ghcjs-exe"]

cabal-testsuite/PackageTests/GhcPkgGuess/SameDirectory/setup.test.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Test.Cabal.Prelude
22

3-
main = setupAndCabalTest $ expectBrokenIf isWindows 10179 $ do
3+
main = setupAndCabalTest $ expectBrokenIfWindows 10179 $ do
44
env <- getTestEnv
55
let cwd = testCurrentDir env
66
ghc_path <- programPathM ghcProgram

cabal-testsuite/PackageTests/GhcPkgGuess/SameDirectoryGhcVersion/setup.test.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Test.Cabal.Prelude
22

3-
main = setupAndCabalTest $ expectBrokenIf isWindows 10179 $ do
3+
main = setupAndCabalTest $ expectBrokenIfWindows 10179 $ do
44
env <- getTestEnv
55
let cwd = testCurrentDir env
66
ghc_path <- programPathM ghcProgram

cabal-testsuite/PackageTests/GhcPkgGuess/SameDirectoryVersion/setup.test.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Test.Cabal.Prelude
22

3-
main = setupAndCabalTest $ expectBrokenIf isWindows 10179 $ do
3+
main = setupAndCabalTest $ expectBrokenIfWindows 10179 $ do
44
env <- getTestEnv
55
let cwd = testCurrentDir env
66
ghc_path <- programPathM ghcProgram

cabal-testsuite/PackageTests/GhcPkgGuess/Symlink/setup.test.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Test.Cabal.Prelude
22

3-
main = setupAndCabalTest $ expectBrokenIf isWindows 10179 $ do
3+
main = setupAndCabalTest $ expectBrokenIfWindows 10179 $ do
44
withSymlink "bin/ghc" "ghc" $ do
55
env <- getTestEnv
66
let cwd = testCurrentDir env

cabal-testsuite/PackageTests/GhcPkgGuess/SymlinkGhcVersion/setup.test.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Test.Cabal.Prelude
22

3-
main = setupAndCabalTest $ expectBrokenIf isWindows 10179 $ do
3+
main = setupAndCabalTest $ expectBrokenIfWindows 10179 $ do
44
withSymlink "bin/ghc-7.10" "ghc" $ do
55
env <- getTestEnv
66
let cwd = testCurrentDir env

cabal-testsuite/PackageTests/GhcPkgGuess/SymlinkVersion/setup.test.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Test.Cabal.Prelude
22

3-
main = setupAndCabalTest $ expectBrokenIf isWindows 10179 $ do
3+
main = setupAndCabalTest $ expectBrokenIfWindows 10179 $ do
44
withSymlink "bin/ghc-7.10" "ghc" $ do
55
env <- getTestEnv
66
let cwd = testCurrentDir env

cabal-testsuite/PackageTests/InternalVersions/BuildDependsExtra/Foo.hs

Lines changed: 0 additions & 1 deletion
This file was deleted.

cabal-testsuite/PackageTests/InternalVersions/BuildDependsExtra/Main.hs

Lines changed: 0 additions & 4 deletions
This file was deleted.

cabal-testsuite/PackageTests/InternalVersions/BuildDependsExtra/build-depends-extra-version.cabal

Lines changed: 0 additions & 17 deletions
This file was deleted.

cabal-testsuite/PackageTests/InternalVersions/BuildDependsExtra/setup.cabal.out

Lines changed: 0 additions & 13 deletions
This file was deleted.

cabal-testsuite/PackageTests/InternalVersions/BuildDependsExtra/setup.out

Lines changed: 0 additions & 13 deletions
This file was deleted.

cabal-testsuite/PackageTests/InternalVersions/BuildDependsExtra/setup.test.hs

Lines changed: 0 additions & 6 deletions
This file was deleted.

cabal-testsuite/PackageTests/InternalVersions/BuildToolDependsExtra/Foo.hs

Lines changed: 0 additions & 1 deletion
This file was deleted.

cabal-testsuite/PackageTests/InternalVersions/BuildToolDependsExtra/Main.hs

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)