testsuite: Be explicit about runtime test dependencies
commit5c2286a4038f5f0abdf9152be95d43411e0434b9
authorMatthew Pickering <matthewtpickering@gmail.com>
Mon, 13 Nov 2023 12:57:05 +0000 (13 12:57 +0000)
committerMikolaj <281893+Mikolaj@users.noreply.github.com>
Thu, 16 Nov 2023 13:45:28 +0000 (16 13:45 +0000)
tree8a6e6abf3374da1cb41c1499fdea6f3981859fee
parent840ee9944080e1d843145503fc2ae47bcbf57f32
testsuite: Be explicit about runtime test dependencies

Issue #8356 reports occasional errors from running the testsuite about
multiple package versions available. This stems from the invokation of
`runghc` not being explicit about all dependencies of the testsuite.

The solution is provide a component in the cabal file which is explicit
about which packages the tests can depend on. This component has a
build-depends section which lists all the dependencies that the tests
require.

It would be better if this component was a library component but we
can't do this with a Custom setup because of limitations to do with
per-component builds.

Then we also enable `-hide-all-packages`, so the dependency will not be
available if it is not explicitly listed as a dependency.

You could also imagine a future where the Setup.hs script found the test
files and compiled a single executable which would run all the tests,
rather than invoking runghc on each one individually.

Fixes #8356
cabal-testsuite/README.md
cabal-testsuite/Setup.hs
cabal-testsuite/cabal-testsuite.cabal
cabal-testsuite/src/Test/Cabal/Script.hs
cabal-testsuite/static/Main.hs [new file with mode: 0644]