diff --git a/tests/testsuite/build.rs b/tests/testsuite/build.rs index 86a1e58c94c..9025c51d3d8 100644 --- a/tests/testsuite/build.rs +++ b/tests/testsuite/build.rs @@ -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") diff --git a/tests/testsuite/check.rs b/tests/testsuite/check.rs index 7499f136d77..7a6b1b33165 100644 --- a/tests/testsuite/check.rs +++ b/tests/testsuite/check.rs @@ -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] diff --git a/tests/testsuite/rustc.rs b/tests/testsuite/rustc.rs index dd5de43fa0f..582a9ee175c 100644 --- a/tests/testsuite/rustc.rs +++ b/tests/testsuite/rustc.rs @@ -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")