Repository: rust-lang/annotate-snippets-rs
Pull request #122 (2024-05-24 14:43:05)

chore: Upgrade to snapbox 0.6


Patch:
diff --git a/Cargo.lock b/Cargo.lock
index 49e824e..074ab74 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -29,6 +29,7 @@ dependencies = [
  "serde",
  "snapbox",
  "toml",
+ "tryfn",
  "unicode-width",
 ]
 
@@ -108,12 +109,6 @@ version = "1.1.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
 
-[[package]]
-name = "bitflags"
-version = "1.3.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
-
 [[package]]
 name = "bitflags"
 version = "2.4.1"
@@ -221,15 +216,6 @@ version = "1.0.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7"
 
-[[package]]
-name = "content_inspector"
-version = "0.2.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b7bda66e858c683005a53a9a60c69a4aca7eeaa45d124526e389f7aec8e62f38"
-dependencies = [
- "memchr",
-]
-
 [[package]]
 name = "criterion"
 version = "0.5.1"
@@ -305,12 +291,6 @@ version = "2.0.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198"
 
-[[package]]
-name = "dunce"
-version = "1.0.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "56ce8c6da7551ec6c462cbaf3bfbc75131ebbfa1c944aeaa9dab51ca1c5f0c3b"
-
 [[package]]
 name = "either"
 version = "1.9.0"
@@ -348,24 +328,6 @@ dependencies = [
  "serde_json",
 ]
 
-[[package]]
-name = "fastrand"
-version = "2.0.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5"
-
-[[package]]
-name = "filetime"
-version = "0.2.23"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1ee447700ac8aa0b2f2bd7bc4462ad686ba06baa6727ac149a2d6277f0d240fd"
-dependencies = [
- "cfg-if",
- "libc",
- "redox_syscall",
- "windows-sys 0.52.0",
-]
-
 [[package]]
 name = "glob"
 version = "0.3.1"
@@ -621,15 +583,6 @@ dependencies = [
  "crossbeam-utils",
 ]
 
-[[package]]
-name = "redox_syscall"
-version = "0.4.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa"
-dependencies = [
- "bitflags 1.3.2",
-]
-
 [[package]]
 name = "regex"
 version = "1.10.2"
