mirror of
https://github.com/rust-lang/cargo.git
synced 2025-10-01 11:30:39 +00:00
test(test): glob support for package selection
This commit is contained in:
parent
8d5e11a520
commit
6fb6b94a33
@ -2833,6 +2833,103 @@ test bar ... ok",
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn test_all_exclude_not_found() {
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
[project]
|
||||
name = "foo"
|
||||
version = "0.1.0"
|
||||
|
||||
[workspace]
|
||||
members = ["bar"]
|
||||
"#,
|
||||
)
|
||||
.file("src/main.rs", "fn main() {}")
|
||||
.file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0"))
|
||||
.file("bar/src/lib.rs", "#[test] pub fn bar() {}")
|
||||
.build();
|
||||
|
||||
p.cargo("test --workspace --exclude baz")
|
||||
.with_stderr_contains("[WARNING] excluded package(s) baz not found in workspace [..]")
|
||||
.with_stdout_contains(
|
||||
"running 1 test
|
||||
test bar ... ok",
|
||||
)
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn test_all_exclude_glob() {
|
||||
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", "#[test] pub fn bar() {}")
|
||||
.file("baz/Cargo.toml", &basic_manifest("baz", "0.1.0"))
|
||||
.file("baz/src/lib.rs", "#[test] pub fn baz() { assert!(false); }")
|
||||
.build();
|
||||
|
||||
p.cargo("test --workspace --exclude '*z'")
|
||||
.with_stdout_contains(
|
||||
"running 1 test
|
||||
test bar ... ok",
|
||||
)
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn test_all_exclude_glob_not_found() {
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
[project]
|
||||
name = "foo"
|
||||
version = "0.1.0"
|
||||
|
||||
[workspace]
|
||||
members = ["bar"]
|
||||
"#,
|
||||
)
|
||||
.file("src/main.rs", "fn main() {}")
|
||||
.file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0"))
|
||||
.file("bar/src/lib.rs", "#[test] pub fn bar() {}")
|
||||
.build();
|
||||
|
||||
p.cargo("test --workspace --exclude '*z'")
|
||||
.with_stderr_contains(
|
||||
"[WARNING] excluded package pattern(s) *z not found in workspace [..]",
|
||||
)
|
||||
.with_stdout_contains(
|
||||
"running 1 test
|
||||
test bar ... ok",
|
||||
)
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn test_all_exclude_broken_glob() {
|
||||
let p = project().file("src/main.rs", "fn main() {}").build();
|
||||
|
||||
p.cargo("test --workspace --exclude '[*z'")
|
||||
.with_status(101)
|
||||
.with_stderr_contains("[ERROR] Cannot build glob pattern from `[*z`")
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn test_all_virtual_manifest() {
|
||||
let p = project()
|
||||
@ -2850,8 +2947,8 @@ fn test_all_virtual_manifest() {
|
||||
.build();
|
||||
|
||||
p.cargo("test --workspace")
|
||||
.with_stdout_contains("test a ... ok")
|
||||
.with_stdout_contains("test b ... ok")
|
||||
.with_stdout_contains("running 1 test\ntest a ... ok")
|
||||
.with_stdout_contains("running 1 test\ntest b ... ok")
|
||||
.run();
|
||||
}
|
||||
|
||||
@ -2872,8 +2969,93 @@ fn test_virtual_manifest_all_implied() {
|
||||
.build();
|
||||
|
||||
p.cargo("test")
|
||||
.with_stdout_contains("test a ... ok")
|
||||
.with_stdout_contains("test b ... ok")
|
||||
.with_stdout_contains("running 1 test\ntest a ... ok")
|
||||
.with_stdout_contains("running 1 test\ntest b ... ok")
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn test_virtual_manifest_one_project() {
|
||||
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", "#[test] fn bar() {}")
|
||||
.file("baz/Cargo.toml", &basic_manifest("baz", "0.1.0"))
|
||||
.file("baz/src/lib.rs", "#[test] fn baz() { assert!(false); }")
|
||||
.build();
|
||||
|
||||
p.cargo("test -p bar")
|
||||
.with_stdout_contains("running 1 test\ntest bar ... ok")
|
||||
.with_stdout_does_not_contain("running 1 test\ntest baz ... ok")
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn test_virtual_manifest_glob() {
|
||||
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", "#[test] fn bar() { assert!(false); }")
|
||||
.file("baz/Cargo.toml", &basic_manifest("baz", "0.1.0"))
|
||||
.file("baz/src/lib.rs", "#[test] fn baz() {}")
|
||||
.build();
|
||||
|
||||
p.cargo("test -p '*z'")
|
||||
.with_stdout_does_not_contain("running 1 test\ntest bar ... ok")
|
||||
.with_stdout_contains("running 1 test\ntest baz ... ok")
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn test_virtual_manifest_glob_not_found() {
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
[workspace]
|
||||
members = ["bar"]
|
||||
"#,
|
||||
)
|
||||
.file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0"))
|
||||
.file("bar/src/lib.rs", "#[test] fn bar() {}")
|
||||
.build();
|
||||
|
||||
p.cargo("test -p bar -p '*z'")
|
||||
.with_stderr_contains("[WARNING] package pattern(s) *z not found in workspace [..]")
|
||||
.with_stdout_contains("running 1 test\ntest bar ... ok")
|
||||
.with_stdout_does_not_contain("running 1 test\ntest baz ... ok")
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn test_virtual_manifest_broken_glob() {
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
[workspace]
|
||||
members = ["bar"]
|
||||
"#,
|
||||
)
|
||||
.file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0"))
|
||||
.file("bar/src/lib.rs", "#[test] fn bar() {}")
|
||||
.build();
|
||||
|
||||
p.cargo("test -p '[*z'")
|
||||
.with_status(101)
|
||||
.with_stderr_contains("[ERROR] Cannot build glob pattern from `[*z`")
|
||||
.run();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user