Repository navigation
Open
Description
Describe the bug
Adding or removing --test-options to the cabal test command shouldn't have any affect on the configuration, but it does.
To Reproduce
Clone cabal repo and run,
cabal test integration-tests2
and then run,
cabal test integration-tests2 --test-options '-p "find root"'
this causes all the packages to reconfigure again:
Build profile: -w ghc-8.10.7 -O1
In order, the following will be built (use -v for more details):
- Cabal-syntax-3.7.0.0 (lib) (configuration changed)
- safe-exceptions-0.1.7.2 (lib) (configuration changed)
- hackage-security-0.6.2.1 (lib) (dependency rebuilt)
- Cabal-3.7.0.0 (lib) (configuration changed)
- cabal-install-solver-3.7.0.0 (lib) (configuration changed)
- cabal-install-3.7.0.0 (lib) (configuration changed)
- cabal-install-3.7.0.0 (test:integration-tests2) (configuration changed)
Configuring library for safe-exceptions-0.1.7.2..
Configuring library for Cabal-syntax-3.7.0.0..
Preprocessing library for safe-exceptions-0.1.7.2..
Building library for safe-exceptions-0.1.7.2..
Preprocessing library for Cabal-syntax-3.7.0.0..
Building library for Cabal-syntax-3.7.0.0..
Configuring library for Cabal-3.7.0.0..
Preprocessing library for hackage-security-0.6.2.1..
Building library for hackage-security-0.6.2.1..
Preprocessing library for Cabal-3.7.0.0..
Building library for Cabal-3.7.0.0..
Configuring library for cabal-install-solver-3.7.0.0..
Preprocessing library for cabal-install-solver-3.7.0.0..
Building library for cabal-install-solver-3.7.0.0..
Configuring library for cabal-install-3.7.0.0..
Preprocessing library for cabal-install-3.7.0.0..
Building library for cabal-install-3.7.0.0..
Configuring test suite 'integration-tests2' for cabal-install-3.7.0.0..
Preprocessing test suite 'integration-tests2' for cabal-install-3.7.0.0..
Building test suite 'integration-tests2' for cabal-install-3.7.0.0..
Running 1 test suites...
Even running the exact command multiple times causes it print the following everytime:
Build profile: -w ghc-8.10.7 -O1
In order, the following will be built (use -v for more details):
- cabal-install-3.7.0.0 (test:integration-tests2) (first run)
Preprocessing test suite 'integration-tests2' for cabal-install-3.7.0.0..
Building test suite 'integration-tests2' for cabal-install-3.7.0.0..
Expected behavior
The behaviour should be similar to running executables, where passing arguments to the executable doesn't result in change of configuration.
System information
- Operating system: nixos
cabal,ghcversions: 3.6.2.0, 8.10.7
Additional context
I am not sure why it is that we send the arguments in --test-options for tests and not like how we pass them to executables (after -- ), is it because test-options can contain templates?
Activity
Mikolaj commentedon Apr 8, 2022
Me too, I'd like to learn why this does not use
--. If, by analogy to executables, these were just--arguments to the test executable, obviously this should not cause reconfiguration of all package in the project.So this does not seem to recompile any files, but it reconfigures all packages (or just library components) in the project. That is reconfigures the test component makes sense, because in principle
cabal testbuilds the test component. so it needs to verify if there's anything to do (though I'd expectUp to dateand notfirst runorconfiguration changedor whichever it is). However, behaving differently when given different--test-optionsseems plain wrong.jneira commentedon Apr 9, 2022
Thanks for the report, it seems to me it is closely releated or even a duplicate of #3342 (it mentions
cabal buildbutcabal testshares the main logic with afaik)jneira commentedon Apr 9, 2022
afaiu Duplicate of #5789
workaround
cabal run test-component -- -test-optionor$(cabal list-bin test-component) --test-optionMikolaj commentedon Apr 9, 2022
That's not a complete workaround, because
cabal testsets directories differently, as @pranaysashank experienced, which blocks PR #7749 due to failing cabal tests. :)But I think you are right #5789 is a duplicate. For #3342 to be a duplicate we'd need
cabal build --enable-teststo reconfigure every time it's invoked which, I hope, is not the case.Mikolaj commentedon May 31, 2022
I wonder, did #7614 solved a similar issue (or perhaps partially solve the same issue or perhaps it was accidentally reverted)?