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 API for more robust tests #300

Merged
merged 2 commits into from Feb 7, 2018
Merged

Use Cabal API for more robust tests #300

merged 2 commits into from Feb 7, 2018

Conversation

RyanGlScott
Copy link
Collaborator

In #290, I revamped the test suite to be compatible with cabal new-build. Well, to be more accurate, I forced everyone to use cabal new-build, and with an extremely recent version of cabal-install to boot. This "solution" left a sour taste in my mouth, so I sought a more principled approach, which I believe I've found.

We now use a custom Setup.hs script to detect all of the relevant information we'll need to invoke GHC, such as:

  • GHC's path
  • The database flags to pass it
  • The directory in which singletons.cabal is located (previously, we had to pass this manually to the test suite, in one of the more disgusting hacks I've ever put into production)

All of this information is put into an autogenerated module Build_singletons that the test suite uses in turn. This approach was inspired by the widely used cabal-doctest library, which performs similar tricks to figure out the right flags to pass to doctest (which is essentially a wrapper around GHC). Not unrelatedly, much of the code in Setup.hs is cargo-culted from cabal-doctest itself.

The big win from this patch is that we are no longer tied to a particular build tool—the tests now pass with cabal old-build, cabal new-build, and stack! This should hopefully make life easier when testing locally, testing on Travis, and for others who want to try the tests out.

@goldfirere
Copy link
Owner

I am unqualified to review this patch, but very very grateful that you've looked into this. If it works, merge!

@RyanGlScott RyanGlScott merged commit 3ba07e3 into master Feb 7, 2018
@RyanGlScott RyanGlScott deleted the better-tests branch February 7, 2018 16:00
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.

None yet

2 participants