Uh oh!
There was an error while loading. Please reload this page.
run-make: arm command wrappers with drop bombs - #125752
Conversation
rustbot
commented
May 30, 2024
rustbot has assigned @Mark-Simulacrum. Use |
f9f3c42 to
d9feedfCompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
jieyouxu
commented
May 30, 2024
@rustbot author |
jieyouxu
commented
May 31, 2024
@rustbot ready |
Uh oh!
There was an error while loading. Please reload this page.
Kobzol
commented
May 31, 2024
Great, this should help catch us subtle mistakes in runmake tests. @bors r+ |
bors
commented
May 31, 2024
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.
Fixesrust-lang#125703.
Because `command_output()` doesn't defuse the drop bomb, it also fixesrust-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.
Fixesrust-lang#125703.
Because `command_output()` doesn't defuse the drop bomb, it also fixesrust-lang#125617.bors
commented
May 31, 2024
This comment has been minimized.
This comment has been minimized.
bors
commented
May 31, 2024
💔 Test failed - checks-actions |
bors
commented
Jun 11, 2024
💔 Test failed - checks-actions |
jieyouxu
commented
Jun 11, 2024
@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.
jieyouxu
commented
Jun 11, 2024
bors
commented
Jun 11, 2024
bors
commented
Jun 11, 2024
bors
commented
Jun 11, 2024
☀️ Test successful - checks-actions |
rust-timer
commented
Jun 11, 2024
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/DerefMutimpl for our customCommandwhich derefs tostd::process::Commandbecause 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::Commandthat doesn't have arun()command.This PR also:
env_varon theimpl_common_helpermacro 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