Skip to content

Add cabal-doctest #428

Open
Open

Description

@sol

Initial implementation: #425
Based on: https://github.com/mpickering/cabal-doctest-demo/blob/master/cabal-doctest

Related discussions:

TODO:

Activity

  1. hsyl20 commented on Aug 1, 2024

    @hsyl20
    Contributor

    Thanks for your work on this!

    I've just noticed that there is an issue when multi-repl: True is present in a cabal.project. The repl loads the target but doesn't run the tests:

    Example from https://github.com/haskus/packages/actions/runs/10195092999/job/28203068431:

    Run cabal doctest
    Resolving dependencies...
    Build profile: -w ghc-9.8.2 -O1
    In order, the following will be built (use -v for more details):
     - doctest-0.22.9 (lib) (requires build)
     - doctest-0.22.9 (exe:doctest) (requires build)
    Starting     doctest-0.22.9 (lib)
    Building     doctest-0.22.9 (lib)
    Installing   doctest-0.22.9 (lib)
    Completed    doctest-0.22.9 (lib)
    Starting     doctest-0.22.9 (exe:doctest)
    Building     doctest-0.22.9 (exe:doctest)
    Installing   doctest-0.22.9 (exe:doctest)
    Completed    doctest-0.22.9 (exe:doctest)
    Copying 'doctest' to
    '/home/runner/.cabal/doctest/ghc-9.8.2-6fbce3708d1cdaa02b114e8244ac58f9/doctest-0.22.9'
    doctest version 0.22.9
    using version 9.8.2 of the GHC API
    using /usr/local/.ghcup/ghc/9.8.2/bin/ghc-9.8.2
    Resolving dependencies...
    Build profile: -w ghc-9.8.2 -O1
    In order, the following will be built (use -v for more details):
     - haskus-utils-data-1.4 (interactive) (lib) (configuration changed)
     - haskus-utils-data-1.4 (interactive) (test:tests) (configuration changed)
    Configuring library for haskus-utils-data-1.4...
    Configuring test suite 'tests' for haskus-utils-data-1.4...
    Preprocessing test suite 'tests' for haskus-utils-data-1.4...
    Preprocessing library for haskus-utils-data-1.4...
    GHCi, version 9.8.2: https://www.haskell.org/ghc/  :? for help
    Loaded GHCi configuration from /home/runner/.cabal/doctest/ghc-9.8.2-6fbce3708d1cdaa02b114e8244ac58f9/init-ghci-0.22.9
    [ 1 of 12] Compiling Haskus.Utils.Either[haskus-utils-data-1.4-inplace]
    [ 2 of 12] Compiling Haskus.Utils.Functor[haskus-utils-data-1.4-inplace]
    [ 3 of 12] Compiling Haskus.Utils.InfList[haskus-utils-data-1.4-inplace]
    [ 4 of 12] Compiling Haskus.Utils.List[haskus-utils-data-1.4-inplace]
    [ 5 of 12] Compiling Haskus.Utils.Map[haskus-utils-data-1.4-inplace]
    [ 6 of 12] Compiling Haskus.Utils.Map.Strict[haskus-utils-data-1.4-inplace]
    [ 7 of 12] Compiling Haskus.Utils.Maybe[haskus-utils-data-1.4-inplace]
    [ 8 of 12] Compiling Haskus.Utils.Monad[haskus-utils-data-1.4-inplace]
    [ 9 of 12] Compiling Haskus.Utils.Tuple[haskus-utils-data-1.4-inplace]
    [10 of 12] Compiling Haskus.Utils.HList[haskus-utils-data-1.4-inplace]
    [11 of 12] Compiling Main[haskus-utils-data-1.4-inplace-tests]
    Ok, 11 modules loaded.
    ghci> Leaving GHCi.
    Examples: 0  Tried: 0  Errors: 0  Failures: 0
    

    Similarly, when I try cabal doctest all it requires multi-repl: True but if enabled it just drops me into a repl with all the modules loaded.

  2. sol commented on Aug 1, 2024

    @sol
    OwnerAuthor

    @hsyl20 does passing --disable-multi-repl to cabal doctest on the command line work as a workaround?

  3. hsyl20 commented on Aug 5, 2024

    @hsyl20
    Contributor

    @sol Yes it does

  4. benjaminweb commented on Jul 23, 2026

    @benjaminweb

    I am running cabal test doctests with cabal file v3.4 using cabal-doctest like this:

    test-suite doctests
      type: exitcode-stdio-1.0
      main-is: doctests.hs
      hs-source-dirs: tests
      build-depends:
        base,
        base-compat >=0.10.5 && <1,
        doctest >=0.15 && <1,
        QuickCheck >=2.10 && <3,
        myPackage,
        template-haskell,
    
      ghc-options:
        -threaded
        -rtsopts
        -with-rtsopts=-N
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions