[QuickCheck] Detecting UserInterrupt / getting uncaught exceptions
Nick Smallbone
nick.smallbone at gmail.com
Thu Nov 15 12:30:31 GMT 2012
Hi Simon,
My first thought was "let's make QuickCheck rethrow any interrupt
exceptions that it gets". But this would make it impossible to get a
Result back from quickCheckResult if the user pressed ctrl-C. So I
think probably you will have to rethrow the exception yourself.
But it's bad that you have to parse the failure reason to find out
what the exception was. I think I'll add an exception field to Result
to fix that. It won't tie QuickCheck to the new exceptions API: the
field will just have type Maybe SomeException on new GHCs and Maybe
Exception on old GHCs/Hugs.
Nick
On 15 November 2012 10:39, Simon Hengel <sol at typeful.net> wrote:
> 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
>
> _______________________________________________
> QuickCheck mailing list
> QuickCheck at projects.haskell.org
> http://projects.haskell.org/cgi-bin/mailman/listinfo/quickcheck
More information about the QuickCheck
mailing list