run-make: arm command wrappers with drop bombs by jieyouxu · Pull Request #125752 · rust-lang/rust (original) (raw)

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 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 custom Command which derefs to std::process::Command because it can cause issues when trying to use a custom command:

fails to compile because the arg() is resolved to std::process::Command::arg, which returns &mut std::process::Command that doesn't have a run() command.

This PR also:

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).

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