Add a regression test for the issue being fixed
authorAlex Crichton <alex@alexcrichton.com>
Tue, 1 Mar 2016 16:25:22 +0000 (08:25 -0800)
committerAlex Crichton <alex@alexcrichton.com>
Fri, 4 Mar 2016 00:55:56 +0000 (16:55 -0800)
When compiling a package from two separate locations it should be cached the
same way both times.

src/cargo/ops/cargo_read_manifest.rs
tests/test_cargo_bench.rs
tests/test_cargo_compile_path_deps.rs
tests/test_cargo_freshness.rs
tests/test_cargo_install.rs

index 20a672e28675c8a2c250c874c229658bc6d8cb90..ddaace3421fa35c876bcdce3d70efbc994d7c49e 100644 (file)
@@ -1,6 +1,5 @@
 use std::collections::{HashMap, HashSet};
 use std::fs;
-use std::io::prelude::*;
 use std::io;
 use std::path::{Path, PathBuf};
 
index 0e16211c52ec2079d2f83682c17a4b5c580966ec..c98035d5c8056ea4726569b87dfb8cbc3c8e5149 100644 (file)
@@ -299,7 +299,7 @@ test!(bench_with_deep_lib_dep {
     assert_that(p.cargo_process("bench"),
                 execs().with_status(0)
                        .with_stdout(&format!("\
-{compiling} foo v0.0.1 ({dir})
+{compiling} foo v0.0.1 ([..])
 {compiling} bar v0.0.1 ({dir})
 {running} target[..]
 
@@ -705,7 +705,7 @@ test!(bench_dylib {
     assert_that(p.cargo_process("bench").arg("-v"),
                 execs().with_status(0)
                        .with_stdout(&format!("\
-{compiling} bar v0.0.1 ({dir})
+{compiling} bar v0.0.1 ({dir}/bar)
 {running} [..] -C opt-level=3 [..]
 {compiling} foo v0.0.1 ({dir})
 {running} [..] -C opt-level=3 [..]
@@ -732,7 +732,7 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
     assert_that(p.cargo("bench").arg("-v"),
                 execs().with_status(0)
                        .with_stdout(&format!("\
-{fresh} bar v0.0.1 ({dir})
+{fresh} bar v0.0.1 ({dir}/bar)
 {fresh} foo v0.0.1 ({dir})
 {running} [..]target[..]release[..]bench-[..]
 
index 9eaaac0a81dcb42f652756bd9ce0d193c77e0456..5cd97d301fdbaace8835ea22628511176591130b 100644 (file)
@@ -517,7 +517,7 @@ Caused by:
   failed to read `[..]bar[..]Cargo.toml`
 
 Caused by:
-  No such file or directory ([..])
+  [..] (os error [..])
 "));
 
 });
index 152190cf045ca5a1e2a2427a82ee100faba6e09f..dc1a402df6d40c7db0d6b25820842b1db8ddb390 100644 (file)
@@ -288,3 +288,67 @@ test!(rerun_if_changed_in_dep {
     assert_that(p.cargo("build"),
                 execs().with_status(0).with_stdout(""));
 });
+
+test!(same_build_dir_cached_packages {
+    let p = project("foo")
+        .file("a1/Cargo.toml", r#"
+            [package]
+            name = "a1"
+            version = "0.0.1"
+            authors = []
+            [dependencies]
+            b = { path = "../b" }
+        "#)
+        .file("a1/src/lib.rs", "")
+        .file("a2/Cargo.toml", r#"
+            [package]
+            name = "a2"
+            version = "0.0.1"
+            authors = []
+            [dependencies]
+            b = { path = "../b" }
+        "#)
+        .file("a2/src/lib.rs", "")
+        .file("b/Cargo.toml", r#"
+            [package]
+            name = "b"
+            version = "0.0.1"
+            authors = []
+            [dependencies]
+            c = { path = "../c" }
+        "#)
+        .file("b/src/lib.rs", "")
+        .file("c/Cargo.toml", r#"
+            [package]
+            name = "c"
+            version = "0.0.1"
+            authors = []
+            [dependencies]
+            d = { path = "../d" }
+        "#)
+        .file("c/src/lib.rs", "")
+        .file("d/Cargo.toml", r#"
+            [package]
+            name = "d"
+            version = "0.0.1"
+            authors = []
+        "#)
+        .file("d/src/lib.rs", "")
+        .file(".cargo/config", r#"
+            [build]
+            target-dir = "./target"
+        "#);
+    p.build();
+
+    assert_that(p.cargo("build").cwd(p.root().join("a1")),
+                execs().with_status(0).with_stdout(&format!("\
+{compiling} d v0.0.1 ({dir}/d)
+{compiling} c v0.0.1 ({dir}/c)
+{compiling} b v0.0.1 ({dir}/b)
+{compiling} a1 v0.0.1 ({dir}/a1)
+", compiling = COMPILING, dir = p.url())));
+    assert_that(p.cargo("build").cwd(p.root().join("a2")),
+                execs().with_status(0).with_stdout(&format!("\
+{compiling} a2 v0.0.1 ({dir}/a2)
+", compiling = COMPILING, dir = p.url())));
+});
index 247b654dde4b1f1abae0280682644354c66cad0d..f385086ca113b48fce33796e14c645d8f147ee3e 100644 (file)
@@ -127,7 +127,7 @@ Caused by:
   failed to read `[..]Cargo.toml`
 
 Caused by:
-  No such file or directory ([..])
+  [..] (os error [..])
 "));
 });