In commercialhaskell/stackage#7727 (comment), @sol suggested I run doctest more directly rather than having a test-suite doctests stanza in my Cabal file (which introduces ~75 lines of boilerplate per package). I started down that path, and then eventually remembered why I really run doctest as a test suite1.
Nixpkgs pulls in packages from Hackage (mostly via Stackage) and creates Nix derivations in a fairly standard way, using cabal2nix. These derivations run test-suites, but not doctest. So, to make sure my tests are run as part of the Nix packaging process, I wrap doctest in a test suite. This is a fairly common pattern for Nix-aware Haskell devs (e.g., from a package that isn’t mine: https://github.com/cdepillabout/termonad/blob/master/termonad.cabal#L156-L166).
I think this is more of a “discussion” than an “issue”, but I’m wondering what the future might look like here.
E.g., hackage2nix (part of cabal2nix) could potentially run cabal doctest on each package2, eliminating the need for the test suite, or doctest could provide some tooling to make the test suite approach less verbose.
I’m not sure what the right answer is, but this seems like a reasonable place to ask the question, and see what other ideas people have, and whether any other approaches already exist.
In commercialhaskell/stackage#7727 (comment), @sol suggested I run
doctestmore directly rather than having atest-suite doctestsstanza in my Cabal file (which introduces ~75 lines of boilerplate per package). I started down that path, and then eventually remembered why I really rundoctestas a test suite1.Nixpkgs pulls in packages from Hackage (mostly via Stackage) and creates Nix derivations in a fairly standard way, using cabal2nix. These derivations run test-suites, but not
doctest. So, to make sure my tests are run as part of the Nix packaging process, I wrapdoctestin a test suite. This is a fairly common pattern for Nix-aware Haskell devs (e.g., from a package that isn’t mine: https://github.com/cdepillabout/termonad/blob/master/termonad.cabal#L156-L166).I think this is more of a “discussion” than an “issue”, but I’m wondering what the future might look like here.
E.g.,
hackage2nix(part ofcabal2nix) could potentially runcabal docteston each package2, eliminating the need for the test suite, ordoctestcould provide some tooling to make the test suite approach less verbose.I’m not sure what the right answer is, but this seems like a reasonable place to ask the question, and see what other ideas people have, and whether any other approaches already exist.
Footnotes
This is made feasible by the cabal-doctest package (not to be confused with
cabal-doctestin this repo, which adds adoctestsubcommand tocabal). ↩Maybe it could somehow identify the subset of packages that have doctests, or the Nixpkgs Haskell infra could include a blacklist of packages that shouldn’t have
doctestrun on them … or something. ↩