Skip to content

Commit eb0e4c0

Browse files
tylerwhallLexmark-tyhall
authored andcommitted
Add a test for stable metadata across workspaces
1 parent dd02aa3 commit eb0e4c0

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

tests/build.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
extern crate cargo;
2+
#[macro_use]
23
extern crate cargotest;
34
extern crate hamcrest;
45
extern crate tempdir;
@@ -3271,3 +3272,32 @@ fn no_bin_in_src_with_lib() {
32713272
execs().with_status(101)
32723273
.with_stderr_contains(r#"[ERROR] couldn't read "[..]main.rs"[..]"#));
32733274
}
3275+
3276+
#[test]
3277+
fn same_metadata_different_directory() {
3278+
// A top-level crate built in two different workspaces should have the
3279+
// same metadata hash.
3280+
let p = project("foo1")
3281+
.file("Cargo.toml", &basic_bin_manifest("foo"))
3282+
.file("src/foo.rs", &main_file(r#""i am foo""#, &[]));
3283+
let output = t!(String::from_utf8(
3284+
t!(p.cargo_process("build").arg("-v").exec_with_output())
3285+
.stderr,
3286+
));
3287+
let metadata = output
3288+
.split_whitespace()
3289+
.filter(|arg| arg.starts_with("metadata="))
3290+
.next()
3291+
.unwrap();
3292+
3293+
let p = project("foo2")
3294+
.file("Cargo.toml", &basic_bin_manifest("foo"))
3295+
.file("src/foo.rs", &main_file(r#""i am foo""#, &[]));
3296+
3297+
assert_that(
3298+
p.cargo_process("build").arg("-v"),
3299+
execs().with_status(0).with_stderr_contains(
3300+
format!("[..]{}[..]", metadata),
3301+
),
3302+
);
3303+
}

0 commit comments

Comments
 (0)