Skip to content

Commit

Permalink
Auto merge of #10372 - weihanglo:issue-9325, r=ehuss
Browse files Browse the repository at this point in the history
Test: ensure dep-infos do not collide when cdylib and bin coexist
  • Loading branch information
bors committed Feb 25, 2022
2 parents 263cc2b + e214248 commit c9a8199
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions tests/testsuite/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4541,6 +4541,54 @@ fn cdylib_final_outputs() {
}
}

#[cargo_test]
// NOTE: Windows MSVC and wasm32-unknown-emscripten do not use metadata. Skip them.
// See <https://github.com/rust-lang/cargo/issues/9325#issuecomment-1030662699>
#[cfg(not(all(target_os = "windows", target_env = "msvc")))]
fn no_dep_info_collision_when_cdylib_and_bin_coexist() {
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "1.0.0"
[lib]
crate-type = ["cdylib"]
"#,
)
.file("src/main.rs", "fn main() {}")
.file("src/lib.rs", "")
.build();

p.cargo("build -v")
.with_stderr_unordered(
"\
[COMPILING] foo v1.0.0 ([CWD])
[RUNNING] `rustc [..] --crate-type bin [..] -C metadata=[..]`
[RUNNING] `rustc [..] --crate-type cdylib [..] -C metadata=[..]`
[FINISHED] [..]
",
)
.run();

let deps_dir = p.target_debug_dir().join("deps");
assert!(deps_dir.join("foo.d").exists());
let dep_info_count = deps_dir
.read_dir()
.unwrap()
.filter(|e| {
let filename = e.as_ref().unwrap().file_name();
let filename = filename.to_str().unwrap();
filename.starts_with("foo") && filename.ends_with(".d")
})
.count();
// cdylib -> foo.d
// bin -> foo-<meta>.d
assert_eq!(dep_info_count, 2);
}

#[cargo_test]
fn deterministic_cfg_flags() {
// This bug is non-deterministic.
Expand Down

0 comments on commit c9a8199

Please sign in to comment.