commercialhaskell / stack

The Haskell Tool Stack
http://haskellstack.org
BSD 3-Clause "New" or "Revised" License
4k stars 843 forks source link

`stack ghci --test` behaving badly #5522

Open AriFordsham opened 3 years ago

AriFordsham commented 3 years ago

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 mains 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

mpilgrem commented 7 months ago

@AriFordsham, I am working through open issues, including old ones. From my perspective, Stack is behaving as expected: