From b427b0012c16e8e2618b1696146464e32a7a3d46 Mon Sep 17 00:00:00 2001 From: Robert Vollmert Date: Mon, 28 Feb 2022 19:12:42 +0100 Subject: [PATCH 1/6] Remove outdated skip of test CustomPlain on macOS It's travis specific, and the related ticket #3938 has been resolved in the meantime. --- cabal-testsuite/PackageTests/CustomPlain/setup.test.hs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/cabal-testsuite/PackageTests/CustomPlain/setup.test.hs b/cabal-testsuite/PackageTests/CustomPlain/setup.test.hs index 6016b2c4f9b..2b4a27b1388 100644 --- a/cabal-testsuite/PackageTests/CustomPlain/setup.test.hs +++ b/cabal-testsuite/PackageTests/CustomPlain/setup.test.hs @@ -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" From 7cea19ab1b18803b615b9c1ac2faebeb57485177 Mon Sep 17 00:00:00 2001 From: Robert Vollmert Date: Thu, 3 Mar 2022 20:08:41 +0100 Subject: [PATCH 2/6] Note that cabal-with-hpc test skip is not travis-specific --- .../TestSuiteTests/ExeV10/cabal-with-hpc.multitest.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cabal-testsuite/PackageTests/TestSuiteTests/ExeV10/cabal-with-hpc.multitest.hs b/cabal-testsuite/PackageTests/TestSuiteTests/ExeV10/cabal-with-hpc.multitest.hs index e093d559b9f..14f12247548 100644 --- a/cabal-testsuite/PackageTests/TestSuiteTests/ExeV10/cabal-with-hpc.multitest.hs +++ b/cabal-testsuite/PackageTests/TestSuiteTests/ExeV10/cabal-with-hpc.multitest.hs @@ -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 From 6b36f3f987b491486dbe24eaafc3d13fabc83568 Mon Sep 17 00:00:00 2001 From: Robert Vollmert Date: Mon, 28 Feb 2022 19:49:15 +0100 Subject: [PATCH 3/6] Replace ghcVersionIs by isGhcVersion, consistent with isWindows, etc. --- .../PackageTests/CmmSourcesDyn/setup.test.hs | 2 +- .../PackageTests/SPDX/cabal-old-build.test.hs | 2 +- cabal-testsuite/README.md | 2 +- cabal-testsuite/src/Test/Cabal/Prelude.hs | 30 +++++++++---------- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/cabal-testsuite/PackageTests/CmmSourcesDyn/setup.test.hs b/cabal-testsuite/PackageTests/CmmSourcesDyn/setup.test.hs index 072977fdee3..800a540696a 100644 --- a/cabal-testsuite/PackageTests/CmmSourcesDyn/setup.test.hs +++ b/cabal-testsuite/PackageTests/CmmSourcesDyn/setup.test.hs @@ -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 diff --git a/cabal-testsuite/PackageTests/SPDX/cabal-old-build.test.hs b/cabal-testsuite/PackageTests/SPDX/cabal-old-build.test.hs index 98def645f5e..f88f6249197 100644 --- a/cabal-testsuite/PackageTests/SPDX/cabal-old-build.test.hs +++ b/cabal-testsuite/PackageTests/SPDX/cabal-old-build.test.hs @@ -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 diff --git a/cabal-testsuite/README.md b/cabal-testsuite/README.md index 23af47be95f..afb072d7d5c 100644 --- a/cabal-testsuite/README.md +++ b/cabal-testsuite/README.md @@ -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 diff --git a/cabal-testsuite/src/Test/Cabal/Prelude.hs b/cabal-testsuite/src/Test/Cabal/Prelude.hs index 2e728a07866..3e09c709762 100644 --- a/cabal-testsuite/src/Test/Cabal/Prelude.hs +++ b/cabal-testsuite/src/Test/Cabal/Prelude.hs @@ -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 @@ -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 @@ -789,13 +788,20 @@ 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 isWindows :: TestM Bool isWindows = return (buildOS == Windows) @@ -809,12 +815,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, @@ -855,7 +855,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 @@ -959,7 +959,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 From 7dba4e5666b198704819c59f6f7bb678d8d6f6a3 Mon Sep 17 00:00:00 2001 From: Robert Vollmert Date: Mon, 28 Feb 2022 19:50:26 +0100 Subject: [PATCH 4/6] Add skipIfGhcVersion --- cabal-testsuite/src/Test/Cabal/Prelude.hs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cabal-testsuite/src/Test/Cabal/Prelude.hs b/cabal-testsuite/src/Test/Cabal/Prelude.hs index 3e09c709762..fc17d964f8e 100644 --- a/cabal-testsuite/src/Test/Cabal/Prelude.hs +++ b/cabal-testsuite/src/Test/Cabal/Prelude.hs @@ -803,6 +803,9 @@ isGhcVersion range = do 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) From fbeb0a1894adf05bb11ce6f57b3405e9b046c8c1 Mon Sep 17 00:00:00 2001 From: Robert Vollmert Date: Mon, 28 Feb 2022 19:50:44 +0100 Subject: [PATCH 5/6] Mark several failing test cases as "expected broken" Failures are tracked in issues https://github.com/haskell/cabal/issues/7610 https://github.com/haskell/cabal/issues/7987 https://github.com/haskell/cabal/issues/7989 https://github.com/haskell/cabal/issues/8028 https://github.com/haskell/cabal/issues/8032 --- .../PackageTests/Backpack/Includes2/setup-external.test.hs | 4 +++- .../Backpack/Includes2/setup-per-component.test.hs | 6 ++++-- .../Backpack/Includes3/setup-external-ok.test.hs | 4 +++- cabal-testsuite/PackageTests/ForeignLibs/setup.test.hs | 7 +++++-- cabal-testsuite/PackageTests/NewBuild/T3827/cabal.test.hs | 4 ++++ .../PackageTests/Regression/T4025/setup.test.hs | 5 ++++- .../PackageTests/Regression/T4270/setup.test.hs | 7 +++++-- 7 files changed, 28 insertions(+), 9 deletions(-) diff --git a/cabal-testsuite/PackageTests/Backpack/Includes2/setup-external.test.hs b/cabal-testsuite/PackageTests/Backpack/Includes2/setup-external.test.hs index 33f813a5eef..217aa2340d7 100644 --- a/cabal-testsuite/PackageTests/Backpack/Includes2/setup-external.test.hs +++ b/cabal-testsuite/PackageTests/Backpack/Includes2/setup-external.test.hs @@ -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"] diff --git a/cabal-testsuite/PackageTests/Backpack/Includes2/setup-per-component.test.hs b/cabal-testsuite/PackageTests/Backpack/Includes2/setup-per-component.test.hs index cfb08f33ed1..a3809d70fc0 100644 --- a/cabal-testsuite/PackageTests/Backpack/Includes2/setup-per-component.test.hs +++ b/cabal-testsuite/PackageTests/Backpack/Includes2/setup-per-component.test.hs @@ -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"] diff --git a/cabal-testsuite/PackageTests/Backpack/Includes3/setup-external-ok.test.hs b/cabal-testsuite/PackageTests/Backpack/Includes3/setup-external-ok.test.hs index 82cb49643a3..8760bb6b35a 100644 --- a/cabal-testsuite/PackageTests/Backpack/Includes3/setup-external-ok.test.hs +++ b/cabal-testsuite/PackageTests/Backpack/Includes3/setup-external-ok.test.hs @@ -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"] diff --git a/cabal-testsuite/PackageTests/ForeignLibs/setup.test.hs b/cabal-testsuite/PackageTests/ForeignLibs/setup.test.hs index 7b7bae851bf..108219f29f2 100644 --- a/cabal-testsuite/PackageTests/ForeignLibs/setup.test.hs +++ b/cabal-testsuite/PackageTests/ForeignLibs/setup.test.hs @@ -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 diff --git a/cabal-testsuite/PackageTests/NewBuild/T3827/cabal.test.hs b/cabal-testsuite/PackageTests/NewBuild/T3827/cabal.test.hs index a591492b2d9..c1287f9bb2a 100644 --- a/cabal-testsuite/PackageTests/NewBuild/T3827/cabal.test.hs +++ b/cabal-testsuite/PackageTests/NewBuild/T3827/cabal.test.hs @@ -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"] diff --git a/cabal-testsuite/PackageTests/Regression/T4025/setup.test.hs b/cabal-testsuite/PackageTests/Regression/T4025/setup.test.hs index 9f38351758f..0ec5d068147 100644 --- a/cabal-testsuite/PackageTests/Regression/T4025/setup.test.hs +++ b/cabal-testsuite/PackageTests/Regression/T4025/setup.test.hs @@ -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 + 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 diff --git a/cabal-testsuite/PackageTests/Regression/T4270/setup.test.hs b/cabal-testsuite/PackageTests/Regression/T4270/setup.test.hs index a62eef8bfd5..cf3d7afbdfb 100644 --- a/cabal-testsuite/PackageTests/Regression/T4270/setup.test.hs +++ b/cabal-testsuite/PackageTests/Regression/T4270/setup.test.hs @@ -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" [] From 8c09118f4c1585f4fa07d9c244ef363b8d4c409f Mon Sep 17 00:00:00 2001 From: Robert Vollmert Date: Thu, 3 Mar 2022 23:36:37 +0100 Subject: [PATCH 6/6] Raise heap size of memory tests from 8M to 16M (fixes #8029) There appears to be a small regression in heap usage with GHC 9.2.1. This raises the limit to accommodate that, and give a bit of a buffer. Compare analysis at https://github.com/haskell/cabal/issues/8029. --- cabal-install/cabal-install.cabal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cabal-install/cabal-install.cabal b/cabal-install/cabal-install.cabal index 9f68b0137b1..216588ade87 100644 --- a/cabal-install/cabal-install.cabal +++ b/cabal-install/cabal-install.cabal @@ -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