-
Notifications
You must be signed in to change notification settings - Fork 318
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
Fix: Ignore CARGO_BUILD_TARGET
in tests
#1010
Conversation
When build target triples are explicitly specified, the layout of the target directory is changed from `target/...` to `target/<triple>/...`. See: https://doc.rust-lang.org/cargo/guide/build-cache.html This caused bin tests failures in `tests/profile.rs`. This patch proposes that we simply ignore the `CARGO_BUILD_TARGET` env var in tests to avoid such problems. A new test is introduced to ensure the correct behavior.
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.
Looks sensible.
This follows from the previous commit. It turns out that `std::env::set_var` is unsafe: the `set_var` in bin tests leaked through the threads and caused `lib` tests to fail. To mitigate this problem we simply remove the `CARGO_BUILD_TARGET` variable in lib tests as well. This also improves correctness. Meanwhile we put `std::env::set_var` and `remove_var` in unsafe blocks as it would be required by Rust 2024.
New commit: it turns out that To mitigate this problem we simply remove the |
Friendly ping @emilio for re-review 😆 |
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.
Ok, looks good with #[serial]
added, thanks!
... also remove an unnecessary `assert`.
Indeed, thank you very much! Fixed in a new commit, awaiting CI! |
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.
Thanks!
Thank you very much for merging! By the way, when would you expect to have the next point release? This information will help us downstream (such as nixpkgs) decide whether to update the patch or just wait for the next release 😆 |
Related: NixOS/nixpkgs#298108
When build target triples are explicitly specified, the layout of the target directory is changed from
target/...
totarget/<triple>/...
. See: https://doc.rust-lang.org/cargo/guide/build-cache.html. This caused bin tests failures intests/profile.rs
.For example, in nixpkgs
CARGO_BUILD_TARGET
is automatically set up, and we observe the following test failures:See: NixOS/nixpkgs#298108 (comment)
This patch proposes that we simply ignore the
CARGO_BUILD_TARGET
env var in tests to avoid such problems. A new test is introduced to ensure the correct behavior.