Skip to content

Commit d75c84a

Browse files
authored
Auto merge of #36604 - japaric:libtest-skip, r=alexcrichton
libtest: add a --skip flag to the test runner This flag takes a FILTER argument and instructs the test runner to skip the tests whose names contain the word FILTER. --skip can be used several times. --- My motivation for submitting this is that while using [smoke] to run `std` unit tests for cross targets I found that a few of the tests always fail due to limitations in QEMU (it can't handle too many threads) and I'd like to skip these problematic tests from the command line to be able to run the rest of the unit tests. [smoke]: https://github.com/japaric/smoke I know there is another mechanism to skip tests: `#[ignore]` but this doesn't work in my use case because I can't (easily) modify the source of the standard libraries to `#[ignore]` some tests. And even if I could, the change would involve conditionally ignoring some tests for some targets but that's not a perfect solution because those tests should pass if executed on real hardware so they should not be `#[ignored]` in that scenario. r? @alexcrichton cc @brson
2 parents 755516b + 45916ec commit d75c84a

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/libtest/lib.rs

+10
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ pub struct TestOpts {
303303
pub color: ColorConfig,
304304
pub quiet: bool,
305305
pub test_threads: Option<usize>,
306+
pub skip: Vec<String>,
306307
}
307308

308309
impl TestOpts {
@@ -318,6 +319,7 @@ impl TestOpts {
318319
color: AutoColor,
319320
quiet: false,
320321
test_threads: None,
322+
skip: vec![],
321323
}
322324
}
323325
}
@@ -337,6 +339,8 @@ fn optgroups() -> Vec<getopts::OptGroup> {
337339
task, allow printing directly"),
338340
getopts::optopt("", "test-threads", "Number of threads used for running tests \
339341
in parallel", "n_threads"),
342+
getopts::optmulti("", "skip", "Skip tests whose names contain FILTER (this flag can \
343+
be used multiple times)","FILTER"),
340344
getopts::optflag("q", "quiet", "Display one character per test instead of one line"),
341345
getopts::optopt("", "color", "Configure coloring of output:
342346
auto = colorize if stdout is a tty and tests are run on serially (default);
@@ -446,6 +450,7 @@ pub fn parse_opts(args: &[String]) -> Option<OptRes> {
446450
color: color,
447451
quiet: quiet,
448452
test_threads: test_threads,
453+
skip: matches.opt_strs("skip"),
449454
};
450455

451456
Some(Ok(test_opts))
@@ -1101,6 +1106,11 @@ pub fn filter_tests(opts: &TestOpts, tests: Vec<TestDescAndFn>) -> Vec<TestDescA
11011106
}
11021107
};
11031108

1109+
// Skip tests that match any of the skip filters
1110+
filtered = filtered.into_iter()
1111+
.filter(|t| !opts.skip.iter().any(|sf| t.desc.name.as_slice().contains(&sf[..])))
1112+
.collect();
1113+
11041114
// Maybe pull out the ignored test and unignore them
11051115
filtered = if !opts.run_ignored {
11061116
filtered

src/tools/compiletest/src/main.rs

+1
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,7 @@ pub fn test_opts(config: &Config) -> test::TestOpts {
313313
},
314314
color: test::AutoColor,
315315
test_threads: None,
316+
skip: vec![],
316317
}
317318
}
318319

0 commit comments

Comments
 (0)