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

Support checking for asynchronous exceptions in Lwt tests #166

Open
craigfe opened this issue Aug 1, 2019 · 0 comments
Open

Support checking for asynchronous exceptions in Lwt tests #166

craigfe opened this issue Aug 1, 2019 · 0 comments

Comments

@craigfe
Copy link
Member

craigfe commented Aug 1, 2019

The Lwt test runner currently catches asynchronous exceptions in tests and triggers a test failure. This is nice functionality, but doesn't allow for the use of check_raises to write tests that expect asynchronous exceptions to be thrown. It's clearly possible to write a handler manually via something like this:

  Lwt.catch
    (fun () -> f () >|= fun () -> `Ok)
    (function e -> Lwt.return @@ `Error e)
  >|= function
  | `Error Lib_exn -> Alcotest.(check pass) "Correct exception" () ()
  | `Error _       -> Alcotest.fail "Incorrect exception was thrown"
  | `Ok            -> Alcotest.fail "No exception was thrown"

but it seems to me that it would be nice for alcotest-lwt to provide users with an asynchronous variant of check_raises that hides this boilerplate.

It might be possible to solve #88 at the same time by changing the exception-handling API altogether.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant