Skip to content

More consistently pass --package-db flag to tests (backport #9954) #10067

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

Merged
merged 2 commits into from
Jun 3, 2024
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
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
Loading