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%

0 commit comments

Comments
 (0)