Skip to content

Commit 93bd6bf

Browse files
committed
Allow using different Cabal library versions for cabal-install tests with custom setup.
The idea here is to pass a `--package-db` flag to `cabal-install` which contains just `Cabal` and `Cabal-syntax` of the specific version. This allows `cabal-install` tests to use the in-tree `Cabal` version, something which you can easily run into and get very confused about when writing tests. There are a few options which can be passed to `cabal-tests` executable to control which Cabal library you will test against. 1. --boot-cabal-lib specifies to use the Cabal library bundled with the test compiler, this is the default and existing behaviour of the testsuite. 2. --intree-cabal-lib=<root_dir> specifies to use Cabal and Cabal-syntax from a specific directory, and `--test-tmp` indicates where to put the package database they are built with. 3. --specific-cabal-lib=<VERSION> specifies to use a specific Cabal version from hackage (ie 3.10.2.0) and installs the package database into --test-tmp=<DIR> The end result is that changes in the Cabal library can be tested with cabal-install tests in the testsuite. There have been a number of confusing issues with people writing tests for changes in the Cabal library which never ran because of cabal-install tests always used the boot Cabal library (see #9425 for one). Fixes #9681
1 parent 4d6375f commit 93bd6bf

File tree

19 files changed

+134
-49
lines changed

19 files changed

+134
-49
lines changed

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import Test.Cabal.Prelude
22
main = cabalTest $ do
3-
-- NB: This variant seems to use the bootstrapped Cabal?
4-
skipUnless "no Cabal for GHC" =<< hasCabalForGhc
53
-- implicit setup-depends conflict with GHC >= 8.2; c.f. #415
64
skipUnlessGhcVersion "< 8.2"
75
-- This test depends heavily on what packages are in the global
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import Test.Cabal.Prelude
22
main = setupTest $ do
3-
skipUnless "no Cabal for GHC" =<< hasCabalForGhc
43
setup' "configure" [] >>= assertOutputContains "ThisIsCustomYeah"
54
setup' "build" [] >>= assertOutputContains "ThisIsCustomYeah"

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import Test.Cabal.Prelude
22
-- Test internal custom preprocessor
33
main = cabalTest $ do
4-
skipUnless "no Cabal for GHC" =<< hasCabalForGhc
5-
64
-- old Cabal's ./Setup.hs output is difficult to normalise
75
recordMode DoNotRecord $
86
cabal "v2-build" []
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import Test.Cabal.Prelude
22
-- Test internal custom preprocessor
33
main = setupTest $ do
4-
skipUnless "no Cabal for GHC" =<< hasCabalForGhc
54
setup_build []
65
runExe' "hello-world" []
76
>>= assertOutputContains "hello from A"
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import Test.Cabal.Prelude
22
main = setupTest $ do
33
recordMode DoNotRecord $ do
4-
skipUnless "no Cabal for GHC" =<< hasCabalForGhc
54
setup' "configure" ["--enable-tests", "--enable-coverage"] >>= assertOutputContains "ThisIsCustomYeah"
65
setup' "build" []
76
setup' "test" [] >>= assertOutputContains "Package coverage report written to"

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import Test.Cabal.Prelude
22
-- Test that if two components have the same module name, they do not
33
-- clobber each other.
44
main = setupAndCabalTest $ do
5-
skipUnless "no Cabal for GHC" =<< hasCabalForGhc -- use of library test suite
65
setup_build ["--enable-tests"]
76
r1 <- fails $ setup' "test" ["foo"]
87
assertOutputContains "test B" r1
Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +0,0 @@
1-
# cabal v2-update
2-
Downloading the latest package list from test-local-repo
3-
# cabal v2-repl
4-
Resolving dependencies...
5-
Error: [Cabal-7107]
6-
Could not resolve dependencies:
7-
[__0] trying: pkg-a-0 (user goal)
8-
[__1] next goal: pkg-a:setup.Cabal (dependency of pkg-a)
9-
[__1] rejecting: pkg-a:setup.Cabal-<VERSION>/installed-<HASH>, pkg-a:setup.Cabal-3.8.0.0 (constraint from --enable-multi-repl requires >=3.11)
10-
[__1] fail (backjumping, conflict set: pkg-a, pkg-a:setup.Cabal)
11-
After searching the rest of the dependency tree exhaustively, these were the goals I've had most trouble fulfilling: pkg-a:setup.Cabal (3), pkg-a (2)
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import Test.Cabal.Prelude
22

3-
main = cabalTest $ withRepo "repo" $ do
3+
main = cabalTest $ recordMode DoNotRecord . withRepo "repo" $ do
4+
-- For the multi-repl command
45
skipUnlessGhcVersion ">= 9.4"
5-
void $ fails $ cabalWithStdin "v2-repl" ["--keep-temp-files","--enable-multi-repl","pkg-a", "pkg-b"] ""
6+
res <- fails $ cabalWithStdin "v2-repl" ["--keep-temp-files","--enable-multi-repl","pkg-a", "pkg-b"] ""
7+
assertOutputContains "constraint from --enable-multi-repl requires >=3.11" res
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 = cabalTest $ do
3-
withPackageDb $ do
3+
noCabalPackageDb . withPackageDb $ do
44
withDirectory "p-no-package-dbs" $ do
55
res <- fails $ cabal' "v2-build" []
66
assertOutputContains "No package databases have been specified." res

cabal-testsuite/PackageTests/Regression/T4270/setup.test.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import Test.Cabal.Prelude
55
main = setupAndCabalTest $ do
66
skipUnless "no shared libs" =<< hasSharedLibraries
77
skipUnless "no shared Cabal" =<< hasCabalShared
8-
skipUnless "no Cabal for GHC" =<< hasCabalForGhc
98
ghc <- isGhcVersion "== 8.0.2"
109
osx <- isOSX
1110
expectBrokenIf (osx && ghc) 8028 $ do

0 commit comments

Comments
 (0)