From 63e5c176eba7d6bd8167719c9f1625f4f9c34c20 Mon Sep 17 00:00:00 2001 From: Evgen Druzhynin Date: Tue, 4 Jul 2017 19:48:28 +0300 Subject: [PATCH] bench command supports --no-fail-fast flag. --- src/bin/bench.rs | 4 +++- tests/bench.rs | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/src/bin/bench.rs b/src/bin/bench.rs index 9e34f784725..ff1e0b4e7ba 100644 --- a/src/bin/bench.rs +++ b/src/bin/bench.rs @@ -26,6 +26,7 @@ pub struct Options { flag_tests: bool, flag_bench: Vec, flag_benches: bool, + flag_no_fail_fast: bool, flag_frozen: bool, flag_locked: bool, arg_args: Vec, @@ -64,6 +65,7 @@ Options: -q, --quiet No output printed to stdout --color WHEN Coloring: auto, always, never --message-format FMT Error format: human, json [default: human] + --no-fail-fast Run all benchmarks regardless of failure --frozen Require Cargo.lock and cache are up to date --locked Require Cargo.lock is up to date @@ -99,7 +101,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult { options.flag_locked)?; let ops = ops::TestOptions { no_run: options.flag_no_run, - no_fail_fast: false, + no_fail_fast: options.flag_no_fail_fast, only_doc: false, compile_opts: ops::CompileOptions { config: config, diff --git a/tests/bench.rs b/tests/bench.rs index 6a49632ee14..b9adbf46693 100644 --- a/tests/bench.rs +++ b/tests/bench.rs @@ -879,6 +879,44 @@ fn test_bench_no_run() { ")); } +#[test] +fn test_bench_no_fail_fast() { + if !is_nightly() { return } + + let p = project("foo") + .file("Cargo.toml", &basic_bin_manifest("foo")) + .file("src/foo.rs", r#" + #![feature(test)] + extern crate test; + fn hello() -> &'static str { + "hello" + } + + pub fn main() { + println!("{}", hello()) + } + + #[bench] + fn bench_hello(_b: &mut test::Bencher) { + assert_eq!(hello(), "hello") + } + + #[bench] + fn bench_nope(_b: &mut test::Bencher) { + assert_eq!("nope", hello()) + }"#); + + assert_that(p.cargo_process("bench").arg("--no-fail-fast"), + execs().with_status(101) + .with_stderr_contains("\ +[RUNNING] target[/]release[/]deps[/]foo-[..][EXE]") + .with_stdout_contains("running 2 tests") + .with_stderr_contains("\ +[RUNNING] target[/]release[/]deps[/]foo-[..][EXE]") + .with_stdout_contains("test bench_hello [..]") + .with_stdout_contains("test bench_nope [..]")); +} + #[test] fn test_bench_multiple_packages() { if !is_nightly() { return }