Skip to content

cabal-tests --with-cabal should have sensible default #8401

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

Open
andreasabel opened this issue Aug 19, 2022 · 6 comments
Open

cabal-tests --with-cabal should have sensible default #8401

andreasabel opened this issue Aug 19, 2022 · 6 comments
Labels
cabal-testsuite re: devx Improving the cabal developer experience (internal issue)

Comments

@andreasabel
Copy link
Member

As suggested in #8392 (comment), the result of cabal list-bin cabal-install should be the default for --with-cabal (rather than skipping all tests that require cabal-install).

In general, a --with-PROG should only overwrite an existing default for PROG, at least that is the custom (followed by configure and cabal).

@andreasabel andreasabel added cabal-testsuite re: devx Improving the cabal developer experience (internal issue) labels Aug 19, 2022
@fgaz
Copy link
Member

fgaz commented Aug 19, 2022

Then we'll also need a way to skip cabal-install tests for the lib-only part of the testsuite

@ulysses4ever
Copy link
Collaborator

This may be convenient indeed but I have two reservations.

A mild one: this looks like a case where you may want to be explicit about the argument, because it’s the single most important one for the whole test suite.

Next, technical: is there a precedent in the whole project where some tool calls some other tool to infer a default value of its parameter. This looks like an extremely fragile scheme. What if there’s no cabal built yet? What if it’s stale? That’s why I’m slightly leaning towards explicit argument passing in this case: it raises the chance that the user actually realizes that the value makes any sense.

The current behavior is not satisfying either. I think I’d prefer it to fail if no --with-cabal provided (for lib tests that are okay with missing cabal there may be another argument, e.g. --only-lib or something). But I’m not actively against this proposal either.

@andreasabel
Copy link
Member Author

Then we'll also need a way to skip cabal-install tests for the lib-only part of the testsuite

As I suggested in another thread, I find --with-cabal=- intuitive to state that the testsuite should be run without cabal-install.

I haven't thought through the cabal list-bin cabal-install which @Mikolaj suggested. If fact, I don't like cabal list-bin because it doesn't straight out print the last generated executable, but starts musing about whether it needs to reconfigure the project. And if you switched GHC to another version in the meantime, it cries "trouble". I prefer cabal-plan list-bin which doesn't make any fuss.

@ulysses4ever : If --with-cabal should be mandatory, then the use of option syntax --OPT is wrong. Options are for optional things. The correct syntax is then:

cabal-tests CABAL FILES ...

CABAL  The cabal-install executable to use in the test suite.

@Mikolaj
Copy link
Member

Mikolaj commented Aug 20, 2022

I prefer cabal-plan list-bin which doesn't make any fuss.

Agreed. If we go for it, we definitely should not try to configure or build the in-tree cabal, but instead fail hard if it's not present (all this assuming the user did not specify the cabal to use).

@andreasabel
Copy link
Member Author

Just fell into this trap again today. Maybe the --with-cabal option could be added to the example in the docs here:

2. Run the `cabal-tests` executable. It will scan for all tests
in your current directory and subdirectories and run them.
To run a specific set of tests, use `cabal-tests PATH ...`.
(e.g. `cabal run cabal-testsuite:cabal-tests -- cabal-testsuite/PackageTests/TestOptions/setup.test.hs`)

Also, cabal-tests could emit a clear warning if --with-cabal was not supplied. The current communication looks like this:

