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

Use cabal-doctest #27

Merged
merged 9 commits into from
Jan 31, 2017
Merged

Use cabal-doctest #27

merged 9 commits into from
Jan 31, 2017

Conversation

phadej
Copy link
Collaborator

@phadej phadej commented Jan 13, 2017

ekmett/bytes#32

Tried locally with GHC HEAD and stack.yaml for ghc 8.0.1, seem to work.

@phadej
Copy link
Collaborator Author

phadej commented Jan 13, 2017

cc @RyanGlScott @bgamari

@phadej phadej force-pushed the new-setup-doctests branch from fa45330 to d101cf0 Compare January 13, 2017 07:46
@phadej phadej force-pushed the new-setup-doctests branch from d101cf0 to 6e26e2c Compare January 13, 2017 07:56
@phadej
Copy link
Collaborator Author

phadej commented Jan 13, 2017

some transient failure in GHC-8.0 job. doctests with GHC-7.0 seems to be genuinely broken.

@phadej phadej force-pushed the new-setup-doctests branch from e772fa4 to 8af9b8b Compare January 13, 2017 08:41
@phadej
Copy link
Collaborator Author

phadej commented Jan 13, 2017

This setup is tested also with bytes, http-api-data and lens. Travis' builds are all green. Also tested locally with stack and cabal new-build.

I'll wait for Ryan's and Ben's comments before merging them there.

@ekmett
Copy link
Owner

ekmett commented Jan 13, 2017

LGTM

Copy link
Collaborator

@RyanGlScott RyanGlScott left a 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 Cabals 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.

##endif

-- | Run in a modified codepage where we can print UTF-8 values on Windows.
withUnicode :: IO a -> IO a
Copy link
Collaborator

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 ;)

Copy link
Collaborator Author

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?

Copy link
Collaborator

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.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Collaborator

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.

where
args =
#ifdef TRUSTWORTHY
"-DTRUSTWORTHY=1" :
Copy link
Collaborator

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?

Copy link
Collaborator Author

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).

Copy link
Collaborator

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?

Copy link
Collaborator Author

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.

@phadej
Copy link
Collaborator Author

phadej commented Jan 13, 2017

See discussion at haskell/cabal#2327 Hopefully in the futurue we don't need setup-type: Custom, neither doctest.hs.

@RyanGlScott
Copy link
Collaborator

Hopefully in the futurue we don't need setup-type: Custom, neither doctest.hs.

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!

@phadej phadej force-pushed the new-setup-doctests branch from 5ae6e7a to 415f914 Compare January 24, 2017 14:47
@phadej
Copy link
Collaborator Author

phadej commented Jan 24, 2017

Ok. Now this seems to work. Next step: I'll make a library out of current Setup.hs, but still use current version for setup-depends unaware cabal-installs.

@phadej phadej changed the title Try out the setup.lhs and doctests.hsc from bytes Use cabal-doctest Jan 31, 2017
@phadej phadej merged commit 65f63b1 into ekmett:master Jan 31, 2017
@phadej phadej deleted the new-setup-doctests branch January 31, 2017 18:30
@RyanGlScott
Copy link
Collaborator

Huzzah!

Now comes the all-important question: do you want to release a new version of distributive now? I don't have time at the moment to go through every remaining Setup.hs in the Kmettiverse and upgrade it to this, but at the very least we could upload this to Hackage for now. That way we could more thoroughly battle-test it in the wild before migrating everything else over to it.

Also there's the question of Stackage (is cabal-doctest currently in Stackage nightly?).

RyanGlScott added a commit that referenced this pull request Jan 31, 2017
@phadej
Copy link
Collaborator Author

phadej commented Jan 31, 2017

I'll add cabal-doctest to Stackage, so it will enter there soonish.

About release: I'm neutral. If there are other reason to release also, then why not.

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.

3 participants