Skip to content

Add a doctest-% pattern target#11799

Draft
philderbeast wants to merge 4 commits into
haskell:masterfrom
cabalism:add/doctest-pattern-target
Draft

Add a doctest-% pattern target#11799
philderbeast wants to merge 4 commits into
haskell:masterfrom
cabalism:add/doctest-pattern-target

Conversation

@philderbeast

@philderbeast philderbeast commented May 7, 2026

Copy link
Copy Markdown
Collaborator

Fixes #11798. Adds a make help item doctest-PACKAGENAME and targets for running doctests for a single package using a doctest-% pattern rule.

$ make help
...
doctest-PACKAGENAME            Run doctests for a single package (replace PACKAGENAME).
doctest-install                Install doctest tool needed for running doctests.
doctest                        Run doctests in all packages.
$ make doctest-PACKAGENAME
Please use one of the following targets:
doctest-Cabal
doctest-Cabal-described
doctest-Cabal-syntax
doctest-cabal-install
doctest-cabal-install-solver
doctest-cabal-testsuite

Note

There were doctests in cabal-testsuite. These weren't being run before and cannot be run with cd cabal-testsuite && cabal doctest so these use REPL_WITH_DOCTEST. I renamed DOCTEST to CABAL_DOCTEST.


  • Patches conform to the coding conventions.
  • Is this a PR that fixes CI? If so, it will need to be backported to older cabal release branches (ask maintainers for directions).

@ulysses4ever

Copy link
Copy Markdown
Collaborator

thanks for the split but the PR title is still far from what is actually done because of how much is done. I think adding convenience targets and switching between cabal doctest and cabal repl should be different PRs. The latter is highly questionable for me while the former is a no brainer (well, if not for the metaprogramming).

@philderbeast philderbeast force-pushed the add/doctest-pattern-target branch 2 times, most recently from a34b26c to bad57c6 Compare May 9, 2026 23:59
@philderbeast philderbeast force-pushed the add/doctest-pattern-target branch from bad57c6 to 588b37f Compare May 17, 2026 12:12
@philderbeast philderbeast force-pushed the add/doctest-pattern-target branch from 588b37f to f665cce Compare June 6, 2026 14:13
@sol

sol commented Jun 6, 2026

Copy link
Copy Markdown
Member

There were doctests in cabal-testsuite. These weren't being run before and cannot be run with cd cabal-testsuite && cabal doctest so these use REPL_WITH_DOCTEST. I renamed DOCTEST to CABAL_DOCTEST.

Is this still the case with cabal doctest 0.25.0?

If yes, what is the exact error you are encountering?

@philderbeast

philderbeast commented Jun 7, 2026

Copy link
Copy Markdown
Collaborator Author

Is this still the case with cabal doctest 0.25.0?

I saw a different error with doctest-0.24.3 but for doctest-0.25.0 I'm seeing this error using cabal doctest to test cabal-testsuite with ghc-9.12.4:

$ make doctest-cabal-testsuite
...
Configuring cabal-testsuite-3...
unrecognized 'repl' option `--keep-temp-files'
Error: [Cabal-7125]
repl failed for cabal-testsuite-3.
make: *** [Makefile:171: doctest-cabal-testsuite] Error 1

And with cabal repl --with-compiler=doctest, I'm seeing this error with doctest-0.25.0:

$ make doctest-cabal-testsuite
Running doctests for cabal-testsuite:
doctest: unrecognized option `--make'
Try `doctest --help' for more information.
Error: [Cabal-7125]
Failed to build Cabal-syntax-3.17.0.0 (which is required by cabal-testsuite-3).
make: *** [Makefile:171: doctest-cabal-testsuite] Error 1

@philderbeast philderbeast force-pushed the add/doctest-pattern-target branch from b78577e to acd18d1 Compare June 7, 2026 00:43
@sol

sol commented Jun 7, 2026

Copy link
Copy Markdown
Member

How am I supposed to build the test suite?

$ git rev-parse HEAD
a51c4ee1556d816ad86e90db7e6330dd51b0b6e7
$ cd cabal-testsuite
$ cabal build .
Resolving dependencies...
Error: [Cabal-7107]
Could not resolve dependencies:
[__0] trying: cabal-testsuite-3 (user goal)
[__1] unknown package: Cabal-tests (dependency of cabal-testsuite)
[__1] fail (backjumping, conflict set: Cabal-tests, cabal-testsuite)
After searching the rest of the dependency tree exhaustively, these were the goals I've had most trouble fulfilling: cabal-testsuite, Cabal-tests

@philderbeast

Copy link
Copy Markdown
Collaborator Author

How am I supposed to build the test suite?

- $ cabal build .
+ $ cabal build . --project-dir=..

@ulysses4ever

ulysses4ever commented Jun 7, 2026

Copy link
Copy Markdown
Collaborator

cabal is supposed to detect project files up the directory tree though. This is a strange error.

@sol

sol commented Jun 7, 2026

Copy link
Copy Markdown
Member
-- This intercepting project is here to avoid tests picking up a cabal.project
-- from a parent directory, such as the one in the root of the `haskell/cabal`
-- project itself. Having `optional-packages: .` avoids the following warning
-- being added to the `.out` file:
--   Warning: There are no packages or optional-packages in the project
optional-packages: .

Does cabal have anything akin to -C, if yes, I think setting that to a temporary directory would be a better approach. If you don't need parallel test execution, then changing the working directory also would work.

@philderbeast philderbeast force-pushed the add/doctest-pattern-target branch from acd18d1 to bc3abaf Compare June 9, 2026 13:01
Comment thread Makefile
Comment thread Makefile
@philderbeast philderbeast marked this pull request as draft June 9, 2026 13:30
@sol

sol commented Jun 10, 2026

Copy link
Copy Markdown
Member
$ cd cabal-testsuite/
$ rm cabal.project
$ mkdir -p foo && cabal repl --keep-temp-files --repl-multi-file foo
Configuration is affected by cabal.project at
'/home/sol/projects/haskell/cabal'.
Build profile: -w ghc-9.14.1 -O1
In order, the following will be built (use -v for more details):
 - cabal-testsuite-3 (interactive) (file /home/sol/projects/haskell/cabal/dist-newstyle/build/x86_64-linux/ghc-9.14.1/Cabal-tests-3/cache/build changed)
unrecognized 'repl' option `--keep-temp-files'
Error: [Cabal-7125]
repl failed for cabal-testsuite-3.

Does anybody know what's wrong with this cabal invocation?

If this doesn't work, cabal doctest can't possibly work.

@philderbeast philderbeast force-pushed the add/doctest-pattern-target branch from bc3abaf to 26fb52d Compare June 17, 2026 00:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add doctest-% pattern target

3 participants