$ cabal-tests -- cabal-testsuite/PackageTests/ListBin/Script/cabal.test.hs 
/usr/local/bin/runghc-9.4.4 -- '--ghc-arg=-i' '--ghc-arg=-no-user-package-db' '--ghc-arg=-package-db' '--ghc-arg=/Users/abel/.cabal/store/ghc-9.4.4/package.db' '--ghc-arg=-package-db' '--ghc-arg=/Users/abel/bin/src/cabal/dist-newstyle/packagedb/ghc-9.4.4' '--ghc-arg=-package-id' '--ghc-arg=Cabal-3.9.0.0-inplace' '--ghc-arg=-package-id' '--ghc-arg=Cabal-syntax-3.9.0.0-inplace' '--ghc-arg=-package-id' '--ghc-arg=sync-2.2.4-67e91ea5' '--ghc-arg=-package-id' '--ghc-arg=base-4.17.0.0' '--ghc-arg=-package-id' '--ghc-arg=cabal-testsuite-3-inplace' '--ghc-arg=-package-id' '--ghc-arg=clck-0.8.3-0601bb17' '--ghc-arg=-package-id' '--ghc-arg=exceptions-0.10.5' '--ghc-arg=-package-id' '--ghc-arg=filepath-1.4.2.2' '--ghc-arg=-package-id' '--ghc-arg=ptprs-pplctv-0.16.1.0-d424affa' '--ghc-arg=-package-id' '--ghc-arg=process-1.6.16.0' '--ghc-arg=-package-id' '--ghc-arg=transformers-0.5.6.2' cabal-testsuite/PackageTests/ListBin/Script/cabal.test.hs --builddir /Users/abel/bin/src/cabal/dist-newstyle/build/x86_64-osx/ghc-9.4.4/cabal-testsuite-3 cabal-testsuite/PackageTests/ListBin/Script/cabal.test.hs
SKIP no cabal-install
cabal.test.hs: TestCodeSkip "no cabal-install"
cabal-tests: callProcess: /usr/local/bin/runghc-9.4.4 "--" "--ghc-arg=-i" "--ghc-arg=-no-user-package-db" "--ghc-arg=-package-db" "--ghc-arg=/Users/abel/.cabal/store/ghc-9.4.4/package.db" "--ghc-arg=-package-db" "--ghc-arg=/Users/abel/bin/src/cabal/dist-newstyle/packagedb/ghc-9.4.4" "--ghc-arg=-package-id" "--ghc-arg=Cabal-3.9.0.0-inplace" "--ghc-arg=-package-id" "--ghc-arg=Cabal-syntax-3.9.0.0-inplace" "--ghc-arg=-package-id" "--ghc-arg=sync-2.2.4-67e91ea5" "--ghc-arg=-package-id" "--ghc-arg=base-4.17.0.0" "--ghc-arg=-package-id" "--ghc-arg=cabal-testsuite-3-inplace" "--ghc-arg=-package-id" "--ghc-arg=clck-0.8.3-0601bb17" "--ghc-arg=-package-id" "--ghc-arg=exceptions-0.10.5" "--ghc-arg=-package-id" "--ghc-arg=filepath-1.4.2.2" "--ghc-arg=-package-id" "--ghc-arg=ptprs-pplctv-0.16.1.0-d424affa" "--ghc-arg=-package-id" "--ghc-arg=process-1.6.16.0" "--ghc-arg=-package-id" "--ghc-arg=transformers-0.5.6.2" "cabal-testsuite/PackageTests/ListBin/Script/cabal.test.hs" "--builddir" "/Users/abel/bin/src/cabal/dist-newstyle/build/x86_64-osx/ghc-9.4.4/cabal-testsuite-3" "cabal-testsuite/PackageTests/ListBin/Script/cabal.test.hs" (exit 1): failed

andreasabel added a commit that referenced this issue Jan 13, 2023
- Add caveat to `--help` text.
- Put `--with-cabal` into very first example in README.
@andreasabel
Copy link
Member Author

Because cabal run cabal-testsuite:cabal-tests puts the correct cabal into the PATH, the default for --with-cabal could simply be cabal. The test runner could inform about the choice of cabal when starting up (by printing the full path of the resolved cabal).

If one wants to skip the cabal-install tests, we could have an option --skip-cabal-install-tests, in the same way as we have a --skip-setup-tests already.

andreasabel added a commit that referenced this issue Jan 13, 2023
- Add caveat to `--help` text.
- Put `--with-cabal` into very first example in README.
andreasabel added a commit that referenced this issue Jan 16, 2023
- Add caveat to `--help` text.
- Put `--with-cabal` into very first example in README.
mergify bot added a commit that referenced this issue Jan 16, 2023
cabal-testsuite #8401: communicate better the need for `--with-cabal`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cabal-testsuite re: devx Improving the cabal developer experience (internal issue)
Projects
None yet
Development

No branches or pull requests

4 participants