-
Notifications
You must be signed in to change notification settings - Fork 5
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
Refactor panic source location tests #209
base: main
Are you sure you want to change the base?
Conversation
tests/panic_source_locations.rs
Outdated
@@ -0,0 +1,39 @@ | |||
#[allow(unused_imports)] |
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.
These unused_imports
attributes (and the dead_code
attribute below) are to silence warnings for rustc-versions < 1.46
. Is there a better way to do this?
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.
Can you make the imports conditional?
#[rustversion::since(1.46)]
use foo;
assert_eq!( | ||
Some("tests/panic_source_locations.rs:19:16".to_string()), | ||
panic_location | ||
); |
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.
These two assertions are in the same test to make sure they're not executed in parallel. get_panic_location
is not thread-safe, since it modifies the global panic handler. There's other ways to solve this, not sure they're better though.
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.
Can't this also race with other tests, if those tests panic?
This PR gets rid of the
test_executables_panic
executable, while re-implementing the same tests in a different way. I think this is better since the executable is not meant for users of the library and as such ideally shouldn't show up in theCargo.toml
file.(I also would like to get rid of
test_executables_helper
at some point.)