-
Notifications
You must be signed in to change notification settings - Fork 697
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow using different Cabal library versions for
cabal-install
test…
…s 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 (cherry picked from commit 716b109)
- Loading branch information
1 parent
4193f06
commit efc8eb1
Showing
21 changed files
with
186 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
import Test.Cabal.Prelude | ||
main = setupTest $ do | ||
skipUnless "no Cabal for GHC" =<< hasCabalForGhc | ||
setup' "configure" [] >>= assertOutputContains "ThisIsCustomYeah" | ||
setup' "build" [] >>= assertOutputContains "ThisIsCustomYeah" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
import Test.Cabal.Prelude | ||
-- Test internal custom preprocessor | ||
main = setupTest $ do | ||
skipUnless "no Cabal for GHC" =<< hasCabalForGhc | ||
setup_build [] | ||
runExe' "hello-world" [] | ||
>>= assertOutputContains "hello from A" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import Test.Cabal.Prelude | ||
main = setupTest $ do | ||
skipIfGhcVersion "== 7.8.4" | ||
recordMode DoNotRecord $ do | ||
skipUnless "no Cabal for GHC" =<< hasCabalForGhc | ||
setup' "configure" ["--enable-tests", "--enable-coverage"] >>= assertOutputContains "ThisIsCustomYeah" | ||
setup' "build" [] | ||
setup' "test" [] >>= assertOutputContains "Package coverage report written to" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 0 additions & 11 deletions
11
cabal-testsuite/PackageTests/MultiRepl/CabalTooOld/cabal.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +0,0 @@ | ||
# cabal v2-update | ||
Downloading the latest package list from test-local-repo | ||
# cabal v2-repl | ||
Resolving dependencies... | ||
Error: [Cabal-7107] | ||
Could not resolve dependencies: | ||
[__0] trying: pkg-a-0 (user goal) | ||
[__1] next goal: pkg-a:setup.Cabal (dependency of pkg-a) | ||
[__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) | ||
[__1] fail (backjumping, conflict set: pkg-a, pkg-a:setup.Cabal) | ||
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) | ||
7 changes: 5 additions & 2 deletions
7
cabal-testsuite/PackageTests/MultiRepl/CabalTooOld/cabal.test.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
import Test.Cabal.Prelude | ||
|
||
main = cabalTest $ withRepo "repo" $ do | ||
main = cabalTest $ recordMode DoNotRecord . withRepo "repo" $ do | ||
-- For the multi-repl command | ||
skipUnlessGhcVersion ">= 9.4" | ||
void $ fails $ cabalWithStdin "v2-repl" ["--keep-temp-files","--enable-multi-repl","pkg-a", "pkg-b"] "" | ||
skipUnlessAnyCabalVersion "< 3.11" | ||
res <- fails $ cabalWithStdin "v2-repl" ["--keep-temp-files","--enable-multi-repl","pkg-a", "pkg-b"] "" | ||
assertOutputContains "constraint from --enable-multi-repl requires >=3.11" res |
9 changes: 0 additions & 9 deletions
9
cabal-testsuite/PackageTests/MultiRepl/EnabledBadClosure/cabal.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +0,0 @@ | ||
# cabal v2-repl | ||
Resolving dependencies... | ||
Error: [Cabal-7107] | ||
Could not resolve dependencies: | ||
[__0] trying: pkg-b-0 (user goal) | ||
[__1] next goal: pkg-b:setup.Cabal (dependency of pkg-b) | ||
[__1] rejecting: pkg-b:setup.Cabal-<VERSION>/installed-<HASH> (constraint from --enable-multi-repl requires >=3.11) | ||
[__1] fail (backjumping, conflict set: pkg-b, pkg-b:setup.Cabal) | ||
After searching the rest of the dependency tree exhaustively, these were the goals I've had most trouble fulfilling: pkg-b (2), pkg-b:setup.Cabal (2) | ||
5 changes: 2 additions & 3 deletions
5
cabal-testsuite/PackageTests/MultiRepl/EnabledBadClosure/cabal.test.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
cabal-testsuite/PackageTests/PackageDB/cabal-fail-no-packagedbs.test.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import Test.Cabal.Prelude | ||
main = cabalTest $ do | ||
withPackageDb $ do | ||
noCabalPackageDb . withPackageDb $ do | ||
withDirectory "p-no-package-dbs" $ do | ||
res <- fails $ cabal' "v2-build" [] | ||
assertOutputContains "No package databases have been specified." res |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
cabal-testsuite/PackageTests/TestSuiteTests/LibV09/setup-deadlock.test.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import Test.Cabal.Prelude | ||
main = setupAndCabalTest $ do | ||
skipUnless "no Cabal for GHC" =<< hasCabalForGhc | ||
skipIfAllCabalVersion "< 2.2" | ||
setup_build ["--enable-tests"] | ||
fails $ setup "test" [] |
2 changes: 1 addition & 1 deletion
2
cabal-testsuite/PackageTests/TestSuiteTests/LibV09/setup.test.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import Test.Cabal.Prelude | ||
-- Test if detailed-0.9 builds correctly | ||
main = setupAndCabalTest $ do | ||
skipUnless "no Cabal for GHC" =<< hasCabalForGhc | ||
skipIfAllCabalVersion "< 1.20" | ||
setup_build ["--enable-tests"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.