Skip to content

Commit 925e774

Browse files
committed
Auto merge of rust-lang#96493 - chbaker0:issue-96342-fix, r=Mark-Simulacrum
Add compiletest and bootstrap "--skip" option forwarded to libtest With this PR, "x.py test --skip SKIP ..." will run the specified test suite, but forward "--skip SKIP" to the test tool. libtest already supports this option. The PR also adds it to compiletest which itself just forwards it to libtest. Adds the functionality requested in rust-lang#96342. This is useful to work around tests broken upstream. rust-lang#96362 (comment) is the specific test issue my project is trying to work around.
2 parents ebb80ec + b2316c1 commit 925e774

File tree

4 files changed

+30
-3
lines changed

4 files changed

+30
-3
lines changed

src/bootstrap/builder/tests.rs

+2
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,7 @@ mod dist {
507507
config.stage = 0;
508508
config.cmd = Subcommand::Test {
509509
paths: vec!["library/std".into()],
510+
skip: vec![],
510511
test_args: vec![],
511512
rustc_args: vec![],
512513
fail_fast: true,
@@ -577,6 +578,7 @@ mod dist {
577578
let mut config = configure(&["A"], &["A"]);
578579
config.cmd = Subcommand::Test {
579580
paths: vec![],
581+
skip: vec![],
580582
test_args: vec![],
581583
rustc_args: vec![],
582584
fail_fast: true,

src/bootstrap/flags.rs

+19-2
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ pub enum Subcommand {
111111
compare_mode: Option<String>,
112112
pass: Option<String>,
113113
run: Option<String>,
114+
skip: Vec<String>,
114115
test_args: Vec<String>,
115116
rustc_args: Vec<String>,
116117
fail_fast: bool,
@@ -261,6 +262,7 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`",
261262
match subcommand {
262263
Kind::Test => {
263264
opts.optflag("", "no-fail-fast", "Run all tests regardless of failure");
265+
opts.optmulti("", "skip", "skips tests matching SUBSTRING, if supported by test tool. May be passed multiple times", "SUBSTRING");
264266
opts.optmulti(
265267
"",
266268
"test-args",
@@ -545,6 +547,7 @@ Arguments:
545547
compare_mode: matches.opt_str("compare-mode"),
546548
pass: matches.opt_str("pass"),
547549
run: matches.opt_str("run"),
550+
skip: matches.opt_strs("skip"),
548551
test_args: matches.opt_strs("test-args"),
549552
rustc_args: matches.opt_strs("rustc-args"),
550553
fail_fast: !matches.opt_present("no-fail-fast"),
@@ -689,12 +692,26 @@ impl Subcommand {
689692
}
690693

691694
pub fn test_args(&self) -> Vec<&str> {
695+
let mut args = vec![];
696+
697+
match *self {
698+
Subcommand::Test { ref skip, .. } => {
699+
for s in skip {
700+
args.push("--skip");
701+
args.push(s.as_str());
702+
}
703+
}
704+
_ => (),
705+
};
706+
692707
match *self {
693708
Subcommand::Test { ref test_args, .. } | Subcommand::Bench { ref test_args, .. } => {
694-
test_args.iter().flat_map(|s| s.split_whitespace()).collect()
709+
args.extend(test_args.iter().flat_map(|s| s.split_whitespace()))
695710
}
696-
_ => Vec::new(),
711+
_ => (),
697712
}
713+
714+
args
698715
}
699716

700717
pub fn rustc_args(&self) -> Vec<&str> {

src/tools/compiletest/src/common.rs

+4
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,10 @@ pub struct Config {
246246
/// Only run tests that match these filters
247247
pub filters: Vec<String>,
248248

249+
/// Skip tests tests matching these substrings. Corresponds to
250+
/// `test::TestOpts::skip`. `filter_exact` does not apply to these flags.
251+
pub skip: Vec<String>,
252+
249253
/// Exactly match the filter, rather than a substring
250254
pub filter_exact: bool,
251255

src/tools/compiletest/src/main.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ pub fn parse_config(args: Vec<String>) -> Config {
9191
)
9292
.optopt("", "run", "whether to execute run-* tests", "auto | always | never")
9393
.optflag("", "ignored", "run tests marked as ignored")
94+
.optmulti("", "skip", "skip tests matching SUBSTRING. Can be passed multiple times", "SUBSTRING")
9495
.optflag("", "exact", "filters match exactly")
9596
.optopt(
9697
"",
@@ -236,6 +237,7 @@ pub fn parse_config(args: Vec<String>) -> Config {
236237
debugger: None,
237238
run_ignored,
238239
filters: matches.free.clone(),
240+
skip: matches.opt_strs("skip"),
239241
filter_exact: matches.opt_present("exact"),
240242
force_pass_mode: matches.opt_str("pass").map(|mode| {
241243
mode.parse::<PassMode>()
@@ -312,6 +314,7 @@ pub fn log_config(config: &Config) {
312314
logv(c, format!("mode: {}", config.mode));
313315
logv(c, format!("run_ignored: {}", config.run_ignored));
314316
logv(c, format!("filters: {:?}", config.filters));
317+
logv(c, format!("skip: {:?}", config.skip));
315318
logv(c, format!("filter_exact: {}", config.filter_exact));
316319
logv(
317320
c,
@@ -506,7 +509,7 @@ pub fn test_opts(config: &Config) -> test::TestOpts {
506509
shuffle: false,
507510
shuffle_seed: None,
508511
test_threads: None,
509-
skip: vec![],
512+
skip: config.skip.clone(),
510513
list: false,
511514
options: test::Options::new(),
512515
time_options: None,
@@ -595,6 +598,7 @@ fn collect_tests_from_dir(
595598
debug!("found test file: {:?}", file_path.display());
596599
let paths =
597600
TestPaths { file: file_path, relative_dir: relative_dir_path.to_path_buf() };
601+
598602
tests.extend(make_test(config, &paths, inputs))
599603
} else if file_path.is_dir() {
600604
let relative_file_path = relative_dir_path.join(file.file_name());

0 commit comments

Comments
 (0)