Add tests for --all-targets
authorXimin Luo <infinity0@pwned.gg>
Thu, 15 Mar 2018 15:20:15 +0000 (16:20 +0100)
committerXimin Luo <infinity0@pwned.gg>
Thu, 15 Mar 2018 16:08:40 +0000 (17:08 +0100)
tests/testsuite/build.rs
tests/testsuite/check.rs
tests/testsuite/rustc.rs

index 86a1e58c94ca87d58be04998d44fa1d236e7fbba..9025c51d3d8036e9bdcbbf75089db58774decacc 100644 (file)
@@ -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")
index 7499f136d776b86d51ba60f2326af1e6b696c410..7a6b1b331658b4b2110373729768d77888aacef9 100644 (file)
@@ -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]
index dd5de43fa0f5fc5f2a7b29b886919dbe620038f5..582a9ee175c541aa2b8951104271454f4afa4ca2 100644 (file)
@@ -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")