Skip to content

Commit d3d206d

Browse files
committed
Add a regression test for the issue being fixed
When compiling a package from two separate locations it should be cached the same way both times.
1 parent 09847df commit d3d206d

5 files changed

+69
-6
lines changed

src/cargo/ops/cargo_read_manifest.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use std::collections::{HashMap, HashSet};
22
use std::fs;
3-
use std::io::prelude::*;
43
use std::io;
54
use std::path::{Path, PathBuf};
65

tests/test_cargo_bench.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ test!(bench_with_deep_lib_dep {
299299
assert_that(p.cargo_process("bench"),
300300
execs().with_status(0)
301301
.with_stdout(&format!("\
302-
{compiling} foo v0.0.1 ({dir})
302+
{compiling} foo v0.0.1 ([..])
303303
{compiling} bar v0.0.1 ({dir})
304304
{running} target[..]
305305
@@ -705,7 +705,7 @@ test!(bench_dylib {
705705
assert_that(p.cargo_process("bench").arg("-v"),
706706
execs().with_status(0)
707707
.with_stdout(&format!("\
708-
{compiling} bar v0.0.1 ({dir})
708+
{compiling} bar v0.0.1 ({dir}/bar)
709709
{running} [..] -C opt-level=3 [..]
710710
{compiling} foo v0.0.1 ({dir})
711711
{running} [..] -C opt-level=3 [..]
@@ -732,7 +732,7 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
732732
assert_that(p.cargo("bench").arg("-v"),
733733
execs().with_status(0)
734734
.with_stdout(&format!("\
735-
{fresh} bar v0.0.1 ({dir})
735+
{fresh} bar v0.0.1 ({dir}/bar)
736736
{fresh} foo v0.0.1 ({dir})
737737
{running} [..]target[..]release[..]bench-[..]
738738

tests/test_cargo_compile_path_deps.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ Caused by:
517517
failed to read `[..]bar[..]Cargo.toml`
518518
519519
Caused by:
520-
No such file or directory ([..])
520+
[..] (os error [..])
521521
"));
522522

523523
});

tests/test_cargo_freshness.rs

+64
Original file line numberDiff line numberDiff line change
@@ -288,3 +288,67 @@ test!(rerun_if_changed_in_dep {
288288
assert_that(p.cargo("build"),
289289
execs().with_status(0).with_stdout(""));
290290
});
291+
292+
test!(same_build_dir_cached_packages {
293+
let p = project("foo")
294+
.file("a1/Cargo.toml", r#"
295+
[package]
296+
name = "a1"
297+
version = "0.0.1"
298+
authors = []
299+
[dependencies]
300+
b = { path = "../b" }
301+
"#)
302+
.file("a1/src/lib.rs", "")
303+
.file("a2/Cargo.toml", r#"
304+
[package]
305+
name = "a2"
306+
version = "0.0.1"
307+
authors = []
308+
[dependencies]
309+
b = { path = "../b" }
310+
"#)
311+
.file("a2/src/lib.rs", "")
312+
.file("b/Cargo.toml", r#"
313+
[package]
314+
name = "b"
315+
version = "0.0.1"
316+
authors = []
317+
[dependencies]
318+
c = { path = "../c" }
319+
"#)
320+
.file("b/src/lib.rs", "")
321+
.file("c/Cargo.toml", r#"
322+
[package]
323+
name = "c"
324+
version = "0.0.1"
325+
authors = []
326+
[dependencies]
327+
d = { path = "../d" }
328+
"#)
329+
.file("c/src/lib.rs", "")
330+
.file("d/Cargo.toml", r#"
331+
[package]
332+
name = "d"
333+
version = "0.0.1"
334+
authors = []
335+
"#)
336+
.file("d/src/lib.rs", "")
337+
.file(".cargo/config", r#"
338+
[build]
339+
target-dir = "./target"
340+
"#);
341+
p.build();
342+
343+
assert_that(p.cargo("build").cwd(p.root().join("a1")),
344+
execs().with_status(0).with_stdout(&format!("\
345+
{compiling} d v0.0.1 ({dir}/d)
346+
{compiling} c v0.0.1 ({dir}/c)
347+
{compiling} b v0.0.1 ({dir}/b)
348+
{compiling} a1 v0.0.1 ({dir}/a1)
349+
", compiling = COMPILING, dir = p.url())));
350+
assert_that(p.cargo("build").cwd(p.root().join("a2")),
351+
execs().with_status(0).with_stdout(&format!("\
352+
{compiling} a2 v0.0.1 ({dir}/a2)
353+
", compiling = COMPILING, dir = p.url())));
354+
});

tests/test_cargo_install.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ Caused by:
127127
failed to read `[..]Cargo.toml`
128128
129129
Caused by:
130-
No such file or directory ([..])
130+
[..] (os error [..])
131131
"));
132132
});
133133

0 commit comments

Comments
 (0)