pub nocapture: bool,
pub color: ColorConfig,
pub quiet: bool,
+ pub test_threads: Option<usize>,
}
impl TestOpts {
nocapture: false,
color: AutoColor,
quiet: false,
+ test_threads: None,
}
}
}
of stdout", "PATH"),
getopts::optflag("", "nocapture", "don't capture stdout/stderr of each \
task, allow printing directly"),
+ getopts::optopt("", "test-threads", "Number of threads used for running tests \
+ in parallel", "n_threads"),
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);
tests whose names contain the filter are run.
By default, all tests are run in parallel. This can be altered with the
-RUST_TEST_THREADS environment variable when running tests (set it to 1).
+--test-threads flag or the RUST_TEST_THREADS environment variable when running
+tests (set it to 1).
All tests have their standard output and standard error captured by default.
This can be overridden with the --nocapture flag or setting RUST_TEST_NOCAPTURE
};
}
+ let test_threads = match matches.opt_str("test-threads") {
+ Some(n_str) =>
+ match n_str.parse::<usize>() {
+ Ok(n) => Some(n),
+ Err(e) =>
+ return Some(Err(format!("argument for --test-threads must be a number > 0 \
+ (error: {})", e)))
+ },
+ None =>
+ None,
+ };
+
let color = match matches.opt_str("color").as_ref().map(|s| &**s) {
Some("auto") | None => AutoColor,
Some("always") => AlwaysColor,
nocapture: nocapture,
color: color,
quiet: quiet,
+ test_threads: test_threads,
};
Some(Ok(test_opts))
}
});
- // It's tempting to just spawn all the tests at once, but since we have
- // many tests that run in other processes we would be making a big mess.
- let concurrency = get_concurrency();
+ let concurrency = match opts.test_threads {
+ Some(n) => n,
+ None => get_concurrency(),
+ };
let mut remaining = filtered_tests;
remaining.reverse();