Skip to content

Commit

Permalink
chore: Update to snapbox 0.6
Browse files Browse the repository at this point in the history
We needed to tweak the redactions because snapbox no longer normalizes
slashes on redactions unless the data type is a `PathBuf`.
  • Loading branch information
epage committed May 28, 2024
1 parent 0bd034c commit eafc743
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 72 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ sha1 = "0.10.6"
sha2 = "0.10.8"
shell-escape = "0.1.5"
supports-hyperlinks = "3.0.0"
snapbox = { version = "0.5.14", features = ["diff", "dir", "term-svg"] }
snapbox = { version = "0.6.5", features = ["diff", "dir", "term-svg"] }
tar = { version = "0.4.40", default-features = false }
tempfile = "3.10.1"
thiserror = "1.0.59"
Expand Down
12 changes: 3 additions & 9 deletions crates/cargo-test-support/src/compare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,12 @@ pub fn assert_ui() -> snapbox::Assert {
// Use `from_file_path` instead of `from_dir_path` so the trailing slash is
// put in the users output, rather than hidden in the variable
let root_url = url::Url::from_file_path(&root).unwrap().to_string();
let root = root.display().to_string();

let mut subs = snapbox::Redactions::new();
subs.extend([(
"[EXE]",
std::borrow::Cow::Borrowed(std::env::consts::EXE_SUFFIX),
)])
.unwrap();
subs.insert("[ROOT]", std::borrow::Cow::Owned(root))
.unwrap();
subs.insert("[ROOTURL]", std::borrow::Cow::Owned(root_url))
subs.extend([("[EXE]", std::env::consts::EXE_SUFFIX)])
.unwrap();
subs.insert("[ROOT]", root).unwrap();
subs.insert("[ROOTURL]", root_url).unwrap();
snapbox::Assert::new()
.action_env(snapbox::assert::DEFAULT_ACTION_ENV)
.substitutions(subs)
Expand Down
123 changes: 63 additions & 60 deletions src/cargo/util/toml/embedded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,24 +281,25 @@ mod test_expand {
snapbox::assert_data_eq!(
si!(r#"fn main() {}"#),
str![[r#"
[[bin]]
name = "test-"
path = "/home/me/test.rs"
[package]
autobenches = false
autobins = false
autoexamples = false
autotests = false
build = false
edition = "2021"
name = "test-"
[profile.release]
strip = true
[workspace]
"#]]
[[bin]]
name = "test-"
path = "/home/me/test.rs"
[package]
autobenches = false
autobins = false
autoexamples = false
autotests = false
build = false
edition = "2021"
name = "test-"
[profile.release]
strip = true
[workspace]
"#]]
);
}

Expand All @@ -312,27 +313,28 @@ time="0.1.25"
fn main() {}
"#),
str![[r#"
[[bin]]
name = "test-"
path = [..]
[dependencies]
time = "0.1.25"
[package]
autobenches = false
autobins = false
autoexamples = false
autotests = false
build = false
edition = "2021"
name = "test-"
[profile.release]
strip = true
[workspace]
"#]]
[[bin]]
name = "test-"
path = [..]
[dependencies]
time = "0.1.25"
[package]
autobenches = false
autobins = false
autoexamples = false
autotests = false
build = false
edition = "2021"
name = "test-"
[profile.release]
strip = true
[workspace]
"#]]
);
}

Expand All @@ -346,27 +348,28 @@ time="0.1.25"
fn main() {}
"#),
str![[r#"
[[bin]]
name = "test-"
path = [..]
[dependencies]
time = "0.1.25"
[package]
autobenches = false
autobins = false
autoexamples = false
autotests = false
build = false
edition = "2021"
name = "test-"
[profile.release]
strip = true
[workspace]
"#]]
[[bin]]
name = "test-"
path = [..]
[dependencies]
time = "0.1.25"
[package]
autobenches = false
autobins = false
autoexamples = false
autotests = false
build = false
edition = "2021"
name = "test-"
[profile.release]
strip = true
[workspace]
"#]]
);
}
}

0 comments on commit eafc743

Please sign in to comment.