From eafc743c0d8906d891853cf8edb2be3b1bc53db5 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Fri, 24 May 2024 12:20:13 -0500 Subject: [PATCH] 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`. --- Cargo.lock | 4 +- Cargo.toml | 2 +- crates/cargo-test-support/src/compare.rs | 12 +-- src/cargo/util/toml/embedded.rs | 101 ++++++++++++----------- 4 files changed, 58 insertions(+), 61 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a1ed4dc3b..dcb4f31e1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -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", diff --git a/Cargo.toml b/Cargo.toml index 7f9ac30f4..c429c94bd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" diff --git a/crates/cargo-test-support/src/compare.rs b/crates/cargo-test-support/src/compare.rs index d38cd5d4a..4ccc7f263 100644 --- a/crates/cargo-test-support/src/compare.rs +++ b/crates/cargo-test-support/src/compare.rs @@ -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) diff --git a/src/cargo/util/toml/embedded.rs b/src/cargo/util/toml/embedded.rs index 5f176041f..618ff0036 100644 --- a/src/cargo/util/toml/embedded.rs +++ b/src/cargo/util/toml/embedded.rs @@ -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] + +"#]] ); } }