about summary refs log tree commit diff
path: root/src/libtest
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2016-09-28 00:38:07 -0700
committerGitHub <noreply@github.com>2016-09-28 00:38:07 -0700
commitd75c84af806b27137ca3d6cfeba4eb904655a7ad (patch)
tree89256a1cd64ae4e3ec954a3ccc44afd3eb950b56 /src/libtest
parent755516bb96cc0f74c3098d2a64917f4e0a6f3f03 (diff)
parent45916ec6864e166b23148caee4081bbeac2d992e (diff)
downloadrust-d75c84af806b27137ca3d6cfeba4eb904655a7ad.tar.gz
rust-d75c84af806b27137ca3d6cfeba4eb904655a7ad.zip
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
Diffstat (limited to 'src/libtest')
-rw-r--r--src/libtest/lib.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs
index 13d57f784e7..dcfd3f754c7 100644
--- a/src/libtest/lib.rs
+++ b/src/libtest/lib.rs
@@ -303,6 +303,7 @@ pub struct TestOpts {
     pub color: ColorConfig,
     pub quiet: bool,
     pub test_threads: Option<usize>,
+    pub skip: Vec<String>,
 }
 
 impl TestOpts {
@@ -318,6 +319,7 @@ impl TestOpts {
             color: AutoColor,
             quiet: false,
             test_threads: None,
+            skip: vec![],
         }
     }
 }
@@ -337,6 +339,8 @@ fn optgroups() -> Vec<getopts::OptGroup> {
                                          task, allow printing directly"),
       getopts::optopt("", "test-threads", "Number of threads used for running tests \
                                            in parallel", "n_threads"),
+      getopts::optmulti("", "skip", "Skip tests whose names contain FILTER (this flag can \
+                                     be used multiple times)","FILTER"),
       getopts::optflag("q", "quiet", "Display one character per test instead of one line"),
       getopts::optopt("", "color", "Configure coloring of output:
             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> {
         color: color,
         quiet: quiet,
         test_threads: test_threads,
+        skip: matches.opt_strs("skip"),
     };
 
     Some(Ok(test_opts))
@@ -1101,6 +1106,11 @@ pub fn filter_tests(opts: &TestOpts, tests: Vec<TestDescAndFn>) -> Vec<TestDescA
         }
     };
 
+    // Skip tests that match any of the skip filters
+    filtered = filtered.into_iter()
+        .filter(|t| !opts.skip.iter().any(|sf| t.desc.name.as_slice().contains(&sf[..])))
+        .collect();
+
     // Maybe pull out the ignored test and unignore them
     filtered = if !opts.run_ignored {
         filtered