Skip to content

Commit 58e86d4

Browse files
committed
test(bindeps): recompile when bin target is also artifact dep
This records the WRONG behaviour, which parent fingerpint cannot detect change of a dependency if it is a bin target and also a artifact dep.
1 parent 5ccea51 commit 58e86d4

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

tests/testsuite/artifact_dep.rs

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2276,3 +2276,71 @@ fn build_script_features_for_shared_dependency() {
22762276
.masquerade_as_nightly_cargo(&["bindeps"])
22772277
.run();
22782278
}
2279+
2280+
#[cargo_test]
2281+
fn calc_bin_artifact_fingerprint() {
2282+
// This records the WRONG behaviour. See rust-lang/cargo#10527
2283+
let p = project()
2284+
.file(
2285+
"Cargo.toml",
2286+
r#"
2287+
[package]
2288+
name = "foo"
2289+
version = "0.1.0"
2290+
resolver = "2"
2291+
2292+
[dependencies]
2293+
bar = { path = "bar/", artifact = "bin" }
2294+
"#,
2295+
)
2296+
.file(
2297+
"src/main.rs",
2298+
r#"
2299+
fn main() {
2300+
let _b = include_bytes!(env!("CARGO_BIN_FILE_BAR"));
2301+
}
2302+
"#,
2303+
)
2304+
.file("bar/Cargo.toml", &basic_bin_manifest("bar"))
2305+
.file("bar/src/main.rs", r#"fn main() { println!("foo") }"#)
2306+
.build();
2307+
p.cargo("check -Z bindeps")
2308+
.masquerade_as_nightly_cargo(&["bindeps"])
2309+
.with_stderr(
2310+
"\
2311+
[COMPILING] bar v0.5.0 ([CWD]/bar)
2312+
[CHECKING] foo v0.1.0 ([CWD])
2313+
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
2314+
",
2315+
)
2316+
.run();
2317+
2318+
p.change_file("bar/src/main.rs", r#"fn main() { println!("bar") }"#);
2319+
// Change in bin artifact but not propagated to parent fingerprint.
2320+
// This is WRONG!
2321+
p.cargo("check -v -Z bindeps")
2322+
.masquerade_as_nightly_cargo(&["bindeps"])
2323+
.with_stderr(
2324+
"\
2325+
[COMPILING] bar v0.5.0 ([CWD]/bar)
2326+
[RUNNING] `rustc --crate-name bar [..]`
2327+
[FRESH] foo v0.1.0 ([CWD])
2328+
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
2329+
",
2330+
)
2331+
.run();
2332+
2333+
// Only run the second time can parent fingerpint perceive the change.
2334+
// This is WRONG!
2335+
p.cargo("check -v -Z bindeps")
2336+
.masquerade_as_nightly_cargo(&["bindeps"])
2337+
.with_stderr(
2338+
"\
2339+
[FRESH] bar v0.5.0 ([CWD]/bar)
2340+
[CHECKING] foo v0.1.0 ([CWD])
2341+
[RUNNING] `rustc --crate-name foo [..]`
2342+
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
2343+
",
2344+
)
2345+
.run();
2346+
}

0 commit comments

Comments
 (0)