Skip to content

Commit a5abe40

Browse files
authored
Unrolled build for rust-lang#126072
Rollup merge of rust-lang#126072 - Zalathar:run-flags, r=jieyouxu compiletest: Allow multiple `//@ run-flags:` headers While working on some tests, I was annoyed to find that multiple `// `@run-flags:`` headers do not combine with each other (as `//@ compile-flags:` headers do), and instead all but one are silently discarded. This makes it impossible to split long flag lists into multiple lines. Fortunately it's easy to just recycle the existing logic from the other command-line-flags headers.
2 parents 98489f2 + 2692d44 commit a5abe40

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

src/tools/compiletest/src/header.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ pub struct TestProps {
9494
// Extra flags to pass to the compiler
9595
pub compile_flags: Vec<String>,
9696
// Extra flags to pass when the compiled code is run (such as --bench)
97-
pub run_flags: Option<String>,
97+
pub run_flags: Vec<String>,
9898
// If present, the name of a file that this test should match when
9999
// pretty-printed
100100
pub pp_exact: Option<PathBuf>,
@@ -262,7 +262,7 @@ impl TestProps {
262262
error_patterns: vec![],
263263
regex_error_patterns: vec![],
264264
compile_flags: vec![],
265-
run_flags: None,
265+
run_flags: vec![],
266266
pp_exact: None,
267267
aux_builds: vec![],
268268
aux_bins: vec![],
@@ -399,7 +399,9 @@ impl TestProps {
399399

400400
config.parse_and_update_revisions(ln, &mut self.revisions);
401401

402-
config.set_name_value_directive(ln, RUN_FLAGS, &mut self.run_flags, |r| r);
402+
if let Some(flags) = config.parse_name_value_directive(ln, RUN_FLAGS) {
403+
self.run_flags.extend(split_flags(&flags));
404+
}
403405

404406
if self.pp_exact.is_none() {
405407
self.pp_exact = config.parse_pp_exact(ln, testfile);

src/tools/compiletest/src/runtest.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -2355,7 +2355,7 @@ impl<'test> TestCx<'test> {
23552355
args.push(exe_file.into_os_string());
23562356

23572357
// Add the arguments in the run_flags directive
2358-
args.extend(self.split_maybe_args(&self.props.run_flags));
2358+
args.extend(self.props.run_flags.iter().map(OsString::from));
23592359

23602360
let prog = args.remove(0);
23612361
ProcArgs { prog, args }
@@ -4173,10 +4173,12 @@ impl<'test> TestCx<'test> {
41734173
}
41744174

41754175
fn normalize_output(&self, output: &str, custom_rules: &[(String, String)]) -> String {
4176-
let rflags = self.props.run_flags.as_ref();
4176+
// Crude heuristic to detect when the output should have JSON-specific
4177+
// normalization steps applied.
4178+
let rflags = self.props.run_flags.join(" ");
41774179
let cflags = self.props.compile_flags.join(" ");
4178-
let json = rflags
4179-
.map_or(false, |s| s.contains("--format json") || s.contains("--format=json"))
4180+
let json = rflags.contains("--format json")
4181+
|| rflags.contains("--format=json")
41804182
|| cflags.contains("--error-format json")
41814183
|| cflags.contains("--error-format pretty-json")
41824184
|| cflags.contains("--error-format=json")

src/tools/rustdoc-gui-test/src/main.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,7 @@ If you want to install the `browser-ui-test` dependency, run `npm install browse
123123
cargo.env("RUSTDOCFLAGS", test_props.compile_flags.join(" "));
124124
}
125125

126-
if let Some(flags) = &test_props.run_flags {
127-
cargo.arg(flags);
128-
}
126+
cargo.args(&test_props.run_flags);
129127
}
130128

131129
if try_run(&mut cargo, config.verbose).is_err() {

0 commit comments

Comments
 (0)