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

Exception not shown upon InvariantFailure #385

Open
NicolasT opened this issue Mar 30, 2023 · 1 comment
Open

Exception not shown upon InvariantFailure #385

NicolasT opened this issue Mar 30, 2023 · 1 comment

Comments

@NicolasT
Copy link

When running a test using invariants with tasty-dejafu, when an invariant is violated, all it shows is invariant failure with a trace. I believe this comes from the showCondition function, which doesn't display the inner exception of an InvariantFailure but does include this in the UncaughtException case.

Since my code checking invariants throws exceptions with some message explaining which invariant was violated, it'd be useful to have this displayed so at least I know what's causing the failure (it's not clear from the trace, could be a bug in my invariant check as well).

Is there a particular reason why the exception is discarded? If not, could it be added similar to the UncaughtException case?

@NicolasT
Copy link
Author

I was, for now, able to recover the exception by using a withTeardown from which I print the Condition in a liftIO. Ugly but worked.

This lead me to another question: withTeardown is

(x -> Either Condition y -> Program Basic n a)
  -> Program (WithSetup x) n y
  -> Program (WithSetupAndTeardown x y) n a

Given the teardown function must yield an a, and only got a Condition or an y, the Consistent Result check won't really work since all a can be is some constant.

(Answering my own question: I only realized while writing this, a could be Maybe y in which case the Consistent Result test still makes sense, and the teardown function returns Nothing in case it gets a Left _ value)

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

No branches or pull requests

1 participant