@@ -665,7 +618,7 @@ version = "0.38.31"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949"
 dependencies = [
- "bitflags 2.4.1",
+ "bitflags",
  "errno",
  "libc",
  "linux-raw-sys",
@@ -738,36 +691,29 @@ checksum = "32fea41aca09ee824cc9724996433064c89f7777e60762749a4170a14abbfa21"
 
 [[package]]
 name = "snapbox"
-version = "0.5.9"
+version = "0.6.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8ac441e1ecf678f68423d47f376d53fabce1afba92c8f68e31508eb27df8562a"
+checksum = "28bef451bfd0a7a395fb3979e130422658926bb2e0d9a168e72aca4c9b5c5738"
 dependencies = [
  "anstream",
  "anstyle",
  "anstyle-svg",
- "content_inspector",
- "dunce",
  "escargot",
- "filetime",
- "ignore",
  "libc",
- "libtest-mimic",
  "normalize-line-endings",
  "os_pipe",
  "serde_json",
  "similar",
  "snapbox-macros",
- "tempfile",
  "wait-timeout",
- "walkdir",
  "windows-sys 0.52.0",
 ]
 
 [[package]]
 name = "snapbox-macros"
-version = "0.3.8"
+version = "0.3.9"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e1c4b838b05d15ab22754068cb73500b2f3b07bf09d310e15b27f88160f1de40"
+checksum = "b1f4c14672714436c09254801c934b203196a51182a5107fb76591c7cc56424d"
 dependencies = [
  "anstream",
 ]
@@ -789,18 +735,6 @@ dependencies = [
  "unicode-ident",
 ]
 
-[[package]]
-name = "tempfile"
-version = "3.10.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1"
-dependencies = [
- "cfg-if",
- "fastrand",
- "rustix",
- "windows-sys 0.52.0",
-]
-
 [[package]]
 name = "termcolor"
 version = "1.4.1"
@@ -838,6 +772,17 @@ dependencies = [
  "serde",
 ]
 
+[[package]]
+name = "tryfn"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "493e1390312bb94363f762687be32a1bd01c3333dfad25a5a7fffab1edc64839"
+dependencies = [
+ "ignore",
+ "libtest-mimic",
+ "snapbox",
+]
+
 [[package]]
 name = "unicode-ident"
 version = "1.0.12"
diff --git a/Cargo.toml b/Cargo.toml
index d7ff69b..72bf895 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -33,8 +33,9 @@ criterion = "0.5.1"
 difference = "2.0.0"
 glob = "0.3.1"
 serde = { version = "1.0.199", features = ["derive"] }
-snapbox = { version = "0.5.9", features = ["diff", "harness", "path", "term-svg", "cmd", "examples"] }
+snapbox = { version = "0.6.0", features = ["diff", "term-svg", "cmd", "examples"] }
 toml = "0.5.11"
+tryfn = "0.2.1"
 
 [[bench]]
 name = "simple"


Test patch:
diff --git a/tests/examples.rs b/tests/examples.rs
index 6025f5e..b657662 100644
--- a/tests/examples.rs
+++ b/tests/examples.rs
@@ -33,5 +33,5 @@ fn assert_example(target: &str, expected: snapbox::Data) {
         .env("CLICOLOR_FORCE", "1")
         .assert()
         .success()
-        .stdout_eq(expected);
+        .stdout_eq(expected.raw());
 }
diff --git a/tests/fixtures/main.rs b/tests/fixtures/main.rs
index 841b363..c0e351c 100644
--- a/tests/fixtures/main.rs
+++ b/tests/fixtures/main.rs
@@ -8,16 +8,15 @@ use std::error::Error;
 
 fn main() {
     #[cfg(not(windows))]
-    snapbox::harness::Harness::new("tests/fixtures/", setup, test)
+    tryfn::Harness::new("tests/fixtures/", setup, test)
         .select(["*/*.toml"])
-        .action_env("SNAPSHOTS")
         .test();
 }
 
-fn setup(input_path: std::path::PathBuf) -> snapbox::harness::Case {
+fn setup(input_path: std::path::PathBuf) -> tryfn::Case {
     let name = input_path.file_name().unwrap().to_str().unwrap().to_owned();
-    let expected = input_path.with_extension("svg");
-    snapbox::harness::Case {
+    let expected = tryfn::Data::read_from(&input_path.with_extension("svg"), None);
+    tryfn::Case {
         name,
         fixture: input_path,
         expected,
diff --git a/tests/formatter.rs b/tests/formatter.rs
index ebe03ff..5b746e1 100644
--- a/tests/formatter.rs
+++ b/tests/formatter.rs
@@ -1,6 +1,6 @@
 use annotate_snippets::{Level, Renderer, Snippet};
 
-use snapbox::{assert_eq, str};
+use snapbox::{assert_data_eq, str};
 
 #[test]
 fn test_i_29() {
@@ -16,11 +16,11 @@ error: oops
   |
 2 | Second oops line
   |        ^^^^ oops
-  |"#]]
-    .indent(false);
+  |
+"#]];
 
     let renderer = Renderer::plain();
-    assert_eq(expected, renderer.render(snippets).to_string());
+    assert_data_eq!(renderer.render(snippets).to_string(), expected);
 }
 
 #[test]
@@ -37,11 +37,11 @@ error
   |
 1 | こんにちは、世界
   |             ^^^^ world
-  |"#]]
-    .indent(false);
+  |
+"#]];
 
     let renderer = Renderer::plain();
-    assert_eq(expected, renderer.render(snippets).to_string());
+    assert_data_eq!(renderer.render(snippets).to_string(), expected);
 }
 
 #[test]
@@ -60,11 +60,11 @@ error
   |  _____^
 2 | | ございます
   | |______^ Good morning
-  |"#]]
-    .indent(false);
+  |
+"#]];
 
     let renderer = Renderer::plain();
-    assert_eq(expected, renderer.render(snippets).to_string());
+    assert_data_eq!(renderer.render(snippets).to_string(), expected);
 }
 
 #[test]
@@ -84,11 +84,11 @@ error
   | ^^^^^^ Sushi1
 2 | 食べたい🍣
   |     ---- note: Sushi2
-  |"#]]
-    .indent(false);
+  |
+"#]];
 
     let renderer = Renderer::plain();
-    assert_eq(expected, renderer.render(snippets).to_string());
+    assert_data_eq!(renderer.render(snippets).to_string(), expected);
 }
 
 #[test]
@@ -105,11 +105,11 @@ error
   |
 1 | こんにちは、新しいWorld！
   |             ^^^^^^^^^^^ New world
-  |"#]]
-    .indent(false);
+  |
+"#]];
 
     let renderer = Renderer::plain();
-    assert_eq(expected, renderer.render(snippets).to_string());
+    assert_data_eq!(renderer.render(snippets).to_string(), expected);
 }
 
 #[test]
@@ -118,7 +118,7 @@ fn test_format_title() {
 
     let expected = str![r#"error[E0001]: This is a title"#];
     let renderer = Renderer::plain();
-    assert_eq(expected, renderer.render(input).to_string());
+    assert_data_eq!(renderer.render(input).to_string(), expected);
 }
 
 #[test]
@@ -133,10 +133,10 @@ error
      |
 5402 | This is line 1
 5403 | This is line 2
-     |"#]]
-    .indent(false);
+     |
+"#]];
     let renderer = Renderer::plain();
-    assert_eq(expected, renderer.render(input).to_string());
+    assert_data_eq!(renderer.render(input).to_string(), expected);
 }
 
 #[test]
@@ -156,10 +156,10 @@ error
     ::: file2.rs
      |
    2 | This is slice 2
-     |"#]]
-    .indent(false);
+     |
+"#]];
     let renderer = Renderer::plain();
-    assert_eq(expected, renderer.render(input).to_string());
+    assert_data_eq!(renderer.render(input).to_string(), expected);
 }
 
 #[test]
