Skip to content

build-type: Custom seems to break doctests when using haddock #7213

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

Open
ezzieyguywuf opened this issue Dec 26, 2020 · 6 comments
Open

build-type: Custom seems to break doctests when using haddock #7213

ezzieyguywuf opened this issue Dec 26, 2020 · 6 comments

Comments

@ezzieyguywuf
Copy link

Describe the bug
If the build-type: Custom is used, which is necessary for doctest, then running ./setup haddock ends up deleting some files that are necessary for the test-suite to run. Re-running ./setup build will re-generate the deleted files.

To Reproduce

  1. Set up a project using doctest
  2. Make sure that the test-suite target depends on the library
  3. Run the following commands
ghc Setup.lhs -o setup
./setup configure --enable-tests
./setup build
./setup haddock
./setup test # tests fail
./setup build # the deleted files are re-built
./setup test # tests pass

Please use version-prefixed commands (e.g. `v2-build` or `v1-build`) to avoid ambiguity.

**Expected behavior**
I expect that regardless of the `build-type`, the `test-suite` will pass if indeed the code is sound. I do **not** expect for the `./setup haddock` call to delete anything.

**System information**
 - Gentoo Linux
 - ghc 8.10.2
 - cabal library version 3.2.0.0

**Additional context**
A full working, minimal project can be found [here](https://gitlab.com/ezzieyguywuf/testfailure) which reproduces the error.
ezzieyguywuf added a commit to ezzieyguywuf/gentoo-haskell that referenced this issue Dec 28, 2020
This is added as a temporary workaround until [this upstream][1] issue
can be closed out

[1]: haskell/cabal#7213

Signed-off-by: Wolfgang E. Sanyer <[email protected]>
gentoo-bot pushed a commit to gentoo/gentoo that referenced this issue Jan 30, 2021
This is added as a temporary workaround until [this upstream][1] issue
can be closed out

[1]: haskell/cabal#7213

Signed-off-by: Wolfgang E. Sanyer <[email protected]>
Signed-off-by: Sergei Trofimovich <[email protected]>
@Mikolaj
Copy link
Member

Mikolaj commented Aug 30, 2021

AFAIK, doctests don't require Custom setups any more. BTW, the most up to date cabal ticket about doctests (with links to other tickets), is here: #4500

@andreasabel
Copy link
Member

@Mikolaj wrote:

AFAIK, doctests don't require Custom setups any more.

Ah, that is something I should learn. Do you have a link to a howto?

@andreasabel andreasabel added the re: doctest Concerning doctest suites label Nov 7, 2021
@Mikolaj
Copy link
Member

Mikolaj commented Nov 8, 2021

Actually, I'm not sure about the unqualified version of my claim any more. However, if you are willing to run doctests with cabal build . && cabal exec cabal test doctests the following setup works for me (and documentation for the packages I use may have some further links: https://github.com/LambdaHack/LambdaHack/blob/master/LambdaHack.cabal#L458

Edit: also on topic: https://twitter.com/TechnoEmpress/status/1457398534525923328

@fgaz
Copy link
Member

fgaz commented Nov 8, 2021

Another alternative: https://github.com/phadej/cabal-extras/tree/master/cabal-docspec

@andreasabel
Copy link
Member

@fgaz: Thanks for the pointer. cabal-docspec seems to have the limitation that you can only doctest exported functions. (But it is likely faster than doctest.)

@Mikolaj: Ah, you are using https://github.com/Hexirp/doctest-driver-gen. I need to look into this!

@Mikolaj
Copy link
Member

Mikolaj commented Nov 8, 2021

@Mikolaj: Ah, you are using https://github.com/Hexirp/doctest-driver-gen. I need to look into this!

I think there are other such tools, as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants