Closed bitemyapp closed 9 years ago
Is there a reason why this can't be done by the test suite itself? I'm not really seeing why stack has more information available to it to implement this well.
@snoyberg "the test suite" being doctests or cabal test
?
Not to say this is something Stack specifically has to solve, but it was intensely painful and I'm not sure where a scaffold or other solution should live. I kinda doubt doctests wants to be anything more than the bare-bones utility kit, which is partly why the Setup.hs ends up being so gnarly. Cabal isn't going to do anything either, so that really just leaves Stack or posting a scaffold/example that works on doctests' documentation.
Needing to rely on a scaffold/template for something that should, IMO, just work kinda irks me and I'm hoping somebody will have an idea.
Have you looked at the way hspec works? It uses a preprocessor to discover all of the relevant files and automatically test them. I was thinking of something along those lines for doctest.
@snoyberg I really like using HSpec, that sounds like a good solution. Question is whether doctest maintainer will be open to it or not. :)
I think it's an orthogonal issue. We could have a separate doctest-formatter tool or something that could enable this kind of workflow, or doctest-hspec that ties the two together well.
Closing this. I'll be happy to provide feedback on how to implement a helper library to make this easier, but I don't think stack should be building in this functionality.
@snoyberg understood, thank you!
@snoyberg I need this as I've almost completely moved over to Stack for work and personal dev. Would you have time to explain how to get stack to run the doctests successfully? I can write it up after I get it working for the wiki / docs.
I've done this without needing to modify Setup.hs at all. You can look at the doctest for warp, which will be much sorter if you can rely on the newest version of doctest.
This may be interesting as well: https://github.com/yesodweb/wai/commit/52f892c3c9643a7e0f868832c2d783f3678c980d
@snoyberg these helped a lot. I was able to eventually get it to work but it's still a little persnickety.
<command line>:
Could not find module ‘Database’
Use -v to see a list of the files searched for.
*** Exception: ExitFailure 1
Prelude> doctest ["Database.Bloodhound"]
<no location info>:
module ‘Database.Bloodhound’ is a package module
*** Exception: ExitFailure 1
Prelude> doctest ["-i src"Database.Bloodhound"]
<interactive>:5:39:
lexical error in string/character literal at end of input
Prelude> doctest ["-i src", "Database.Bloodhound"]
Examples: 83 Tried: 83 Errors: 0 Failures: 0
Nevertheless, this should be considerably less difficult for people to pick up than what I had before. Thank you very much!
Or at least makes it less painful.
Perhaps Stack could gather up the doctests for you and run them through doctests' API?
Per https://github.com/commercialhaskell/stack/issues/259#issuecomment-114153410
Yuck.