haskell / haskell/cabal

`cabal v2-install` silently ignores `--run-tests`, but docs suggests it should work

Open
#11,254 5 comments 1 reaction 0 assignees View on GitHub
cabal-install: cmd/install documentation re: --run-tests re: v1-vs-v2
Dominant language
Haskell
Stars
1.7k
Forks
750
Avg merge
4d 3h
Merged PRs (30d)
28

Description

https://github.com/haskell/cabal/blob/8365cec87198fce066bc8389604e285eddfe1d9a/doc/cabal-project-description-file.rst?plain=1#L1050-L1068
> Run package test suite during installation.

I understand this sentence as `cabal v2-install --run-tests` should run the tests. It doesn't.
It also does not alert the user that it ignores the option `--run-tests`.
`cabal v1-install --run-tests` does run the tests.

Here is a reproducer for the situation (attached as zip):
Make a package with a test suite that always fails and run `cabal install --run-tests` (the `v1-` command aborts with error but `v2-` succeeds).

`.cabal`:
```
cabal-version: 3.0
name: install-run-tests
version: 0
build-type: Simple

executable install-run-tests-exe
main-is: Main.hs
hs-source-dirs: .
default-language: Haskell2010
build-depends: base >=4 && < 5

test-suite install-run-tests-test
default-language: Haskell2010
type: exitcode-stdio-1.0
hs-source-dirs: test
main-is: Main.hs
build-depends: base >=4 && < 5
```
Testsuite `test/Main.hs`:
```haskell
import System.Exit

main = do
putStrLn "Test suite always fails."
exitFailure
```
Executable `Main.hs`:
```haskell
main = putStrLn "I am the executable."
```

Simplest fix:
- Report an error if `--run-tests` if passed to `v2-install`.
- Correct the docs.

Elaborate fix:
- Implement `cabal install --run-tests` also for the `v2-` version.

[reproducer.zip](https://github.com/user-attachments/files/22866060/reproducer.zip)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.