Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mark failing tests as expected failures, or fix them #8022

Merged
merged 6 commits into from
Mar 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cabal-install/cabal-install.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ Test-Suite memory-usage-tests
hs-source-dirs: tests
default-language: Haskell2010

ghc-options: -threaded -rtsopts "-with-rtsopts=-M8M -K1K"
ghc-options: -threaded -rtsopts "-with-rtsopts=-M16M -K1K"

other-modules:
UnitTests.Distribution.Solver.Modular.DSL
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import Test.Cabal.Prelude
main = setupAndCabalTest $ do
skipUnlessGhcVersion ">= 8.1"
skipUnlessGhcVersion ">= 8.1"
ghc <- isGhcVersion "== 9.0.2 || == 9.2.1"
expectBrokenIf ghc 7987 $ do
withPackageDb $ do
withDirectory "mylib" $ setup_install_with_docs ["--ipid", "mylib-0.1.0.0"]
withDirectory "mysql" $ setup_install_with_docs ["--ipid", "mysql-0.1.0.0"]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import Test.Cabal.Prelude
main = setupTest $ do
-- No cabal test because per-component is broken with it
skipUnlessGhcVersion ">= 8.1"
-- No cabal test because per-component is broken with it
skipUnlessGhcVersion ">= 8.1"
ghc <- isGhcVersion "== 9.0.2 || == 9.2.1"
expectBrokenIf ghc 7987 $
withPackageDb $ do
let setup_install' args = setup_install_with_docs (["--cabal-file", "Includes2.cabal"] ++ args)
setup_install' ["mylib", "--cid", "mylib-0.1.0.0"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import Test.Cabal.Prelude
import Data.List
import qualified Data.Char as Char
main = setupAndCabalTest $ do
skipUnlessGhcVersion ">= 8.1"
skipUnlessGhcVersion ">= 8.1"
ghc <- isGhcVersion "== 9.0.2 || == 9.2.1"
expectBrokenIf ghc 7987 $
withPackageDb $ do
containers_id <- getIPID "containers"
withDirectory "repo/sigs-0.1.0.0" $ setup_install_with_docs ["--ipid", "sigs-0.1.0.0"]
Expand Down
2 changes: 1 addition & 1 deletion cabal-testsuite/PackageTests/CmmSourcesDyn/setup.test.hs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Test.Cabal.Prelude

main = setupTest $ do
skipIf "ghc < 7.8" =<< ghcVersionIs (< mkVersion [7,8])
skipIf "ghc < 7.8" =<< isGhcVersion "< 7.8"
setup "configure" []
res <- setup' "build" []
assertOutputContains "= Post common block elimination =" res
5 changes: 0 additions & 5 deletions cabal-testsuite/PackageTests/CustomPlain/setup.test.hs
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import Test.Cabal.Prelude
main = setupTest $ do
skipUnless "no Cabal for GHC" =<< hasCabalForGhc
-- On Travis OSX, Cabal shipped with GHC 7.8 does not work
-- with error "setup: /usr/bin/ar: permission denied"; see
-- also https://github.com/haskell/cabal/issues/3938
-- This is a hack to make the test not run in this case.
skipIf "osx and ghc < 7.10" =<< liftM2 (&&) isOSX (ghcVersionIs (< mkVersion [7,10]))
setup' "configure" [] >>= assertOutputContains "ThisIsCustomYeah"
setup' "build" [] >>= assertOutputContains "ThisIsCustomYeah"
7 changes: 5 additions & 2 deletions cabal-testsuite/PackageTests/ForeignLibs/setup.test.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@ import Test.Cabal.Prelude
-- Recording is turned off because versionedlib will or will not
-- be installed depending on if we're on Linux or not.
main = setupAndCabalTest . recordMode DoNotRecord $ do
-- Foreign libraries don't work with GHC 7.6 and earlier
skipUnlessGhcVersion ">= 7.8"
-- Foreign libraries don't work with GHC 7.6 and earlier
skipUnlessGhcVersion ">= 7.8"
osx <- isOSX
ghc <- isGhcVersion "== 8.0.2"
expectBrokenIf (osx && ghc) 7989 $
withPackageDb $ do
setup_install []
setup "copy" [] -- regression test #4156
Expand Down
4 changes: 4 additions & 0 deletions cabal-testsuite/PackageTests/NewBuild/T3827/cabal.test.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import Test.Cabal.Prelude
main = cabalTest $ do
missesProfiling <- isGhcVersion ">= 9.2.1"
osx <- isOSX
missesProfilingOsx <- isGhcVersion ">= 8.10.7"
expectBrokenIf (missesProfiling || osx && missesProfilingOsx) 8032 $
cabal "v2-build" ["exe:q"]
5 changes: 4 additions & 1 deletion cabal-testsuite/PackageTests/Regression/T4025/setup.test.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import Test.Cabal.Prelude
-- an executable RPATH. Don't test on Windows, which doesn't
-- support RPATH.
main = setupAndCabalTest $ do
skipIfWindows
skipIfWindows
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we could move this skipIfWindows to expectBrokenIf ((osx || win) && ghc)

