Rollup merge of #131913 - jieyouxu:only_debug_assertions, r=onur-ozkan
Add `{ignore,needs}-{rustc,std}-debug-assertions` directive support
Add `{ignore,needs}-{rustc,std}-debug-assertions` compiletest directives and retire the old `{ignore,only}-debug` directives. The old `{ignore,only}-debug` directives were ambiguous because you could have std built with debug assertions but rustc not built with debug assertions or vice versa. If we want to support the use case of controlling test run based on if rustc was built with debug assertions, then having `{ignore,only}-debug` will be very confusing.
cc ````@matthiaskrgr````
Closes #123987.
r? bootstrap (or compiler tbh)
This commit is contained in:
commit
93e9ec05a9
22 changed files with 119 additions and 43 deletions
|
|
@ -236,8 +236,11 @@ pub struct Config {
|
|||
/// Run ignored tests
|
||||
pub run_ignored: bool,
|
||||
|
||||
/// Whether to run tests with `ignore-debug` header
|
||||
pub with_debug_assertions: bool,
|
||||
/// Whether rustc was built with debug assertions.
|
||||
pub with_rustc_debug_assertions: bool,
|
||||
|
||||
/// Whether std was built with debug assertions.
|
||||
pub with_std_debug_assertions: bool,
|
||||
|
||||
/// Only run tests that match these filters
|
||||
pub filters: Vec<String>,
|
||||
|
|
|
|||
|
|
@ -46,7 +46,6 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
|
|||
"ignore-coverage-map",
|
||||
"ignore-coverage-run",
|
||||
"ignore-cross-compile",
|
||||
"ignore-debug",
|
||||
"ignore-eabi",
|
||||
"ignore-emscripten",
|
||||
"ignore-endian-big",
|
||||
|
|
@ -82,6 +81,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
|
|||
"ignore-powerpc",
|
||||
"ignore-remote",
|
||||
"ignore-riscv64",
|
||||
"ignore-rustc-debug-assertions",
|
||||
"ignore-s390x",
|
||||
"ignore-sgx",
|
||||
"ignore-sparc64",
|
||||
|
|
@ -89,6 +89,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
|
|||
"ignore-stable",
|
||||
"ignore-stage1",
|
||||
"ignore-stage2",
|
||||
"ignore-std-debug-assertions",
|
||||
"ignore-test",
|
||||
"ignore-thumb",
|
||||
"ignore-thumbv8m.base-none-eabi",
|
||||
|
|
@ -135,6 +136,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
|
|||
"needs-relocation-model-pic",
|
||||
"needs-run-enabled",
|
||||
"needs-rust-lld",
|
||||
"needs-rustc-debug-assertions",
|
||||
"needs-sanitizer-address",
|
||||
"needs-sanitizer-cfi",
|
||||
"needs-sanitizer-dataflow",
|
||||
|
|
@ -147,6 +149,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
|
|||
"needs-sanitizer-shadow-call-stack",
|
||||
"needs-sanitizer-support",
|
||||
"needs-sanitizer-thread",
|
||||
"needs-std-debug-assertions",
|
||||
"needs-symlink",
|
||||
"needs-threads",
|
||||
"needs-unwind",
|
||||
|
|
|
|||
|
|
@ -202,9 +202,14 @@ pub(super) fn parse_cfg_name_directive<'a>(
|
|||
message: "when running tests remotely",
|
||||
}
|
||||
condition! {
|
||||
name: "debug",
|
||||
condition: config.with_debug_assertions,
|
||||
message: "when running tests with `ignore-debug` header",
|
||||
name: "rustc-debug-assertions",
|
||||
condition: config.with_rustc_debug_assertions,
|
||||
message: "when rustc is built with debug assertions",
|
||||
}
|
||||
condition! {
|
||||
name: "std-debug-assertions",
|
||||
condition: config.with_std_debug_assertions,
|
||||
message: "when std is built with debug assertions",
|
||||
}
|
||||
condition! {
|
||||
name: config.debugger.as_ref().map(|d| d.to_str()),
|
||||
|
|
|
|||
|
|
@ -159,6 +159,16 @@ pub(super) fn handle_needs(
|
|||
condition: cache.llvm_zstd,
|
||||
ignore_reason: "ignored if LLVM wasn't build with zstd for ELF section compression",
|
||||
},
|
||||
Need {
|
||||
name: "needs-rustc-debug-assertions",
|
||||
condition: config.with_rustc_debug_assertions,
|
||||
ignore_reason: "ignored if rustc wasn't built with debug assertions",
|
||||
},
|
||||
Need {
|
||||
name: "needs-std-debug-assertions",
|
||||
condition: config.with_std_debug_assertions,
|
||||
ignore_reason: "ignored if std wasn't built with debug assertions",
|
||||
},
|
||||
];
|
||||
|
||||
let (name, comment) = match ln.split_once([':', ' ']) {
|
||||
|
|
|
|||
|
|
@ -74,6 +74,8 @@ struct ConfigBuilder {
|
|||
git_hash: bool,
|
||||
system_llvm: bool,
|
||||
profiler_runtime: bool,
|
||||
rustc_debug_assertions: bool,
|
||||
std_debug_assertions: bool,
|
||||
}
|
||||
|
||||
impl ConfigBuilder {
|
||||
|
|
@ -122,6 +124,16 @@ impl ConfigBuilder {
|
|||
self
|
||||
}
|
||||
|
||||
fn rustc_debug_assertions(&mut self, is_enabled: bool) -> &mut Self {
|
||||
self.rustc_debug_assertions = is_enabled;
|
||||
self
|
||||
}
|
||||
|
||||
fn std_debug_assertions(&mut self, is_enabled: bool) -> &mut Self {
|
||||
self.std_debug_assertions = is_enabled;
|
||||
self
|
||||
}
|
||||
|
||||
fn build(&mut self) -> Config {
|
||||
let args = &[
|
||||
"compiletest",
|
||||
|
|
@ -170,6 +182,12 @@ impl ConfigBuilder {
|
|||
if self.profiler_runtime {
|
||||
args.push("--profiler-runtime".to_owned());
|
||||
}
|
||||
if self.rustc_debug_assertions {
|
||||
args.push("--with-rustc-debug-assertions".to_owned());
|
||||
}
|
||||
if self.std_debug_assertions {
|
||||
args.push("--with-std-debug-assertions".to_owned());
|
||||
}
|
||||
|
||||
args.push("--rustc-path".to_string());
|
||||
// This is a subtle/fragile thing. On rust-lang CI, there is no global
|
||||
|
|
@ -314,6 +332,32 @@ fn only_target() {
|
|||
assert!(!check_ignore(&config, "//@ only-64bit"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rustc_debug_assertions() {
|
||||
let config: Config = cfg().rustc_debug_assertions(false).build();
|
||||
|
||||
assert!(check_ignore(&config, "//@ needs-rustc-debug-assertions"));
|
||||
assert!(!check_ignore(&config, "//@ ignore-rustc-debug-assertions"));
|
||||
|
||||
let config: Config = cfg().rustc_debug_assertions(true).build();
|
||||
|
||||
assert!(!check_ignore(&config, "//@ needs-rustc-debug-assertions"));
|
||||
assert!(check_ignore(&config, "//@ ignore-rustc-debug-assertions"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn std_debug_assertions() {
|
||||
let config: Config = cfg().std_debug_assertions(false).build();
|
||||
|
||||
assert!(check_ignore(&config, "//@ needs-std-debug-assertions"));
|
||||
assert!(!check_ignore(&config, "//@ ignore-std-debug-assertions"));
|
||||
|
||||
let config: Config = cfg().std_debug_assertions(true).build();
|
||||
|
||||
assert!(!check_ignore(&config, "//@ needs-std-debug-assertions"));
|
||||
assert!(check_ignore(&config, "//@ ignore-std-debug-assertions"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn stage() {
|
||||
let config: Config = cfg().stage_id("stage1-x86_64-unknown-linux-gnu").build();
|
||||
|
|
|
|||
|
|
@ -88,7 +88,8 @@ pub fn parse_config(args: Vec<String>) -> Config {
|
|||
.optopt("", "run", "whether to execute run-* tests", "auto | always | never")
|
||||
.optflag("", "ignored", "run tests marked as ignored")
|
||||
.optflag("", "has-enzyme", "run tests that require enzyme")
|
||||
.optflag("", "with-debug-assertions", "whether to run tests with `ignore-debug` header")
|
||||
.optflag("", "with-rustc-debug-assertions", "whether rustc was built with debug assertions")
|
||||
.optflag("", "with-std-debug-assertions", "whether std was built with debug assertions")
|
||||
.optmulti(
|
||||
"",
|
||||
"skip",
|
||||
|
|
@ -235,7 +236,8 @@ pub fn parse_config(args: Vec<String>) -> Config {
|
|||
|
||||
let src_base = opt_path(matches, "src-base");
|
||||
let run_ignored = matches.opt_present("ignored");
|
||||
let with_debug_assertions = matches.opt_present("with-debug-assertions");
|
||||
let with_rustc_debug_assertions = matches.opt_present("with-rustc-debug-assertions");
|
||||
let with_std_debug_assertions = matches.opt_present("with-std-debug-assertions");
|
||||
let mode = matches.opt_str("mode").unwrap().parse().expect("invalid mode");
|
||||
let has_html_tidy = if mode == Mode::Rustdoc {
|
||||
Command::new("tidy")
|
||||
|
|
@ -293,7 +295,8 @@ pub fn parse_config(args: Vec<String>) -> Config {
|
|||
suite: matches.opt_str("suite").unwrap(),
|
||||
debugger: None,
|
||||
run_ignored,
|
||||
with_debug_assertions,
|
||||
with_rustc_debug_assertions,
|
||||
with_std_debug_assertions,
|
||||
filters,
|
||||
skip: matches.opt_strs("skip"),
|
||||
filter_exact: matches.opt_present("exact"),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue