Rollup merge of #81356 - ehuss:libtest-filters, r=m-ou-se

libtest: allow multiple filters

Libtest ignores any filters after the first. This changes it so that if multiple filters are passed, it will test against all of them.

This also affects compiletest to do the same.

Closes #30422
This commit is contained in:
Mara Bos 2021-02-08 19:28:13 +01:00 committed by GitHub
commit b102ea479d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 65 additions and 29 deletions

View file

@ -0,0 +1,17 @@
// run-pass
// compile-flags: --test
// run-flags: --test-threads=1 test1 test2
// check-run-results
// normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME"
// ignore-emscripten no threads support
#[test]
fn test1() {}
#[test]
fn test2() {}
#[test]
fn test3() {
panic!("this should not run");
}

View file

@ -0,0 +1,7 @@
running 2 tests
test test1 ... ok
test test2 ... ok
test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 1 filtered out; finished in $TIME

View file

@ -240,8 +240,8 @@ pub struct Config {
/// Run ignored tests
pub run_ignored: bool,
/// Only run tests that match this filter
pub filter: Option<String>,
/// Only run tests that match these filters
pub filters: Vec<String>,
/// Exactly match the filter, rather than a substring
pub filter_exact: bool,

View file

@ -221,7 +221,7 @@ pub fn parse_config(args: Vec<String>) -> Config {
suite: matches.opt_str("suite").unwrap(),
debugger: None,
run_ignored,
filter: matches.free.first().cloned(),
filters: matches.free.clone(),
filter_exact: matches.opt_present("exact"),
force_pass_mode: matches.opt_str("pass").map(|mode| {
mode.parse::<PassMode>()
@ -280,7 +280,7 @@ pub fn log_config(config: &Config) {
logv(c, format!("stage_id: {}", config.stage_id));
logv(c, format!("mode: {}", config.mode));
logv(c, format!("run_ignored: {}", config.run_ignored));
logv(c, format!("filter: {}", opt_str(&config.filter)));
logv(c, format!("filters: {:?}", config.filters));
logv(c, format!("filter_exact: {}", config.filter_exact));
logv(
c,
@ -465,7 +465,7 @@ fn configure_lldb(config: &Config) -> Option<Config> {
pub fn test_opts(config: &Config) -> test::TestOpts {
test::TestOpts {
exclude_should_panic: false,
filter: config.filter.clone(),
filters: config.filters.clone(),
filter_exact: config.filter_exact,
run_ignored: if config.run_ignored { test::RunIgnored::Yes } else { test::RunIgnored::No },
format: if config.quiet { test::OutputFormat::Terse } else { test::OutputFormat::Pretty },