-
Notifications
You must be signed in to change notification settings - Fork 182
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
Add integration test for unwind safety #407
Add integration test for unwind safety #407
Conversation
8051ba8
to
f706742
Compare
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.
Some guidance
|
||
#[derive(Debug, Default)] | ||
struct MockDatabase { | ||
chalk_db: ChalkDatabase, |
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.
I don't think we actually want to wrap an actual database.
} | ||
} | ||
|
||
impl RustIrDatabase<ChalkIr> for MockDatabase { |
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.
For these methods, I was thinking just hardcode what we want to return for trait Foo
and struct Bar
use std::panic; | ||
|
||
// lower program | ||
let mut db = lower_program_with_db! { |
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.
So, we won't actually "lower" anything, it'll just be hardcoded.
let program = db.chalk_db.checked_program().unwrap(); | ||
|
||
// lower goal | ||
let goal = lower_goal! { |
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.
Similarly here. We aren't going to "lower" this, we'll just manually create the UCanonicalGoalInEnvironment
for Foo: Bar
// solve goal but this will panic | ||
db.panic = true; | ||
let result = panic::catch_unwind(|| { | ||
db.solve(&peeled_goal); | ||
}); | ||
assert!(result.is_err() == true); | ||
|
||
// solve again but without panicking this time | ||
db.panic = false; | ||
assert!(db.solve(&peeled_goal).is_some()); |
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.
This is exactly what I was thinking :)
@@ -1,15 +1,35 @@ | |||
#![allow(unused_macros)] | |||
|
|||
macro_rules! lowering_success { | |||
(program $program:tt) => { | |||
macro_rules! lower_program_with_db { |
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.
I don't think we want to change/use anything here.
Closing in favor of #462 Thanks for the initial work here though :) |
This currently does not work because when the panic triggers, the solver lock is poisoned and i am not aware of a way to force un-poisoning it.
One approach that i've tried and that work, is to lock the solver outside of
catch_unwind
but this requires to useAssertUnwindSafe
to use the lock guard insidecatch_unwind
and that kind of defeats the whole purpose of that test.Fixes #260