@@ -180,10 +180,10 @@ error
 5402 | This is line 1
 5403 | This is line 2
      |        -- info: Test annotation
-     |"#]]
-    .indent(false);
+     |
+"#]];
     let renderer = Renderer::plain();
-    assert_eq(expected, renderer.render(input).to_string());
+    assert_data_eq!(renderer.render(input).to_string(), expected);
 }
 
 #[test]
@@ -193,10 +193,10 @@ fn test_format_footer_title() {
         .footer(Level::Error.title("This __is__ a title"));
     let expected = str![[r#"
 error
- = error: This __is__ a title"#]]
-    .indent(false);
+ = error: This __is__ a title
+"#]];
     let renderer = Renderer::plain();
-    assert_eq(expected, renderer.render(input).to_string());
+    assert_data_eq!(renderer.render(input).to_string(), expected);
 }
 
 #[test]
@@ -224,10 +224,10 @@ error
    |
 56 | This is an example
 57 | of content lines
-   |"#]]
-    .indent(false);
+   |
+"#]];
     let renderer = Renderer::plain();
-    assert_eq(expected, renderer.render(input).to_string());
+    assert_data_eq!(renderer.render(input).to_string(), expected);
 }
 
 #[test]
@@ -243,10 +243,10 @@ error
   |
 1 | tests
   | ----- help: Example string
-  |"#]]
-    .indent(false);
+  |
+"#]];
     let renderer = Renderer::plain();
-    assert_eq(expected, renderer.render(input).to_string());
+    assert_data_eq!(renderer.render(input).to_string(), expected);
 }
 
 #[test]
@@ -264,10 +264,10 @@ error
 1 | tests
   | ----- help: Example string
   | ----- help: Second line
-  |"#]]
-    .indent(false);
+  |
+"#]];
     let renderer = Renderer::plain();
-    assert_eq(expected, renderer.render(input).to_string());
+    assert_data_eq!(renderer.render(input).to_string(), expected);
 }
 
 #[test]
@@ -279,10 +279,10 @@ fn test_only_source() {
 error
 --> file.rs
  |
- |"#]]
-    .indent(false);
+ |
+"#]];
     let renderer = Renderer::plain();
-    assert_eq(expected, renderer.render(input).to_string());
+    assert_data_eq!(renderer.render(input).to_string(), expected);
 }
 
 #[test]
@@ -298,8 +298,8 @@ LL | This is an example
 LL | of content lines
 LL | 
 LL | abc
-   |"#]]
-    .indent(false);
+   |
+"#]];
     let renderer = Renderer::plain().anonymized_line_numbers(true);
-    assert_eq(expected, renderer.render(input).to_string());
+    assert_data_eq!(renderer.render(input).to_string(), expected);
 }