Skip to content

Commit

Permalink
Fix fingerprint calculation for patched deps.
Browse files Browse the repository at this point in the history
  • Loading branch information
ehuss committed Dec 28, 2018
1 parent fef7802 commit ed98cab
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 6 deletions.
6 changes: 1 addition & 5 deletions src/cargo/core/compiler/fingerprint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,6 @@ impl Fingerprint {
}

fn update_local(&self, root: &Path) -> CargoResult<()> {
let mut hash_busted = false;
for local in self.local.iter() {
match *local {
LocalFingerprint::MtimeBased(ref slot, ref path) => {
Expand All @@ -246,12 +245,9 @@ impl Fingerprint {
}
LocalFingerprint::EnvBased(..) | LocalFingerprint::Precalculated(..) => continue,
}
hash_busted = true;
}

if hash_busted {
*self.memoized_hash.lock().unwrap() = None;
}
*self.memoized_hash.lock().unwrap() = None;
Ok(())
}

Expand Down
59 changes: 58 additions & 1 deletion tests/testsuite/freshness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::io::prelude::*;
use crate::support::paths::CargoPathExt;
use crate::support::registry::Package;
use crate::support::sleep_ms;
use crate::support::{basic_manifest, project};
use crate::support::{basic_manifest, is_coarse_mtime, project};

#[test]
fn modifying_and_moving() {
Expand Down Expand Up @@ -1246,3 +1246,60 @@ fn reuse_panic_pm() {
)
.run();
}

#[test]
fn bust_patched_dep() {
Package::new("registry1", "0.1.0").publish();
Package::new("registry2", "0.1.0")
.dep("registry1", "0.1.0")
.publish();

let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.0.1"
[dependencies]
registry2 = "0.1.0"
[patch.crates-io]
registry1 = { path = "reg1new" }
"#,
)
.file("src/lib.rs", "")
.file("reg1new/Cargo.toml", &basic_manifest("registry1", "0.1.0"))
.file("reg1new/src/lib.rs", "")
.build();

p.cargo("build").run();

File::create(&p.root().join("reg1new/src/lib.rs")).unwrap();
if is_coarse_mtime() {
sleep_ms(1000);
}

p.cargo("build")
.with_stderr(
"\
[COMPILING] registry1 v0.1.0 ([..])
[COMPILING] registry2 v0.1.0
[COMPILING] foo v0.0.1 ([..])
[FINISHED] [..]
",
)
.run();

p.cargo("build -v")
.with_stderr(
"\
[FRESH] registry1 v0.1.0 ([..])
[FRESH] registry2 v0.1.0
[FRESH] foo v0.0.1 ([..])
[FINISHED] [..]
",
)
.run();
}

0 comments on commit ed98cab

Please sign in to comment.