commercialhaskell / commercialhaskell/stack

`stack ghci --test` behaving badly

Open
#5,522 1 comment 0 reactions 0 assignees View on GitHub
component: ghci type: question
Dominant language
Haskell
Stars
4.1k
Forks
850
Avg merge
10h 37m
Merged PRs (30d)
4

Description

### General summary/comments (optional)
`stack ghci --test` is mentioned in the docs as being supported, but behaves strangely in my project

### Steps to reproduce

Project with library, no executable, multiple test suites

package.yaml: (excerpts)
```
library:
source-dirs: src

tests:
hlint:
source-dirs: test
main: hlint.hs
ghc-options:
- -threaded
- -with-rtsopts=-N
dependencies:
- hlint-test
hspec:
source-dirs: test
main: hspec.hs
ghc-options:
- -threaded
- -with-rtsopts=-N
dependencies:
- fcm-deepref-experiment
- hspec

quickcheck:
source-dirs: test
main: quickcheck.hs
ghc-options:
- -threaded
- -with-rtsopts=-N
dependencies:
- fcm-deepref-experiment
- QuickCheck
- quickcheck-classes
```

1. Run `stack ghci`
2. Run `stack ghci --tests`

### Expected

1. `ghci` loads, with no main module, 'cos there's none under `src`
2. `stack` runs test suite, and if successful, loads `ghci` without main module as above.

### Actual

What actually happened.

1. `stack ghci` runs as expected.
2. `stack ghci --test`:
- Prints
```
2021-04-13 14:29:35.354891: [info] fcm-deepref-experiment> Test running disabled by --no-run-tests flag.
```
- Reports: 'The main module is ambiguous' and lists all the `main`s under `test`. (No-one asked it to load `test`, except to run tests) and asks to specify a main module
- (Pressed Enter as no main module wanted)
- Warns of multiple modules with same name
- Loads `ghci`

output: https://gist.github.com/AriFordsham/cbc6802f0f1edacd5d6a2b3f5a190970

### Stack version

```
$ stack --version
Version 2.5.1, Git revision d6ab861544918185236cf826cb2028abb266d6d5 x86_64 hpack-0.33.0
```

### Method of installation

Debian repo

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.