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

Refactor panic source location tests #209

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

soenkehahn
Copy link
Owner

@soenkehahn soenkehahn commented May 4, 2022

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 the Cargo.toml file.

(I also would like to get rid of test_executables_helper at some point.)

@@ -0,0 +1,39 @@
#[allow(unused_imports)]
Copy link
Owner Author

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?

Copy link
Collaborator

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
);
Copy link
Owner Author

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.

Copy link
Collaborator

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?

@soenkehahn soenkehahn marked this pull request as ready for review May 4, 2022 10:51
@soenkehahn soenkehahn requested a review from casey May 4, 2022 10:51
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

Successfully merging this pull request may close these issues.

2 participants