Repository: toml-rs/toml
Pull request #860 (2025-04-21 20:21:06)

test(edit): Reduce duplicate test runs


Patch:
diff --git a/Cargo.lock b/Cargo.lock
index c19f057d..ba1d9320 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -920,6 +920,7 @@ checksum = "09bfc3e423ee63d96dc78d95894ac4303839aa6c0eece2d9d9e1dd055e092773"
 dependencies = [
  "ignore",
  "libtest-mimic",
+ "snapbox",
  "toml-test",
  "toml-test-data",
 ]
@@ -950,7 +951,6 @@ version = "0.22.24"
 dependencies = [
  "indexmap",
  "kstring",
- "libtest-mimic",
  "proptest",
  "serde",
  "serde_json",
diff --git a/_typos.toml b/_typos.toml
index c378d1c5..9797c1b9 100644
--- a/_typos.toml
+++ b/_typos.toml
@@ -1,6 +1,6 @@
 [files]
 extend-exclude = [
-    "crates/toml_edit/tests/fixtures/**",
+    "crates/toml_edit/tests/snapshots/**",
     "crates/benchmarks/src/Cargo.*.toml",
 ]
 
diff --git a/crates/toml_edit/Cargo.toml b/crates/toml_edit/Cargo.toml
index 1317c06b..067d5f1b 100644
--- a/crates/toml_edit/Cargo.toml
+++ b/crates/toml_edit/Cargo.toml
@@ -50,9 +50,8 @@ toml_write = { version = "0.1.0", path = "../toml_write", optional = true }
 
 [dev-dependencies]
 serde_json = "1.0.116"
-toml-test-harness = "1.0.0"
+toml-test-harness = { version = "1.0.0", features = ["snapshot"] }
 toml-test-data = "2.0.0"
-libtest-mimic = "0.7.2"
 snapbox = "0.6.0"
 proptest = "1.5.0"
 
@@ -62,16 +61,11 @@ required-features = ["parse", "display"]
 
 [[test]]
 name = "decoder_compliance"
-required-features = ["parse"]
-harness = false
-
-[[test]]
-name = "encoder_compliance"
 required-features = ["parse", "display"]
 harness = false
 
 [[test]]
-name = "invalid"
+name = "encoder_compliance"
 required-features = ["parse", "display"]
 harness = false
 


Test patch:
diff --git a/crates/toml_edit/tests/decoder_compliance.rs b/crates/toml_edit/tests/decoder_compliance.rs
index 37a9335e..01cb3f4a 100644
--- a/crates/toml_edit/tests/decoder_compliance.rs
+++ b/crates/toml_edit/tests/decoder_compliance.rs
@@ -5,5 +5,6 @@ fn main() {
     let mut harness = toml_test_harness::DecoderHarness::new(decoder);
     harness.version("1.0.0");
     harness.ignore([]).unwrap();
+    harness.snapshot_root("tests/snapshots");
     harness.test();
 }
diff --git a/crates/toml_edit/tests/fixtures/invalid/array/array.stderr b/crates/toml_edit/tests/fixtures/invalid/array/array.stderr
deleted file mode 100644
index 6cb810d2..00000000
--- a/crates/toml_edit/tests/fixtures/invalid/array/array.stderr
+++ /dev/null
@@ -1,6 +0,0 @@
-TOML parse error at line 1, column 21
-  |
-1 | double-comma-1 = [1,,2]
-  |                     ^
-invalid array
-expected `]`
diff --git a/crates/toml_edit/tests/fixtures/invalid/bool/bool.stderr b/crates/toml_edit/tests/fixtures/invalid/bool/bool.stderr
deleted file mode 100644
index 15170841..00000000
--- a/crates/toml_edit/tests/fixtures/invalid/bool/bool.stderr
+++ /dev/null
@@ -1,6 +0,0 @@
-TOML parse error at line 1, column 27
-  |
-1 | almost-false-with-extra = falsify
-  |                           ^
-invalid string
-expected `"`, `'`
diff --git a/crates/toml_edit/tests/fixtures/invalid/control/control.stderr b/crates/toml_edit/tests/fixtures/invalid/control/control.stderr
deleted file mode 100644
index f214b54f..00000000
--- a/crates/toml_edit/tests/fixtures/invalid/control/control.stderr
+++ /dev/null
@@ -1,5 +0,0 @@
-TOML parse error at line 9, column 1
-  |
-9 | comment-cr   = "Carriage return in comment" # \x0da=1
-  | ^
-duplicate key `comment-cr` in document root
diff --git a/crates/toml_edit/tests/fixtures/invalid/float/float.stderr b/crates/toml_edit/tests/fixtures/invalid/float/float.stderr
deleted file mode 100644
index 627650f8..00000000
--- a/crates/toml_edit/tests/fixtures/invalid/float/float.stderr
+++ /dev/null
@@ -1,5 +0,0 @@
-TOML parse error at line 1, column 17
-  |
-1 | leading-zero = 03.14
-  |                 ^
-expected newline, `#`
diff --git a/crates/toml_edit/tests/fixtures/invalid/integer/integer.stderr b/crates/toml_edit/tests/fixtures/invalid/integer/integer.stderr
deleted file mode 100644
index f058a2d9..00000000
--- a/crates/toml_edit/tests/fixtures/invalid/integer/integer.stderr
+++ /dev/null
@@ -1,5 +0,0 @@
-TOML parse error at line 1, column 19
-  |
-1 | leading-zero-1 = 01
-  |                   ^
-expected newline, `#`
diff --git a/crates/toml_edit/tests/fixtures/invalid/string/string.stderr b/crates/toml_edit/tests/fixtures/invalid/string/string.stderr
deleted file mode 100644
index 5d5577fa..00000000
--- a/crates/toml_edit/tests/fixtures/invalid/string/string.stderr
+++ /dev/null
@@ -1,6 +0,0 @@
-TOML parse error at line 1, column 20
-  |
-1 | bad-hex-esc-1 = "\x0g"
-  |                    ^
-invalid escape sequence
-expected `b`, `f`, `n`, `r`, `t`, `u`, `U`, `\`, `"`
diff --git a/crates/toml_edit/tests/invalid.rs b/crates/toml_edit/tests/invalid.rs
deleted file mode 100644
index 18c81be2..00000000
--- a/crates/toml_edit/tests/invalid.rs
+++ /dev/null
@@ -1,26 +0,0 @@
-use toml_edit::DocumentMut;
-
-fn main() {
-    let args = libtest_mimic::Arguments::from_args();
-    let tests = toml_test_data::invalid()
-        .map(|case| {
-            libtest_mimic::Trial::test(case.name.display().to_string(), move || {
-                let expect_path =
-                    std::path::Path::new("tests/fixtures").join(case.name.with_extension("stderr"));
-                let err = match run_case(case.fixture()) {
-                    Ok(()) => "".to_owned(),
-                    Err(err) => err,
-                };
-                snapbox::assert_data_eq!(err, snapbox::Data::read_from(&expect_path, None).raw());
-                Ok(())
-            })
-        })
-        .collect();
-    libtest_mimic::run(&args, tests).exit()
-}
-
-fn run_case(input: &[u8]) -> Result<(), String> {
-    let raw = std::str::from_utf8(input).map_err(|e| e.to_string())?;
-    let _ = raw.parse::<DocumentMut>().map_err(|e| e.to_string())?;
-    Ok(())
-}