Skip to content

Commit 3c8bf0b

Browse files
committed
Add {ignore,needs}-debug-assertions-{rustc,std} directive support
And retire the old `only-debug` directive which was ambiguous and only for std debug assertions.
1 parent e92993d commit 3c8bf0b

File tree

6 files changed

+39
-11
lines changed

6 files changed

+39
-11
lines changed

src/bootstrap/src/core/build_steps/test.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1928,9 +1928,13 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
19281928

19291929
cmd.arg("--json");
19301930

1931+
if builder.config.rust_debug_assertions {
1932+
cmd.arg("--with-debug-assertions-rustc");
1933+
}
1934+
19311935
if builder.config.rust_debug_assertions_std {
1932-
cmd.arg("--with-debug-assertions");
1933-
};
1936+
cmd.arg("--with-debug-assertions-std");
1937+
}
19341938

19351939
let mut llvm_components_passed = false;
19361940
let mut copts_passed = false;

src/tools/compiletest/src/command-list.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
4545
"ignore-coverage-map",
4646
"ignore-coverage-run",
4747
"ignore-cross-compile",
48-
"ignore-debug",
48+
"ignore-debug-assertions-rustc",
49+
"ignore-debug-assertions-std",
4950
"ignore-eabi",
5051
"ignore-emscripten",
5152
"ignore-endian-big",
@@ -122,6 +123,8 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
122123
"min-llvm-version",
123124
"min-system-llvm-version",
124125
"needs-asm-support",
126+
"needs-debug-assertions-rustc",
127+
"needs-debug-assertions-std",
125128
"needs-deterministic-layouts",
126129
"needs-dlltool",
127130
"needs-dynamic-linking",

src/tools/compiletest/src/common.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,11 @@ pub struct Config {
235235
/// Run ignored tests
236236
pub run_ignored: bool,
237237

238-
/// Whether to run tests with `ignore-debug` header
239-
pub with_debug_assertions: bool,
238+
/// Whether rustc was built with debug assertions.
239+
pub with_debug_assertions_rustc: bool,
240+
241+
/// Whether std was built with debug assertions.
242+
pub with_debug_assertions_std: bool,
240243

241244
/// Only run tests that match these filters
242245
pub filters: Vec<String>,

src/tools/compiletest/src/header/cfg.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,14 @@ pub(super) fn parse_cfg_name_directive<'a>(
202202
message: "when running tests remotely",
203203
}
204204
condition! {
205-
name: "debug",
206-
condition: config.with_debug_assertions,
207-
message: "when running tests with `ignore-debug` header",
205+
name: "debug-assertions-rustc",
206+
condition: config.with_debug_assertions_rustc,
207+
message: "when rustc is built with debug assertions",
208+
}
209+
condition! {
210+
name: "debug-assertions-std",
211+
condition: config.with_debug_assertions_std,
212+
message: "when std is built with debug assertions",
208213
}
209214
condition! {
210215
name: config.debugger.as_ref().map(|d| d.to_str()),

src/tools/compiletest/src/header/needs.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,16 @@ pub(super) fn handle_needs(
159159
condition: cache.llvm_zstd,
160160
ignore_reason: "ignored if LLVM wasn't build with zstd for ELF section compression",
161161
},
162+
Need {
163+
name: "needs-debug-assertions-rustc",
164+
condition: config.with_debug_assertions_rustc,
165+
ignore_reason: "ignored if rustc wasn't built with debug assertions",
166+
},
167+
Need {
168+
name: "needs-debug-assertions-std",
169+
condition: config.with_debug_assertions_std,
170+
ignore_reason: "ignored if std wasn't built with debug assertions",
171+
},
162172
];
163173

164174
let (name, comment) = match ln.split_once([':', ' ']) {

src/tools/compiletest/src/lib.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ pub fn parse_config(args: Vec<String>) -> Config {
8888
.optopt("", "run", "whether to execute run-* tests", "auto | always | never")
8989
.optflag("", "ignored", "run tests marked as ignored")
9090
.optflag("", "has-enzyme", "run tests that require enzyme")
91-
.optflag("", "with-debug-assertions", "whether to run tests with `ignore-debug` header")
91+
.optflag("", "with-debug-assertions-rustc", "whether rustc was built with debug assertions")
92+
.optflag("", "with-debug-assertions-std", "whether std was built with debug assertions")
9293
.optmulti(
9394
"",
9495
"skip",
@@ -228,7 +229,8 @@ pub fn parse_config(args: Vec<String>) -> Config {
228229

229230
let src_base = opt_path(matches, "src-base");
230231
let run_ignored = matches.opt_present("ignored");
231-
let with_debug_assertions = matches.opt_present("with-debug-assertions");
232+
let with_debug_assertions_rustc = matches.opt_present("with-debug-assertions-rustc");
233+
let with_debug_assertions_std = matches.opt_present("with-debug-assertions-std");
232234
let mode = matches.opt_str("mode").unwrap().parse().expect("invalid mode");
233235
let has_tidy = if mode == Mode::Rustdoc {
234236
Command::new("tidy")
@@ -286,7 +288,8 @@ pub fn parse_config(args: Vec<String>) -> Config {
286288
suite: matches.opt_str("suite").unwrap(),
287289
debugger: None,
288290
run_ignored,
289-
with_debug_assertions,
291+
with_debug_assertions_rustc,
292+
with_debug_assertions_std,
290293
filters,
291294
skip: matches.opt_strs("skip"),
292295
filter_exact: matches.opt_present("exact"),

0 commit comments

Comments
 (0)