chore: Update to snapbox 0.6

We needed to tweak the redactions because snapbox no longer normalizes
slashes on redactions unless the data type is a `PathBuf`.
This commit is contained in:
Ed Page 2024-05-24 12:20:13 -05:00
parent 0bd034cd06
commit eafc743c0d
4 changed files with 58 additions and 61 deletions

4
Cargo.lock generated
View File

@ -3208,9 +3208,9 @@ checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67"
[[package]]
name = "snapbox"
version = "0.5.14"
version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f37d101fcafc8e73748fd8a1b7048f5979f93d372fd17027d7724c1643bc379b"
checksum = "9ad8c7be18cc9ec7f4d7948ad6b9df0e04fc649663e3c0ed59f304ed17ca69e9"
dependencies = [
"anstream",
"anstyle",

View File

@ -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"

View File

@ -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)

View File

@ -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"
[[bin]]
name = "test-"
path = "/home/me/test.rs"
[package]
autobenches = false
autobins = false
autoexamples = false
autotests = false
build = false
edition = "2021"
name = "test-"
[package]
autobenches = false
autobins = false
autoexamples = false
autotests = false
build = false
edition = "2021"
name = "test-"
[profile.release]
strip = true
[profile.release]
strip = true
[workspace]
"#]]
[workspace]
"#]]
);
}
@ -312,27 +313,28 @@ time="0.1.25"
fn main() {}
"#),
str![[r#"
[[bin]]
name = "test-"
path = [..]
[[bin]]
name = "test-"
path = [..]
[dependencies]
time = "0.1.25"
[dependencies]
time = "0.1.25"
[package]
autobenches = false
autobins = false
autoexamples = false
autotests = false
build = false
edition = "2021"
name = "test-"
[package]
autobenches = false
autobins = false
autoexamples = false
autotests = false
build = false
edition = "2021"
name = "test-"
[profile.release]
strip = true
[profile.release]
strip = true
[workspace]
"#]]
[workspace]
"#]]
);
}
@ -346,27 +348,28 @@ time="0.1.25"
fn main() {}
"#),
str![[r#"
[[bin]]
name = "test-"
path = [..]
[[bin]]
name = "test-"
path = [..]
[dependencies]
time = "0.1.25"
[dependencies]
time = "0.1.25"
[package]
autobenches = false
autobins = false
autoexamples = false
autotests = false
build = false
edition = "2021"
name = "test-"
[package]
autobenches = false
autobins = false
autoexamples = false
autotests = false
build = false
edition = "2021"
name = "test-"
[profile.release]
strip = true
[profile.release]
strip = true
[workspace]
"#]]
[workspace]
"#]]
);
}
}