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

Coloured reporting and Template Haskell runner #1

Merged
merged 1 commit into from
Mar 19, 2017
Merged

Conversation

jacobstanley
Copy link
Member

This significantly improves the test runner, adding coloured output 🌈 and some template haskell code for discovering properties.

screen shot 2017-03-19 at 5 33 44 pm

The property discovery is a little hacky, but it does deal with multi-line comments, so the following will not be picked up as a property:

{-
prop_foo =
  not done yet
-}

The failure output pulls in the source code of the property and annotates it with the generated test data, as well as "calling out" which of your propositions actually failed. I can imagine this will be useful when you have a conjoin like thing with many possible ways in which you can fail:

screen shot 2017-03-19 at 5 30 21 pm

The source code annotation relies on the GHC 8.0 CallStack API, so I'm going to need to figure out something to do as a stop gap for use in GHC 7.10. I'll probably just go back to printing the forall's in a list along with their types if compiling for 7.10.

Ignore the churn on the Example.hs file, I was just playing with things to see what different failures would look like in the test runner. Hopefully the source code annotation stuff scales to larger examples, I'm not sure, but I think it should be ok.

My todo list before doing the first Hackage release is basically just adding examples for working with IO, ResourceT and ExceptT to see if there's any issues with Template Haskell property discovery stuff and the interface for monadic tests.

@jacobstanley jacobstanley merged commit d7722a4 into master Mar 19, 2017
@jacobstanley jacobstanley deleted the topic/runner branch March 19, 2017 06:48
@@ -34,15 +34,17 @@ source-repository head
library
build-depends:
base >= 3 && < 5
, base64-bytestring >= 1.0 && < 1.1
, ansi-terminal >= 0.6 && < 0.7

Choose a reason for hiding this comment

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

I know it would be less convenient, but I wonder whether it would be worth splitting up the project into core, runner-terminal, example, etc. I suspect that will be too annoying for the first release.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah I think it's probably worth waiting until there is a concrete burden before doing this

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not too worried about ansi-terminal as a dependency, it's absolutely micro and only depends libraries which already ship with GHC itself (unix / Win32 depending on the platform).

@charleso
Copy link

Updated screenshots or output would be good in the doc. :)

@charleso
Copy link

Next level. 💯

else if elem "--no-color" args then
pure False
else
liftIO $ hSupportsANSI stdout
Copy link
Member

Choose a reason for hiding this comment

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

Agree with your env variable suggestion, this getArgs is pretty brutal.

hSupportANSI will be correct for 99% of users though 👍

Copy link
Member Author

Choose a reason for hiding this comment

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

unfortunately it doesn't work with cabal test (and hence mafia test) !! :(

Copy link
Member Author

Choose a reason for hiding this comment

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

so the only way to get colours is to say mafia test -- --test-option=--color, but yeah an env var would do the trick too, works fine in ghci

@thumphries
Copy link
Member

this is amazing 🔥

HuwCampbell pushed a commit to HuwCampbell/haskell-hedgehog that referenced this pull request Aug 14, 2019
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

3 participants