mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-25 11:14:46 +00:00
test(bench): glob support for package selection
This commit is contained in:
parent
f1de239450
commit
a06ec889f4
@ -1458,6 +1458,55 @@ test bar ... bench: [..] ns/iter (+/- [..])",
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn bench_all_exclude_glob() {
|
||||
if !is_nightly() {
|
||||
return;
|
||||
}
|
||||
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
[project]
|
||||
name = "foo"
|
||||
version = "0.1.0"
|
||||
|
||||
[workspace]
|
||||
members = ["bar", "baz"]
|
||||
"#,
|
||||
)
|
||||
.file("src/main.rs", "fn main() {}")
|
||||
.file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0"))
|
||||
.file(
|
||||
"bar/src/lib.rs",
|
||||
r#"
|
||||
#![feature(test)]
|
||||
#[cfg(test)]
|
||||
extern crate test;
|
||||
|
||||
#[bench]
|
||||
pub fn bar(b: &mut test::Bencher) {
|
||||
b.iter(|| {});
|
||||
}
|
||||
"#,
|
||||
)
|
||||
.file("baz/Cargo.toml", &basic_manifest("baz", "0.1.0"))
|
||||
.file(
|
||||
"baz/src/lib.rs",
|
||||
"#[test] pub fn baz() { break_the_build(); }",
|
||||
)
|
||||
.build();
|
||||
|
||||
p.cargo("bench --workspace --exclude '*z'")
|
||||
.with_stdout_contains(
|
||||
"\
|
||||
running 1 test
|
||||
test bar ... bench: [..] ns/iter (+/- [..])",
|
||||
)
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn bench_all_virtual_manifest() {
|
||||
if !is_nightly() {
|
||||
@ -1511,6 +1560,59 @@ fn bench_all_virtual_manifest() {
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn bench_virtual_manifest_glob() {
|
||||
if !is_nightly() {
|
||||
return;
|
||||
}
|
||||
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
[workspace]
|
||||
members = ["bar", "baz"]
|
||||
"#,
|
||||
)
|
||||
.file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0"))
|
||||
.file("bar/src/lib.rs", "pub fn bar() { break_the_build(); }")
|
||||
.file(
|
||||
"bar/benches/bar.rs",
|
||||
r#"
|
||||
#![feature(test)]
|
||||
extern crate test;
|
||||
|
||||
use test::Bencher;
|
||||
|
||||
#[bench]
|
||||
fn bench_bar(_: &mut Bencher) -> () { break_the_build(); }
|
||||
"#,
|
||||
)
|
||||
.file("baz/Cargo.toml", &basic_manifest("baz", "0.1.0"))
|
||||
.file("baz/src/lib.rs", "pub fn baz() {}")
|
||||
.file(
|
||||
"baz/benches/baz.rs",
|
||||
r#"
|
||||
#![feature(test)]
|
||||
extern crate test;
|
||||
|
||||
use test::Bencher;
|
||||
|
||||
#[bench]
|
||||
fn bench_baz(_: &mut Bencher) -> () { () }
|
||||
"#,
|
||||
)
|
||||
.build();
|
||||
|
||||
// The order in which bar and baz are built is not guaranteed
|
||||
p.cargo("bench -p '*z'")
|
||||
.with_stderr_contains("[RUNNING] target/release/deps/baz-[..][EXE]")
|
||||
.with_stdout_contains("test bench_baz ... bench: [..]")
|
||||
.with_stderr_does_not_contain("[RUNNING] target/release/deps/bar-[..][EXE]")
|
||||
.with_stdout_does_not_contain("test bench_bar ... bench: [..]")
|
||||
.run();
|
||||
}
|
||||
|
||||
// https://github.com/rust-lang/cargo/issues/4287
|
||||
#[cargo_test]
|
||||
fn legacy_bench_name() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user