-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
run-make: arm command wrappers with drop bombs #125752
Conversation
rustbot has assigned @Mark-Simulacrum. Use |
f9f3c42
to
d9feedf
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.
Looks good, left a few comments.
r? @Kobzol
@rustbot author |
d9feedf
to
7867fb7
Compare
@rustbot ready |
Great, this should help catch us subtle mistakes in runmake tests. @bors r+ |
run-make: enforce `#[must_use]` and arm command wrappers with drop bombs This PR is one in a series of cleanups to run-make tests and the run-make-support library. ### Summary It's easy to forget to actually executed constructed command wrappers, e.g. `rustc().input("foo.rs")` but forget the `run()`, so to help catch these mistakes, we: - Add `#[must_use]` annotations to functions where suitable and compile rmake.rs recipes with `-Dunused_must_use`. - Arm command wrappers with drop bombs on construction to force them to be executed by test code. ### Details Especially for command wrappers like `Rustc`, it's very easy to build up a command invocation but forget to actually execute it, e.g. by using `run()`. This commit adds "drop bombs" to command wrappers, which are armed on command wrapper construction, and only defused if the command is executed (through `run`, `run_fail` or `run_fail_assert_exit_code`). If the test writer forgets to execute the command, the drop bomb will "explode" and panic with an error message. This is so that tests don't silently pass with constructed-but-not-executed command wrappers. We don't add `#[must_use]` for command wrapper helper methods because they return `&mut Self` and can be annoying e.g. if a helper method is conditionally called, such as ``` if condition { cmd.arg("-Cprefer-dynamic"); // <- unused_must_use fires } cmd.run(); // <- even though cmd is eventually executed ``` This PR is best reviewed commit-by-commit. Fixes rust-lang#125703. Because `command_output()` doesn't defuse the drop bomb, it also fixes rust-lang#125617.
Rollup of 6 pull requests Successful merges: - rust-lang#125652 (Revert propagation of drop-live information from Polonius) - rust-lang#125730 (Apply `x clippy --fix` and `x fmt` on Rustc) - rust-lang#125752 (run-make: enforce `#[must_use]` and arm command wrappers with drop bombs) - rust-lang#125756 (coverage: Optionally instrument the RHS of lazy logical operators) - rust-lang#125796 (Also InstSimplify `&raw*`) - rust-lang#125816 (Don't build the `rust-demangler` binary for coverage tests) r? `@ghost` `@rustbot` modify labels: rollup
run-make: enforce `#[must_use]` and arm command wrappers with drop bombs This PR is one in a series of cleanups to run-make tests and the run-make-support library. ### Summary It's easy to forget to actually executed constructed command wrappers, e.g. `rustc().input("foo.rs")` but forget the `run()`, so to help catch these mistakes, we: - Add `#[must_use]` annotations to functions where suitable and compile rmake.rs recipes with `-Dunused_must_use`. - Arm command wrappers with drop bombs on construction to force them to be executed by test code. ### Details Especially for command wrappers like `Rustc`, it's very easy to build up a command invocation but forget to actually execute it, e.g. by using `run()`. This commit adds "drop bombs" to command wrappers, which are armed on command wrapper construction, and only defused if the command is executed (through `run`, `run_fail` or `run_fail_assert_exit_code`). If the test writer forgets to execute the command, the drop bomb will "explode" and panic with an error message. This is so that tests don't silently pass with constructed-but-not-executed command wrappers. We don't add `#[must_use]` for command wrapper helper methods because they return `&mut Self` and can be annoying e.g. if a helper method is conditionally called, such as ``` if condition { cmd.arg("-Cprefer-dynamic"); // <- unused_must_use fires } cmd.run(); // <- even though cmd is eventually executed ``` This PR is best reviewed commit-by-commit. Fixes rust-lang#125703. Because `command_output()` doesn't defuse the drop bomb, it also fixes rust-lang#125617.
This comment has been minimized.
This comment has been minimized.
💔 Test failed - checks-actions |
💔 Test failed - checks-actions |
@bors r- |
This is incorrectly named (it's actually `env_clear`), and is itself a gigantic footgun: removing `TMPDIR` on Unix and `TMP`/`TEMP` on Windows basically wrecks anything that relies on `std::env::temp_dir` from functioning correctly. For example, this includes rustc's codegen.
- Update all command wrappers and command construction helpers with `#[track_caller]` where suitable to help the drop bomb panic message. - Remove `Deref`/`DerefMut` for `Command` because it was causing issues with resolving to `std::process::Command` in a method call chain.
c1c06d6
to
5ec3eef
Compare
☀️ Test successful - checks-actions |
Finished benchmarking commit (20ba13c): comparison URL. Overall result: ❌ regressions - no action needed@rustbot label: -perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)This benchmark run did not return any relevant results for this metric. CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 678.233s -> 677.565s (-0.10%) |
… r=jieyouxu Remove unused `llvm_readobj.rs` in `run-make-support` `llvm_readobj.rs` seems unused from the migration to `llvm.rs` in rust-lang#125165. Also, `llvm.rs` was missing the drop bombs (rust-lang#125752) in `llvm_readobj.rs`. Part of rust-lang#121876. r? `@jieyouxu`
Rollup merge of rust-lang#126536 - Rejyr:remove-unused-run-make-file, r=jieyouxu Remove unused `llvm_readobj.rs` in `run-make-support` `llvm_readobj.rs` seems unused from the migration to `llvm.rs` in rust-lang#125165. Also, `llvm.rs` was missing the drop bombs (rust-lang#125752) in `llvm_readobj.rs`. Part of rust-lang#121876. r? `@jieyouxu`
This PR is one in a series of cleanups to run-make tests and the run-make-support library.
Summary
It's easy to forget to actually executed constructed command wrappers, e.g.
rustc().input("foo.rs")
but forget therun()
, so to help catch these mistakes, we arm command wrappers with drop bombs on construction to force them to be executed by test code.This PR also removes the
Deref
/DerefMut
impl for our customCommand
which derefs tostd::process::Command
because it can cause issues when trying to use a custom command:fails to compile because the
arg()
is resolved tostd::process::Command::arg
, which returns&mut std::process::Command
that doesn't have arun()
command.This PR also:
env_var
on theimpl_common_helper
macro that was wrongly named and is a footgun (no users).0.1.0
.Details
Especially for command wrappers like
Rustc
, it's very easy to build upa command invocation but forget to actually execute it, e.g. by using
run()
. This commit adds "drop bombs" to command wrappers, which arearmed on command wrapper construction, and only defused if the command
is executed (through
run
,run_fail
).If the test writer forgets to execute the command, the drop bomb will
"explode" and panic with an error message. This is so that tests don't
silently pass with constructed-but-not-executed command wrappers.
This PR is best reviewed commit-by-commit.
try-job: x86_64-msvc