Use Cabal API for more robust tests #300
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In #290, I revamped the test suite to be compatible with
cabal new-build
. Well, to be more accurate, I forced everyone to usecabal new-build
, and with an extremely recent version ofcabal-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: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 usedcabal-doctest
library, which performs similar tricks to figure out the right flags to pass todoctest
(which is essentially a wrapper around GHC). Not unrelatedly, much of the code inSetup.hs
is cargo-culted fromcabal-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
, andstack
! This should hopefully make life easier when testing locally, testing on Travis, and for others who want to try the tests out.