Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move away from build-type Custom #129

Closed

Conversation

andreabedini
Copy link

cabal-doctest is no longer unsupported or needed.

The author of the doctest package recommends1 to run doctests with

cabal repl --with-ghc=doctest

This change removes the custom-setup and adjusts the test-suite to use the recommended approach above. The package doctest is added to the project with extra-packages to make sure its dependencies are always in scope (a small variation to the approach suggested by the doctest author).

Footnotes

  1. https://github.com/sol/doctest#running-doctest-for-a-cabal-package

cabal-doctest is no longer unsupported or needed.

The author of the `doctest` package recommends[^1] to run doctests with

  cabal repl --with-ghc=doctest

This change removes the custom-setup and adjusts the test-suite to use
the recommended approach above. The package `doctest` is added to the
project with `extra-packages` to make sure its dependencies are always
in scope (a small variation to the approach suggested by the
`doctest` author).

[^1]: https://github.com/sol/doctest#running-doctest-for-a-cabal-package
Copy link
Owner

@cdepillabout cdepillabout left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you change this so that the doctests will be run when you do cabal test?

@andreabedini
Copy link
Author

Could you change this so that the doctests will be run when you do cabal test?

Unfortunately the short answer is no. This is exactly how doctest recommends to be run https://github.com/sol/doctest#running-doctest-for-a-cabal-package.

cabal has a new feature that would allow running doctest with cabal test but that would require coordination with doctest I am afraid. So I thought I'd stick with the recommended way.

@cdepillabout
Copy link
Owner

cdepillabout commented Nov 8, 2023

@andreabedini My two requirements here would be:

  • There's an easy way to run the doctests, ideally as a test target in the .cabal file, so that cabal test would also run the doctests.
  • All the common Haskell build tools can (easily) run the doctests. I have the following in mind:
    • cabal-install
    • stack
    • the Nixpkgs Haskell infrastructure (which is based on Setup.hs / Cabal)
    • haskell.nix (although I know haskell.nix has had trouble with cabal-doctest in the past, so maybe don't need to include this one)

cabal-doctest currently meets these requirements, but has the following drawbacks:

  • It uses Custom
  • Its deprecated ??
  • It often feels somewhat hacky

It would be great if there was a doctest solution that meets all of my above requirements, and doesn't have any of these drawbacks.

@andreabedini
Copy link
Author

The new SetupHooks API will provide a better solution.

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.

Cross-compilation broken by custom Setup.hs used for doctests
2 participants