maybe it should be in other pr, revising all skipIfWindows and transform as much of them as possible in knownBrokenIfWindows

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think I'd prefer to leave this out. Skipping might also be more appropriate (in some of those ifWindows cases at least), where we test non-Windows functionality, instead of something that we'd usually expect to work but that's broken for some reason.

(There's a second difference -- expectBrokenIf tests will be run, while skipIf won't. So e.g. for tests that are too slow, we can't use expectBrokenIf.)

osx <- isOSX
ghc <- isGhcVersion ">= 8.10.7"
expectBrokenIf (osx && ghc) 7610 $ do -- see also issue #7988
setup "configure" ["--enable-executable-dynamic"]
setup "build" []
-- This should fail as it we should NOT be able to find the
Expand Down
7 changes: 5 additions & 2 deletions cabal-testsuite/PackageTests/Regression/T4270/setup.test.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,8 @@ main = setupAndCabalTest $ do
skipUnless "no shared libs" =<< hasSharedLibraries
skipUnless "no shared Cabal" =<< hasCabalShared
skipUnless "no Cabal for GHC" =<< hasCabalForGhc
setup_build ["--enable-tests", "--enable-executable-dynamic"]
setup "test" []
ghc <- isGhcVersion "== 8.0.2"
osx <- isOSX
expectBrokenIf (osx && ghc) 8028 $ do
setup_build ["--enable-tests", "--enable-executable-dynamic"]
setup "test" []
2 changes: 1 addition & 1 deletion cabal-testsuite/PackageTests/SPDX/cabal-old-build.test.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import Test.Cabal.Prelude
main = setupAndCabalTest $ withPackageDb $ do
setup_install []
recordMode DoNotRecord $ do
ghc84 <- ghcVersionIs (>= mkVersion [8,4])
ghc84 <- isGhcVersion ">= 8.4"
let lic = if ghc84 then "BSD-3-Clause" else "BSD3"
ghcPkg' "field" ["my", "license"] >>= assertOutputContains lic
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import qualified Distribution.Verbosity as Verbosity
import Test.Cabal.Prelude

main = cabalTest $ do
skipIf "osx" =<< isOSX -- TODO: re-enable this once the macOS Travis
skipIf "osx" =<< isOSX -- TODO: re-enable this once the macOS CI
-- issues are resolved, see discussion in #4902.

hasShared <- hasSharedLibraries
Expand Down
2 changes: 1 addition & 1 deletion cabal-testsuite/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ and stderr.
**How do I skip running a test in some environments?** Use the
`skipIf` and `skipUnless` combinators. Useful parameters to test
these with include `hasSharedLibraries`, `hasProfiledLibraries`,
`hasCabalShared`, `ghcVersionIs`, `isWindows`, `isLinux`, `isOSX`
`hasCabalShared`, `isGhcVersion`, `isWindows`, `isLinux`, `isOSX`
and `hasCabalForGhc`.

**I programatically modified a file in my test suite, but Cabal/GHC
Expand Down
33 changes: 18 additions & 15 deletions cabal-testsuite/src/Test/Cabal/Prelude.hs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import Distribution.Simple.Configure
import Distribution.Version
import Distribution.Package
import Distribution.Parsec (eitherParsec)
import Distribution.Pretty (prettyShow)
import Distribution.Types.UnqualComponentName
import Distribution.Types.LocalBuildInfo
import Distribution.PackageDescription
Expand Down Expand Up @@ -765,7 +764,7 @@ getScriptCacheDirectory script = do

hasSharedLibraries :: TestM Bool
hasSharedLibraries = do
shared_libs_were_removed <- ghcVersionIs (>= mkVersion [7,8])
shared_libs_were_removed <- isGhcVersion ">= 7.8"
return (not (buildOS == Windows && shared_libs_were_removed))

hasProfiledLibraries :: TestM Bool
Expand All @@ -789,13 +788,23 @@ hasCabalShared = do
env <- getTestEnv
return (testHaveCabalShared env)

ghcVersionIs :: WithCallStack ((Version -> Bool) -> TestM Bool)
ghcVersionIs f = do
isGhcVersion :: WithCallStack (String -> TestM Bool)
isGhcVersion range = do
ghc_program <- requireProgramM ghcProgram
case programVersion ghc_program of
Nothing -> error $ "ghcVersionIs: no ghc version for "
v <- case programVersion ghc_program of
Nothing -> error $ "isGhcVersion: no ghc version for "
++ show (programLocation ghc_program)
Just v -> return (f v)
Just v -> return v
vr <- case eitherParsec range of
Left err -> fail err
Right vr -> return vr
return (v `withinRange` vr)

skipUnlessGhcVersion :: String -> TestM ()
skipUnlessGhcVersion range = skipUnless ("needs ghc " ++ range) =<< isGhcVersion range

skipIfGhcVersion :: String -> TestM ()
skipIfGhcVersion range = skipUnless ("incompatible with ghc " ++ range) =<< isGhcVersion range

isWindows :: TestM Bool
isWindows = return (buildOS == Windows)
Expand All @@ -809,12 +818,6 @@ isLinux = return (buildOS == Linux)
skipIfWindows :: TestM ()
skipIfWindows = skipIf "Windows" =<< isWindows

skipUnlessGhcVersion :: String -> TestM ()
skipUnlessGhcVersion str =
case eitherParsec str of
Right vr -> skipUnless ("needs ghc" ++ prettyShow vr) =<< ghcVersionIs (`withinRange` vr)
Left err -> fail err

getOpenFilesLimit :: TestM (Maybe Integer)
#ifdef mingw32_HOST_OS
-- No MS-specified limit, was determined experimentally on Windows 10 Pro x64,
Expand Down Expand Up @@ -855,7 +858,7 @@ hasCabalForGhc = do
-- You'll want to exclude them in that case.
--
hasNewBuildCompatBootCabal :: TestM Bool
hasNewBuildCompatBootCabal = ghcVersionIs (>= mkVersion [7,9])
hasNewBuildCompatBootCabal = isGhcVersion ">= 7.9"

------------------------------------------------------------------------
-- * Broken tests
Expand Down Expand Up @@ -959,7 +962,7 @@ getIPID pn = do
delay :: TestM ()
delay = do
env <- getTestEnv
is_old_ghc <- ghcVersionIs (< mkVersion [7,7])
is_old_ghc <- isGhcVersion "< 7.7"
-- For old versions of GHC, we only had second-level precision,
-- so we need to sleep a full second. Newer versions use
-- millisecond level precision, so we only have to wait
Expand Down