Skip to content

Commit 0c54ce2

Browse files
committed
refactor(source_id): merge stable hash tests into one
1 parent 3ff54e5 commit 0c54ce2

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed

src/cargo/core/source_id.rs

+4-10
Original file line numberDiff line numberDiff line change
@@ -792,16 +792,6 @@ mod tests {
792792
// the prefix components (e.g. `C:`), there is not way to have a
793793
// cross-platform stable hash for absolute paths.
794794
#[test]
795-
fn test_cratesio_hash() {
796-
let gctx = GlobalContext::default().unwrap();
797-
let crates_io = SourceId::crates_io(&gctx).unwrap();
798-
assert_eq!(crate::util::hex::short_hash(&crates_io), "83d63c3e13aca8cc");
799-
}
800-
801-
// See the comment in `test_cratesio_hash`.
802-
//
803-
// Only test on non-Windows as paths on Windows will get different hashes.
804-
#[test]
805795
fn test_stable_hash() {
806796
use crate::util::StableHasher;
807797
use std::path::Path;
@@ -817,6 +807,10 @@ mod tests {
817807
hasher.finish()
818808
};
819809

810+
let source_id = SourceId::crates_io(&GlobalContext::default().unwrap()).unwrap();
811+
assert_eq!(gen_hash(source_id), 14747226178473219715);
812+
assert_eq!(crate::util::hex::short_hash(&source_id), "83d63c3e13aca8cc");
813+
820814
let url = "https://my-crates.io".into_url().unwrap();
821815
let source_id = SourceId::for_registry(&url).unwrap();
822816
assert_eq!(gen_hash(source_id), 2056262832525457700);

src/cargo/sources/registry/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ fn short_name(id: SourceId, is_shallow: bool) -> String {
456456
// CAUTION: This should not change between versions. If you change how
457457
// this is computed, it will orphan previously cached data, forcing the
458458
// cache to be rebuilt and potentially wasting significant disk space. If
459-
// you change it, be cautious of the impact. See `test_cratesio_hash` for
459+
// you change it, be cautious of the impact. See `test_stable_hash` for
460460
// a similar discussion.
461461
let hash = hex::short_hash(&id);
462462
let ident = id.url().host_str().unwrap_or("").to_string();

0 commit comments

Comments
 (0)