From b2316c1a88b09dfebe7cabf889af9ceab8fef5f9 Mon Sep 17 00:00:00 2001 From: Collin Baker Date: Wed, 27 Apr 2022 17:11:14 -0400 Subject: Add test skip support libtest already supports a "--skip SUBSTRING" arg which excludes any test names matching SUBSTRING. This adds a "--skip" argument to compiletest and bootstrap which is forwarded to libtest. --- src/bootstrap/builder/tests.rs | 2 ++ src/bootstrap/flags.rs | 21 +++++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) (limited to 'src/bootstrap') diff --git a/src/bootstrap/builder/tests.rs b/src/bootstrap/builder/tests.rs index 3b6cd7564f0..b3ccba2e48d 100644 --- a/src/bootstrap/builder/tests.rs +++ b/src/bootstrap/builder/tests.rs @@ -495,6 +495,7 @@ mod dist { config.stage = 0; config.cmd = Subcommand::Test { paths: vec!["library/std".into()], + skip: vec![], test_args: vec![], rustc_args: vec![], fail_fast: true, @@ -565,6 +566,7 @@ mod dist { let mut config = configure(&["A"], &["A"]); config.cmd = Subcommand::Test { paths: vec![], + skip: vec![], test_args: vec![], rustc_args: vec![], fail_fast: true, diff --git a/src/bootstrap/flags.rs b/src/bootstrap/flags.rs index 58571ea129c..4cd835ade64 100644 --- a/src/bootstrap/flags.rs +++ b/src/bootstrap/flags.rs @@ -111,6 +111,7 @@ pub enum Subcommand { compare_mode: Option, pass: Option, run: Option, + skip: Vec, test_args: Vec, rustc_args: Vec, fail_fast: bool, @@ -261,6 +262,7 @@ To learn more about a subcommand, run `./x.py -h`", match subcommand { Kind::Test => { opts.optflag("", "no-fail-fast", "Run all tests regardless of failure"); + opts.optmulti("", "skip", "skips tests matching SUBSTRING, if supported by test tool. May be passed multiple times", "SUBSTRING"); opts.optmulti( "", "test-args", @@ -545,6 +547,7 @@ Arguments: compare_mode: matches.opt_str("compare-mode"), pass: matches.opt_str("pass"), run: matches.opt_str("run"), + skip: matches.opt_strs("skip"), test_args: matches.opt_strs("test-args"), rustc_args: matches.opt_strs("rustc-args"), fail_fast: !matches.opt_present("no-fail-fast"), @@ -689,12 +692,26 @@ impl Subcommand { } pub fn test_args(&self) -> Vec<&str> { + let mut args = vec![]; + + match *self { + Subcommand::Test { ref skip, .. } => { + for s in skip { + args.push("--skip"); + args.push(s.as_str()); + } + } + _ => (), + }; + match *self { Subcommand::Test { ref test_args, .. } | Subcommand::Bench { ref test_args, .. } => { - test_args.iter().flat_map(|s| s.split_whitespace()).collect() + args.extend(test_args.iter().flat_map(|s| s.split_whitespace())) } - _ => Vec::new(), + _ => (), } + + args } pub fn rustc_args(&self) -> Vec<&str> { -- cgit 1.4.1-3-g733a5