]> git.proxmox.com Git - cargo.git/commitdiff
New test for `cargo rustc --crate-type` with dependency
authorWeihang Lo <me@weihanglo.tw>
Sun, 13 Feb 2022 09:42:12 +0000 (17:42 +0800)
committerWeihang Lo <me@weihanglo.tw>
Sat, 26 Feb 2022 01:44:48 +0000 (09:44 +0800)
tests/testsuite/rustc.rs

index f1e72c0a5c58ff5b9caf9c3e7fd2a4e22e57c96f..57cec8689a1d886043e4ea7d8de285df37d912c4 100644 (file)
@@ -231,6 +231,46 @@ fn build_with_crate_type_for_foo() {
         .run();
 }
 
+#[cargo_test]
+fn build_with_crate_type_for_foo_with_deps() {
+    let p = project()
+        .file(
+            "src/lib.rs",
+            r#"
+            extern crate a;
+            pub fn foo() { a::hello(); }
+            "#,
+        )
+        .file(
+            "Cargo.toml",
+            r#"
+            [package]
+            name = "foo"
+            version = "0.0.1"
+            authors = []
+
+            [dependencies]
+            a = { path = "a" }
+            "#,
+        )
+        .file("a/Cargo.toml", &basic_manifest("a", "0.1.0"))
+        .file("a/src/lib.rs", "pub fn hello() {}")
+        .build();
+
+    p.cargo("rustc -v --crate-type cdylib -Zunstable-options")
+        .masquerade_as_nightly_cargo()
+        .with_stderr(
+            "\
+[COMPILING] a v0.1.0 ([CWD]/a)
+[RUNNING] `rustc --crate-name a a/src/lib.rs [..]--crate-type lib [..]
+[COMPILING] foo v0.0.1 ([CWD])
+[RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type cdylib [..]
+[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
+",
+        )
+        .run();
+}
+
 #[cargo_test]
 fn build_with_crate_types_for_foo() {
     let p = project().file("src/lib.rs", "").build();