Skip to content

cabal test integration (GHC 9.4.5) #411

Open
@benjaminweb

Description

@benjaminweb

Objective: How to let doctest run with cabal test?
(I've spent considerable time to learn that I need to call cabal repl --with-ghc=doctest.)

Ideal outcome: README of doctest shows example of doctest integration in package.yaml or cabal file.

Steps to reproduce:

  • checkout repo [1].
  • run cabal test
> cabal test
Resolving dependencies...
Build profile: -w ghc-9.4.5 -O1
In order, the following will be built (use -v for more details):
 - dtest-0.1 (lib) (configuration changed)
 - dtest-0.1 (test:doctest) (dependency rebuilt)
Configuring library for dtest-0.1..
Preprocessing library for dtest-0.1..
Building library for dtest-0.1..
Preprocessing test suite 'doctest' for dtest-0.1..
Building test suite 'doctest' for dtest-0.1..
Running 1 test suites...
Test suite doctest: RUNNING...
src/Lib.hs:4: failure in expression `import qualified Data.HashMap.Strict as HM'
expected:
 but got:
          ^
          <no location info>: error:
              Could not find module ‘Data.HashMap.Strict’
              Perhaps you meant
                Data.Map.Strict (from containers-0.6.7)
                Data.IntMap.Strict (from containers-0.6.7)

Examples: 1  Tried: 1  Errors: 0  Failures: 1


Test suite doctest: FAIL
Test suite logged to:
/Users/benjamin/repos/dtest/dist-newstyle/build/aarch64-osx/ghc-9.4.5/dtest-0.1/t/doctest/test/dtest-0.1-doctest.log
0 of 1 test suites (0 of 1 test cases) passed.
Error: cabal: Tests failed for test:doctest from dtest-0.1.

Expected behaviour:

> cabal repl --with-ghc=doctest
Resolving dependencies...
Build profile: -w ghc-9.4.5 -O1
In order, the following will be built (use -v for more details):
 - dtest-0.1 (lib) (configuration changed)
Configuring library for dtest-0.1..
Preprocessing library for dtest-0.1..
Examples: 1  Tried: 1  Errors: 0  Failures: 0

[1] https://github.com/benjaminweb/doctest-cabal-integration

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions