[QuickCheck] Detecting UserInterrupt / getting uncaught exceptions
Simon Hengel
sol at typeful.net
Thu Nov 15 09:39:06 GMT 2012
Hi,
when the user presses ctrl-c I want to abort test runs. I think
currently the only way to achieve this is to check the failure reason,
something like:
isUserInterrupt :: Result -> Bool
isUserInterrupt r = case r of
Failure {reason = "Exception: 'user interrupt'"} -> True
_ -> False
For my use cases it would be convenient if QuickCheck would not catch
(or re-throw) UserInterrupt (or preferably any AsyncException). This
way they would hit 'main' and the program would terminate as expected.
Somewhat related, it would be useful if I could get the exception value
when a property fails due to an uncaught exception, so that I can e.g.
print the exception type. The issue that I see here is that this would
either make the API conditional, or it would tie QuickCheck to
"Control.Exception". Not sure if this is an option. Any thoughts?
Cheers,
Simon
More information about the QuickCheck
mailing list