Skip to content

--test-options shouldn't change the configuration and rebuild all the packages in the project #8091

Open

Description

@pranaysashank

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, ghc versions: 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

  1. Mikolaj commented on Apr 8, 2022

    @Mikolaj
    Member

    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 test builds the test component. so it needs to verify if there's anything to do (though I'd expect Up to date and not first run or configuration changed or whichever it is). However, behaving differently when given different --test-options seems plain wrong.

  2. jneira commented on Apr 9, 2022

    @jneira
    Member

    Thanks for the report, it seems to me it is closely releated or even a duplicate of #3342 (it mentions cabal build but cabal test shares the main logic with afaik)

  3. jneira commented on Apr 9, 2022

    @jneira
    Member

    afaiu Duplicate of #5789
    workaround cabal run test-component -- -test-option or $(cabal list-bin test-component) --test-option

  4. Mikolaj commented on Apr 9, 2022

    @Mikolaj
    Member

    That's not a complete workaround, because cabal test sets 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-tests to reconfigure every time it's invoked which, I hope, is not the case.

  5. Mikolaj commented on May 31, 2022

    @Mikolaj
    Member

    I wonder, did #7614 solved a similar issue (or perhaps partially solve the same issue or perhaps it was accidentally reverted)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions