Disambiguate between rustc vs std having debug assertions
Additionally, `NO_DEBUG_ASSERTIONS` is set by CI that threads through to the `./configure` script, which is somewhat fragile and "spooky action at a distance". Instead, use env vars controlled by compiletest, whose debug assertion info comes from bootstrap.
This commit is contained in:
parent
855e0fe46e
commit
120c9fcb86
2 changed files with 25 additions and 3 deletions
|
|
@ -225,6 +225,19 @@ impl TestCx<'_> {
|
|||
cmd.env("RUNNER", runner);
|
||||
}
|
||||
|
||||
// Guard against externally-set env vars.
|
||||
cmd.env_remove("__RUSTC_DEBUG_ASSERTIONS_ENABLED");
|
||||
if self.config.with_rustc_debug_assertions {
|
||||
// Used for `run_make_support::env::rustc_debug_assertions_enabled`.
|
||||
cmd.env("__RUSTC_DEBUG_ASSERTIONS_ENABLED", "1");
|
||||
}
|
||||
|
||||
cmd.env_remove("__STD_DEBUG_ASSERTIONS_ENABLED");
|
||||
if self.config.with_std_debug_assertions {
|
||||
// Used for `run_make_support::env::std_debug_assertions_enabled`.
|
||||
cmd.env("__STD_DEBUG_ASSERTIONS_ENABLED", "1");
|
||||
}
|
||||
|
||||
// We don't want RUSTFLAGS set from the outside to interfere with
|
||||
// compiler flags set in the test cases:
|
||||
cmd.env_remove("RUSTFLAGS");
|
||||
|
|
|
|||
|
|
@ -18,11 +18,20 @@ pub fn env_var_os(name: &str) -> OsString {
|
|||
}
|
||||
}
|
||||
|
||||
/// Check if `NO_DEBUG_ASSERTIONS` is set (usually this may be set in CI jobs).
|
||||
/// Check if staged `rustc`-under-test was built with debug assertions.
|
||||
#[track_caller]
|
||||
#[must_use]
|
||||
pub fn no_debug_assertions() -> bool {
|
||||
std::env::var_os("NO_DEBUG_ASSERTIONS").is_some()
|
||||
pub fn rustc_debug_assertions_enabled() -> bool {
|
||||
// Note: we assume this env var is set when the test recipe is being executed.
|
||||
std::env::var_os("__RUSTC_DEBUG_ASSERTIONS_ENABLED").is_some()
|
||||
}
|
||||
|
||||
/// Check if staged `std`-under-test was built with debug assertions.
|
||||
#[track_caller]
|
||||
#[must_use]
|
||||
pub fn std_debug_assertions_enabled() -> bool {
|
||||
// Note: we assume this env var is set when the test recipe is being executed.
|
||||
std::env::var_os("__STD_DEBUG_ASSERTIONS_ENABLED").is_some()
|
||||
}
|
||||
|
||||
/// A wrapper around [`std::env::set_current_dir`] which includes the directory
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue