Skip to content

Commit

Permalink
refactor(source_id): merge stable hash tests into one
Browse files Browse the repository at this point in the history
  • Loading branch information
weihanglo committed Jul 9, 2024
1 parent 494571a commit 5acc7d0
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 11 deletions.
10 changes: 0 additions & 10 deletions src/cargo/core/source_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -792,16 +792,6 @@ mod tests {
// the prefix components (e.g. `C:`), there is not way to have a
// cross-platform stable hash for absolute paths.
#[test]
fn test_cratesio_hash() {
let gctx = GlobalContext::default().unwrap();
let crates_io = SourceId::crates_io(&gctx).unwrap();
assert_eq!(crate::util::hex::short_hash(&crates_io), "83d63c3e13aca8cc");
}

// See the comment in `test_cratesio_hash`.
//
// Only test on non-Windows as paths on Windows will get different hashes.
#[test]
fn test_stable_hash() {
use std::hash::Hasher;
use std::path::Path;
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/sources/registry/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ fn short_name(id: SourceId, is_shallow: bool) -> String {
// CAUTION: This should not change between versions. If you change how
// this is computed, it will orphan previously cached data, forcing the
// cache to be rebuilt and potentially wasting significant disk space. If
// you change it, be cautious of the impact. See `test_cratesio_hash` for
// you change it, be cautious of the impact. See `test_stable_hash` for
// a similar discussion.
let hash = hex::short_hash(&id);
let ident = id.url().host_str().unwrap_or("").to_string();
Expand Down

0 comments on commit 5acc7d0

Please sign in to comment.