Validation tests: bin_exe! reads CARGO_BIN_EXE_<name> with option_env!, so clippy --all-targets compiles them

The remote CI's Linux leg has failed "Clippy (warnings denied)" on master since at least fc9c99916d
(runs 45911520903, 46004353737, 46104484064, and 46893773054 at d8735b75f0): every bin_exe! use in the
validation crate's integration tests stops with "environment variable `CARGO_BIN_EXE_corpus-triage`
not defined at compile time" (and corpus-pipeline, corpus-vulkan, corpus-index, command-replay), on
the pinned nightly-2026-11-03. The macro read the path with env!, a compile-time error where Cargo
does not set the variable. option_env! compiles either way; when the test runs, nextest's
NEXTEST_BIN_EXE_<name> or Cargo's baked-in path is still taken first, and a missing one panics with
its name instead of failing the build.

Verified: the next msi job runs clippy over the validation crate with no rustc wrapper and a fresh
target, at the parent's macro and at this one.
This commit is contained in:
Anees Iqbal committed 2026-12-02 06:50:40 -08:00
1 parent 0b71bdf72a
commit 56cf3dbd1b
1 file changed
+11 -1
@@ -16,7 +16,17 @@ macro_rules! bin_exe {
($name:literal) => {
std::env::var_os(concat!("NEXTEST_BIN_EXE_", $name))
.map(std::path::PathBuf::from)
.unwrap_or_else(|| std::path::PathBuf::from(env!(concat!("CARGO_BIN_EXE_", $name))))
.unwrap_or_else(|| {
// `option_env!`, not `env!`: Cargo sets `CARGO_BIN_EXE_<name>` for a build of the
// test, but not for `cargo clippy --all-targets`, which only checks it.
std::path::PathBuf::from(option_env!(concat!("CARGO_BIN_EXE_", $name)).expect(
concat!(
"Cargo sets CARGO_BIN_EXE_",
$name,
" when it builds this test"
),
))
})
};
}