-
Notifications
You must be signed in to change notification settings - Fork 25
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
Use cabal-doctest #27
Conversation
fa45330
to
d101cf0
Compare
d101cf0
to
6e26e2c
Compare
some transient failure in GHC-8.0 job. doctests with GHC-7.0 seems to be genuinely broken. |
e772fa4
to
8af9b8b
Compare
This setup is tested also with I'll wait for Ryan's and Ben's comments before merging them there. |
LGTM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of inline comments, but otherwise this looks fantastic. Thank you so, so much for taking on this endeavor, @phadej. Setup
scripts are something that quickly exhaust my patience, so I'm glad you're willing to wade through the muck to improve the state of things.
One thing I'm wondering: you mentioned that this works with stack
and cabal new-build
. Does it also work with cabal sandbox
? I remember having some trouble getting that to work at one point. If it doesn't work with sandboxes, it's not a deal-breaker, but something worth considering.
Looking into the future, it looks like the Setup
logic has become much more complicated than it used to be, so it might be wise to put as much of Setup
into a library as possible. Obviously, the lack of custom-setup
on older Cabal
s prevents us from putting everything into a library, but it would still be nice to be able to say:
main :: IO ()
#if MIN_VERSION_Cabal(1,24,0)
main = buildDoctestsModuleHook
#else
main = -- fallback case
#endif
Happily, the logic in the doctests
driver itself is still relatively simple, so it might not need to be put into its own library. Or maybe it should anyway? Up to you.
Anyways, once my inline comments are addressed, feel free to merge.
tests/doctests.hsc
Outdated
##endif | ||
|
||
-- | Run in a modified codepage where we can print UTF-8 values on Windows. | ||
withUnicode :: IO a -> IO a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happily, you could remove the entirety of withUnicode
if you're willing to depend on the code-page
library and use withCP65001
instead. You also wouldn't need this file to be a .hsc
file and could remove the use of hsc2hs
.
Disclaimer: I wrote code-page
;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we (you?) submit a patch to doctest
? It will benefit everyone at once, if it would live there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea. I'll work on a doctest
patch sometime today.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Until that's merged, there's certainly no harm in keeping withUnicode
(or withCP65001
, if you want to get rid of this CPP cruft now). It should be the case that withUnicode . withUnicode = withUnicode
.
tests/doctests.hsc
Outdated
where | ||
args = | ||
#ifdef TRUSTWORTHY | ||
"-DTRUSTWORTHY=1" : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to define TRUSTWORTHY
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's just left from lens
. (IMHO it would be easier just to leave it, than to make a small forks of Setup.hs / doctests.hsc for each package).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me phrase my question this way: is there a reason why the Setup
script can't figure out that TRUSTWORTHY
is a flag, and have it pass that as an argument to doctest
? That is, why wouldn't TRUSTWORTHY
just be in the flags
argument?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. I think I can grab cpp-options
from lib's BuildInfo
. I'll make the change.
See discussion at haskell/cabal#2327 Hopefully in the futurue we don't need |
Certainly. And a I owe you a big thank-you for pursuing that as well. This is a much-needed improvement to the Haskell ecosystem! |
5ae6e7a
to
415f914
Compare
Ok. Now this seems to work. Next step: I'll make a library out of current Setup.hs, but still use current version for |
Huzzah! Now comes the all-important question: do you want to release a new version of Also there's the question of Stackage (is |
I'll add About release: I'm neutral. If there are other reason to release also, then why not. |
ekmett/bytes#32
Tried locally with GHC HEAD and
stack.yaml
for ghc 8.0.1, seem to work.