Skip to content

Commit

Permalink
fix(filters)!: Dont normalize all redactions
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Apr 22, 2024
1 parent 0841264 commit 34272b3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
8 changes: 2 additions & 6 deletions crates/snapbox/src/filters/redactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,7 @@ impl From<&'static str> for RedactedValue {
Self { inner: None }
} else {
Self {
inner: Some(RedactedValueInner::String(crate::filters::normalize_text(
inner,
))),
inner: Some(RedactedValueInner::Str(inner)),
}
}
}
Expand All @@ -192,9 +190,7 @@ impl From<String> for RedactedValue {
Self { inner: None }
} else {
Self {
inner: Some(RedactedValueInner::String(crate::filters::normalize_text(
&inner,
))),
inner: Some(RedactedValueInner::String(inner)),
}
}
}
Expand Down
10 changes: 8 additions & 2 deletions src/cases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,9 @@ impl TestCases {
var: &'static str,
value: impl Into<Cow<'static, str>>,
) -> Result<&Self, crate::Error> {
self.substitutions.borrow_mut().insert(var, value.into())?;
let value = value.into();
let value = snapbox::filters::normalize_text(&value);
self.substitutions.borrow_mut().insert(var, value)?;
Ok(self)
}

Expand All @@ -150,7 +152,11 @@ impl TestCases {
) -> Result<&Self, crate::Error> {
self.substitutions
.borrow_mut()
.extend(vars.into_iter().map(|(v, r)| (v, r.into())))?;
.extend(vars.into_iter().map(|(var, value)| {
let value = value.into();
let value = snapbox::filters::normalize_text(&value);
(var, value)
}))?;
Ok(self)
}

Expand Down
8 changes: 2 additions & 6 deletions src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,14 +199,10 @@ impl Case {
};
let mut substitutions = substitutions.clone();
if let Some(root) = fs_context.path() {
substitutions
.insert("[ROOT]", root.display().to_string())
.unwrap();
substitutions.insert("[ROOT]", root.to_owned()).unwrap();
}
if let Some(cwd) = cwd.clone().or_else(|| std::env::current_dir().ok()) {
substitutions
.insert("[CWD]", cwd.display().to_string())
.unwrap();
substitutions.insert("[CWD]", cwd).unwrap();
}
substitutions
.insert("[EXE]", std::env::consts::EXE_SUFFIX)
Expand Down

0 comments on commit 34272b3

Please sign in to comment.