]> git.proxmox.com Git - cargo.git/commitdiff
Allow multiple arguments in `cargo bench`
authorLukas Lueg <lukas.lueg@gmail.com>
Sat, 30 Sep 2017 14:51:42 +0000 (16:51 +0200)
committerLukas Lueg <lukas.lueg@gmail.com>
Sat, 30 Sep 2017 14:51:42 +0000 (16:51 +0200)
Fixes #4504

src/bin/bench.rs
tests/bench.rs

index e3cacfac301cfa201056abef004815802b705798..cb39fc9ceb54d8e53790bfa600c8820ef3c39b0c 100644 (file)
@@ -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
index 105b4029a42c4dcd94c5a612442a2a9001e16189..a2a2f21a6374fcc66106021bc4ee49eb40ba82b1 100644 (file)
@@ -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 }