-
Notifications
You must be signed in to change notification settings - Fork 435
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
Catch violations in times(...) expectations #2766
Catch violations in times(...) expectations #2766
Conversation
Adds a new quit() method to universe that causes all spawned actors to quit. It also collects actors exit codes that can be used to verify that all actors quit gracefully, which in turn allows to fail the test if mock objects expectations are not met. Relates to quickwit-oss#2754
I opened #2768 to fix the license header checker. |
Improve panic handling Co-authored-by: Paul Masurel <paul@quickwit.io>
Also adds a check to the universe.drop() to make sure that universe.assert_quit() was indeed called at the end of the test.
Seems like rust-lang/cargo#8379 is the issue here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM...
See comments inline.
Can you investigate the Shared<JoinHandle>
solution too?
If it is a dead-end no pb.
Co-authored-by: Paul Masurel <paul@quickwit.io>
One thing that still annoys me with the current implementation is that when a test that uses universe fails for some unrelated reason the logic in universe drop is still triggered. So, you see two panics - first is your test's panic, which is useful, but then you also get the universe's drop panic with irrelevant message "Did you call universe.assert_quit()?". I just implemented it and it confuses me sometimes, I imagine it might also confuse others. Not really sure how to detect it though. |
@imotov Yes, if it is too confusing we may have to remove this Drop impl. Anyway, LGTM |
If test fails with panic and universe drop is called it kills the test runner instead of displaying the first panic. Relates to quickwit-oss#2766
* Universe shouldn't panic if thread is panicking If test fails with panic and universe drop is called it kills the test runner instead of displaying the first panic. Relates to #2766 * Fix format
Description
Adds a new quit() method to universe that causes all spawned actors to quit. It also collects actors exit codes that can be used to verify that all actors quit gracefully, which in turn allows to fail the test if mock objects expectations are not met.
Relates to #2754
How was this PR tested?
Added several tests to universe.rs. I also had to modify several
times(...)
parameters to make tests pass. Somebody who is more familiar with these tests should probably check if these changes make sense or if I inadvertently found and buried actual bugs.