Don't inherit package database to tests
commitdbe5cf42d2de1a74ce363b2514fc51de3e673ae8
authorMatthew Pickering <matthewtpickering@gmail.com>
Fri, 19 Jan 2024 19:49:05 +0000 (19 19:49 +0000)
committerMikolaj <281893+Mikolaj@users.noreply.github.com>
Thu, 1 Feb 2024 12:26:54 +0000 (1 12:26 +0000)
tree49616526521ad697a77cad868466cc437bb441a2
parent17217c3a0459235502bb92a4b17c8fe82672eab6
Don't inherit package database to tests

I can't think of a reason why it would be desirable to expose the user's
cabal store or local dist-newstyle to the test runner. In fact, this can
break test output in certain situations depending on what is in your
store.

Tests should run in as hemertic environment as possible and not
depend on anything to do with external system configuration.

I have introduced a Note [Testsuite package environments] which explains
what the environments are for the three different components of the
testsuite.

{- Note [Testsuite package environments]

There are three different package environments which are used when running the
testsuite.

1. Environment used to compile `cabal-tests` executable
2. Environment used to run test scripts "setup.test.hs"
3. Environment made available to tests themselves via `./Setup configure`

These are all distinct from each other and should be specified separately.

Where are these environments specified:

1. The build-depends on `cabal-tests` executable in `cabal-testsuite.cabal`
2. The build-depends of `test-runtime-deps` executable in `cabal-testsuite.cabal`
   These dependencies are injected in a special module (`Test.Cabal.ScriptEnv0`) which
   then is consulted in `Test.Cabal.Monad` in order to pass the right environmnet.
   This is mechanism by which the `./Setup` tests have access to the in-tree `Cabal`
   and `Cabal-syntax` libraries.
3. No specification, only the `GlobalPackageDb` is available (see
   `testPackageDBStack`) unless the test itself augments the environment with
   `withPackageDb`.

At the moment, `cabal-install` tests always use the bootstrap cabal, which is a
bit confusing but `cabal-install` is not flexible enough to be given additional
package databases (yet).

-}
cabal-testsuite/main/cabal-tests.hs
cabal-testsuite/src/Test/Cabal/Monad.hs