Skip to content

Commit

Permalink
Allow multiple arguments in cargo bench
Browse files Browse the repository at this point in the history
Fixes #4504
  • Loading branch information
lukaslueg committed Sep 30, 2017
1 parent a888e11 commit df882fa
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/bin/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ Usage:
Options:
-h, --help Print this message
--lib Benchmark only this package's library
--bin NAME Benchmark only the specified binary
--bin NAME ... Benchmark only the specified binary
--bins Benchmark all binaries
--example NAME Benchmark only the specified example
--example NAME ... Benchmark only the specified example
--examples Benchmark all examples
--test NAME Benchmark only the specified test target
--test NAME ... Benchmark only the specified test target
--tests Benchmark all tests
--bench NAME Benchmark only the specified bench target
--bench NAME ... Benchmark only the specified bench target
--benches Benchmark all benches
--all-targets Benchmark all targets (default)
--no-run Compile, but don't run benchmarks
Expand Down
34 changes: 34 additions & 0 deletions tests/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,40 @@ fn bench_tarname() {
.with_stdout_contains("test run2 ... bench: [..]"));
}

#[test]
fn bench_multiple_targets() {
if !is_nightly() { return }

let prj = project("foo")
.file("Cargo.toml" , r#"
[package]
name = "foo"
version = "0.0.1"
authors = []
"#)
.file("benches/bin1.rs", r#"
#![feature(test)]
extern crate test;
#[bench] fn run1(_ben: &mut test::Bencher) { }"#)
.file("benches/bin2.rs", r#"
#![feature(test)]
extern crate test;
#[bench] fn run2(_ben: &mut test::Bencher) { }"#)
.file("benches/bin3.rs", r#"
#![feature(test)]
extern crate test;
#[bench] fn run3(_ben: &mut test::Bencher) { }"#);

assert_that(prj.cargo_process("bench")
.arg("--bench").arg("bin1")
.arg("--bench").arg("bin2"),
execs()
.with_status(0)
.with_stdout_contains("test run1 ... bench: [..]")
.with_stdout_contains("test run2 ... bench: [..]")
.with_stdout_does_not_contain("run3"));
}

#[test]
fn cargo_bench_verbose() {
if !is_nightly() { return }
Expand Down

0 comments on commit df882fa

Please sign in to comment.