mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +00:00
Add tests for --all-targets
This commit is contained in:
parent
89d5161d8e
commit
0bf8e541db
@ -5336,6 +5336,55 @@ fn build_filter_infer_profile() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn all_targets_with_and_without() {
|
||||
let p = project("foo")
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "0.1.0"
|
||||
authors = []
|
||||
"#,
|
||||
)
|
||||
.file("src/main.rs", "fn main() {}")
|
||||
.build();
|
||||
assert_that(
|
||||
p.cargo("build").arg("-v").arg("--all-targets"),
|
||||
execs().with_status(0)
|
||||
// bin
|
||||
.with_stderr_contains("\
|
||||
[RUNNING] `rustc --crate-name foo src[/]main.rs --crate-type bin \
|
||||
--emit=dep-info,link[..]")
|
||||
// bench
|
||||
.with_stderr_contains("\
|
||||
[RUNNING] `rustc --crate-name foo src[/]main.rs --emit=dep-info,link \
|
||||
-C opt-level=3 --test [..]")
|
||||
// unit test
|
||||
.with_stderr_contains("\
|
||||
[RUNNING] `rustc --crate-name foo src[/]main.rs --emit=dep-info,link \
|
||||
-C debuginfo=2 --test [..]"),
|
||||
);
|
||||
assert_that(p.cargo("clean"), execs().with_status(0));
|
||||
assert_that(
|
||||
p.cargo("build").arg("-v"),
|
||||
execs().with_status(0)
|
||||
// bin
|
||||
.with_stderr_contains("\
|
||||
[RUNNING] `rustc --crate-name foo src[/]main.rs --crate-type bin \
|
||||
--emit=dep-info,link[..]")
|
||||
// bench
|
||||
.with_stderr_does_not_contain("\
|
||||
[RUNNING] `rustc --crate-name foo src[/]main.rs --emit=dep-info,link \
|
||||
-C opt-level=3 --test [..]")
|
||||
// unit test
|
||||
.with_stderr_does_not_contain("\
|
||||
[RUNNING] `rustc --crate-name foo src[/]main.rs --emit=dep-info,link \
|
||||
-C debuginfo=2 --test [..]"),
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn all_targets_no_lib() {
|
||||
let p = project("foo")
|
||||
|
@ -606,7 +606,7 @@ fn check_virtual_all_implied() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn check_all_targets() {
|
||||
fn all_targets_with_and_without() {
|
||||
let foo = project("foo")
|
||||
.file("Cargo.toml", SIMPLE_MANIFEST)
|
||||
.file("src/main.rs", "fn main() {}")
|
||||
@ -626,6 +626,17 @@ fn check_all_targets() {
|
||||
.with_stderr_contains("[..] --crate-name test2 tests[/]test2.rs [..]")
|
||||
.with_stderr_contains("[..] --crate-name bench3 benches[/]bench3.rs [..]"),
|
||||
);
|
||||
assert_that(foo.cargo("clean"), execs().with_status(0));
|
||||
assert_that(
|
||||
foo.cargo("check").arg("-v"),
|
||||
execs()
|
||||
.with_status(0)
|
||||
.with_stderr_contains("[..] --crate-name foo src[/]lib.rs [..]")
|
||||
.with_stderr_contains("[..] --crate-name foo src[/]main.rs [..]")
|
||||
.with_stderr_does_not_contain("[..] --crate-name example1 examples[/]example1.rs [..]")
|
||||
.with_stderr_does_not_contain("[..] --crate-name test2 tests[/]test2.rs [..]")
|
||||
.with_stderr_does_not_contain("[..] --crate-name bench3 benches[/]bench3.rs [..]"),
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -437,6 +437,55 @@ fn build_only_bar_dependency() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn all_targets_with_and_without() {
|
||||
let p = project("foo")
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "0.1.0"
|
||||
authors = []
|
||||
"#,
|
||||
)
|
||||
.file("src/main.rs", "fn main() {}")
|
||||
.build();
|
||||
assert_that(
|
||||
p.cargo("rustc").arg("-v").arg("--all-targets"),
|
||||
execs().with_status(0)
|
||||
// bin
|
||||
.with_stderr_contains("\
|
||||
[RUNNING] `rustc --crate-name foo src[/]main.rs --crate-type bin \
|
||||
--emit=dep-info,link[..]")
|
||||
// bench
|
||||
.with_stderr_contains("\
|
||||
[RUNNING] `rustc --crate-name foo src[/]main.rs --emit=dep-info,link \
|
||||
-C opt-level=3 --test [..]")
|
||||
// unit test
|
||||
.with_stderr_contains("\
|
||||
[RUNNING] `rustc --crate-name foo src[/]main.rs --emit=dep-info,link \
|
||||
-C debuginfo=2 --test [..]"),
|
||||
);
|
||||
assert_that(p.cargo("clean"), execs().with_status(0));
|
||||
assert_that(
|
||||
p.cargo("rustc").arg("-v"),
|
||||
execs().with_status(0)
|
||||
// bin
|
||||
.with_stderr_contains("\
|
||||
[RUNNING] `rustc --crate-name foo src[/]main.rs --crate-type bin \
|
||||
--emit=dep-info,link[..]")
|
||||
// bench
|
||||
.with_stderr_does_not_contain("\
|
||||
[RUNNING] `rustc --crate-name foo src[/]main.rs --emit=dep-info,link \
|
||||
-C opt-level=3 --test [..]")
|
||||
// unit test
|
||||
.with_stderr_does_not_contain("\
|
||||
[RUNNING] `rustc --crate-name foo src[/]main.rs --emit=dep-info,link \
|
||||
-C debuginfo=2 --test [..]"),
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn fail_with_multiple_packages() {
|
||||
let foo = project("foo")
|
||||
|
Loading…
x
Reference in New Issue
Block a user