]> git.proxmox.com Git - cargo.git/commitdiff
Allow metadata hash to be computed when checking dylibs
authorMichael Fairley <michaelfairley@gmail.com>
Wed, 29 Nov 2017 03:31:34 +0000 (23:31 -0400)
committerMichael Fairley <michaelfairley@gmail.com>
Wed, 29 Nov 2017 03:32:19 +0000 (23:32 -0400)
src/cargo/ops/cargo_rustc/context.rs
tests/check.rs

index 9e3696787233e08b7f654d35f1f5d714836845bf..44b6cbb9a943804090302ce2e232b7088a9eac2d 100644 (file)
@@ -535,7 +535,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
         // just here for rustbuild. We need a more principled method
         // doing this eventually.
         let __cargo_default_lib_metadata = env::var("__CARGO_DEFAULT_LIB_METADATA");
-        if !unit.profile.test &&
+        if !(unit.profile.test || unit.profile.check) &&
             (unit.target.is_dylib() || unit.target.is_cdylib() ||
                  (unit.target.is_bin() && self.target_triple().starts_with("wasm32-"))) &&
             unit.pkg.package_id().source_id().is_path() &&
index 073ee3186eeb43c606aed802ad9b6c55b11df769..68e1615ecf590a7e5df745996281d7419eba0488 100644 (file)
@@ -1,3 +1,4 @@
+#[macro_use]
 extern crate cargotest;
 extern crate hamcrest;
 extern crate glob;
@@ -298,6 +299,45 @@ fn issue_3419() {
                 execs().with_status(0));
 }
 
+// Check on a dylib should have a different metadata hash than build.
+#[test]
+fn check_dylib() {
+    let p = project("foo")
+        .file("Cargo.toml", r#"
+            [package]
+            name = "foo"
+            version = "0.1.0"
+            authors = []
+
+            [lib]
+            crate-type = ["dylib"]
+
+            [dependencies]
+        "#)
+        .file("src/lib.rs", "")
+        .build();
+
+    let build_output = t!(String::from_utf8(
+        t!(p.cargo("build").arg("-v").exec_with_output())
+            .stderr,
+    ));
+    let build_metadata = build_output
+        .split_whitespace()
+        .find(|arg| arg.starts_with("metadata="))
+        .unwrap();
+
+    let check_output = t!(String::from_utf8(
+        t!(p.cargo("check").arg("-v").exec_with_output())
+            .stderr,
+    ));
+    let check_metadata = check_output
+        .split_whitespace()
+        .find(|arg| arg.starts_with("metadata="))
+        .unwrap();
+
+    assert_ne!(build_metadata, check_metadata);
+}
+
 // test `cargo rustc --profile check`
 #[test]
 fn rustc_check() {