Skip to content

Commit

Permalink
test: Update regex of HASH redaction for registry files
Browse files Browse the repository at this point in the history
  • Loading branch information
dieterplex committed Jul 13, 2024
1 parent b31577d commit 265c923
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion crates/cargo-test-support/src/compare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ fn add_regex_redactions(subs: &mut snapbox::Redactions) {
.unwrap();
subs.insert(
"[HASH]",
regex!(r"home/\.cargo/registry/src/-(?<redacted>[a-z0-9]+)"),
regex!(r"home/\.cargo/registry/(cache|index|src)/-(?<redacted>[a-z0-9]+)"),
)
.unwrap();
subs.insert(
Expand Down Expand Up @@ -979,4 +979,23 @@ B", false,
str!["[FINISHED] `release` profile [optimized] target(s) in [ELAPSED]s"].raw()
);
}

#[test]
fn redact_hash() {
let mut subs = snapbox::Redactions::new();
add_regex_redactions(&mut subs);

assert_data_eq!(
subs.redact("[REMOVING] [ROOT]/home/.cargo/registry/cache/-1234567890abcdef"),
str!["[REMOVING] [ROOT]/home/.cargo/registry/index/-[HASH]"].raw()
);
assert_data_eq!(
subs.redact("[REMOVING] [ROOT]/home/.cargo/registry/index/-1234567890abcdef"),
str!["[REMOVING] [ROOT]/home/.cargo/registry/src/-[HASH]"].raw()
);
assert_data_eq!(
subs.redact("[REMOVING] [ROOT]/home/.cargo/registry/src/-1234567890abcdef"),
str!["[REMOVING] [ROOT]/home/.cargo/registry/src/-[HASH]"].raw()
);
}
}

0 comments on commit 265c923

Please sign in to comment.