Skip to content

Commit

Permalink
More consistently pass --package-db flag to tests (backport #9954) (#…
Browse files Browse the repository at this point in the history
…10067)

* More consistently pass --package-db flag to tests

Previously `--package-db` was only passed to test which used the `v2-`
prefix.

Now we pass `--package-db` to things which use the `v2-` prefix, not
things which use the `v1-` prefix and by default assume that unprefixed
commands are v2 commands.

(cherry picked from commit 2b44677)

# Conflicts:
#	cabal-testsuite/PackageTests/CustomTestCoverage/cabal.out

* fixup! resolve conflicts

---------

Co-authored-by: Matthew Pickering <matthewtpickering@gmail.com>
Co-authored-by: Artem Pelenitsyn <a.pelenitsyn@gmail.com>
  • Loading branch information
3 people authored Jun 3, 2024
1 parent c16b7dc commit a437d82
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
12 changes: 6 additions & 6 deletions cabal-testsuite/PackageTests/CustomTestCoverage/cabal.out
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ Build profile: -w ghc-<GHCVER> -O1
In order, the following will be built:
- plain-0.1.0.0 *test (first run)
Configuring plain-0.1.0.0...
Preprocessing library for plain-0.1.0.0..
Building library for plain-0.1.0.0..
Preprocessing test suite 'test' for plain-0.1.0.0..
Building test suite 'test' for plain-0.1.0.0..
Preprocessing library for plain-0.1.0.0...
Building library for plain-0.1.0.0...
Preprocessing test suite 'test' for plain-0.1.0.0...
Building test suite 'test' for plain-0.1.0.0...
Running 1 test suites...
Test suite test: RUNNING...
Test suite test: PASS
Test suite logged to: <ROOT>/cabal.dist/work/./dist/build/<ARCH>/ghc-<GHCVER>/plain-0.1.0.0/test/plain-0.1.0.0-test.log
Test coverage report written to <ROOT>/cabal.dist/work/./dist/build/<ARCH>/ghc-<GHCVER>/plain-0.1.0.0/hpc/vanilla/html/test/hpc_index.html
Package coverage report written to <ROOT>/cabal.dist/work/./dist/build/<ARCH>/ghc-<GHCVER>/plain-0.1.0.0/hpc/vanilla/html/hpc_index.html
1 of 1 test suites (1 of 1 test cases) passed.
Package coverage report written to <ROOT>/cabal.dist/work/./dist/build/<ARCH>/ghc-<GHCVER>/plain-0.1.0.0/hpc/vanilla/html/plain-0.1.0.0/hpc_index.html
Package coverage report written to <ROOT>/cabal.dist/work/./dist/build/<ARCH>/ghc-<GHCVER>/plain-0.1.0.0/hpc/vanilla/html/hpc_index.html
4 changes: 2 additions & 2 deletions cabal-testsuite/PackageTests/Regression/T9640/cabal.out
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ In order, the following will be built:
- one-custom-0.1.0.0 (lib:one-custom) (requires build)
- depend-on-custom-with-exe-0.1.0.0 (lib) (first run)
Configuring one-custom-0.1.0.0...
Preprocessing library for one-custom-0.1.0.0..
Building library for one-custom-0.1.0.0..
Preprocessing library for one-custom-0.1.0.0...
Building library for one-custom-0.1.0.0...
Installing library in <PATH>
Warning: depend-on-custom-with-exe.cabal:16:1: Ignoring trailing fields after sections: "ghc-options"
Configuring library for depend-on-custom-with-exe-0.1.0.0...
Expand Down
2 changes: 1 addition & 1 deletion cabal-testsuite/src/Test/Cabal/DecodeShowBuildInfo.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import System.Exit
--
-- Results can be read via 'withPlan', 'buildInfoFile' and 'decodeBuildInfoFile'.
runShowBuildInfo :: [String] -> TestM ()
runShowBuildInfo args = cabal "build" ("--enable-build-info":args)
runShowBuildInfo args = noCabalPackageDb $ cabal "build" ("--enable-build-info":args)

-- | Read 'build-info.json' for a given package and component
-- from disk and record the content. Helpful for defining test-cases
Expand Down
10 changes: 7 additions & 3 deletions cabal-testsuite/src/Test/Cabal/Prelude.hs
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ cabalGArgs global_args cmd args input = do
| cmd `elem` ["v2-sdist", "path"]
= [ "--project-file=" ++ fp | Just fp <- [testCabalProjectFile env] ]

| cmd == "v2-clean"
| cmd == "v2-clean" || cmd == "clean"
= [ "--builddir", testDistDir env ]
++ [ "--project-file=" ++ fp | Just fp <- [testCabalProjectFile env] ]

Expand All @@ -322,10 +322,14 @@ cabalGArgs global_args cmd args input = do
, "-j1" ]
++ [ "--project-file=" ++ fp | Just fp <- [testCabalProjectFile env] ]
++ ["--package-db=" ++ db | Just db <- [testPackageDbPath env]]
| "v1-" `isPrefixOf` cmd
= [ "--builddir", testDistDir env ]
++ install_args

| otherwise
= [ "--builddir", testDistDir env ] ++
install_args
= [ "--builddir", testDistDir env ]
++ ["--package-db=" ++ db | Just db <- [testPackageDbPath env]]
++ install_args

install_args
| cmd == "v1-install" || cmd == "v1-build" = [ "-j1" ]
Expand Down

0 comments on commit a437d82

Please sign in to comment.