From 12112fa7b8ec3f5065b340e294af0c9f0cdd5cc4 Mon Sep 17 00:00:00 2001 From: "Norman Nunley, Jr." Date: Sun, 22 Dec 2024 12:22:14 -0500 Subject: [PATCH] Switch from text-diff to similar for content diffing. --- Cargo.lock | 115 +++++++++++++++++--------------- Cargo.toml | 3 +- crates/kernel/Cargo.toml | 3 +- crates/kernel/tests/textdump.rs | 6 +- 4 files changed, 67 insertions(+), 60 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ab60cd17..8f33b058 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -310,6 +310,17 @@ dependencies = [ "opaque-debug", ] +[[package]] +name = "bstr" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "786a307d683a5bf92e6fd5fd69a7eb613751668d1d8d67d802846dfe367c62c8" +dependencies = [ + "memchr", + "regex-automata", + "serde", +] + [[package]] name = "bumpalo" version = "3.16.0" @@ -525,6 +536,18 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" +[[package]] +name = "console" +version = "0.15.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea3c6ecd8059b57859df5c69830340ed3c41d30e3da0c1cbed90a96ac853041b" +dependencies = [ + "encode_unicode", + "libc", + "once_cell", + "windows-sys 0.59.0", +] + [[package]] name = "const-oid" version = "0.9.6" @@ -698,7 +721,7 @@ dependencies = [ "rustix", "signal-hook", "signal-hook-mio", - "winapi 0.3.9", + "winapi", ] [[package]] @@ -707,7 +730,7 @@ version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "acdd7c62a3665c7f6830a51635d9ac9b23ed385797f70a83bb8bafe9c572ab2b" dependencies = [ - "winapi 0.3.9", + "winapi", ] [[package]] @@ -898,6 +921,12 @@ version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" +[[package]] +name = "encode_unicode" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34aa73646ffb006b8f5147f3dc182bd4bcb190227ce861fc4a4844bf8e3cb2c0" + [[package]] name = "encoding_rs" version = "0.8.35" @@ -1120,15 +1149,6 @@ dependencies = [ "version_check", ] -[[package]] -name = "getopts" -version = "0.2.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14dbbfd5c71d70241ecf9e6f13737f7b5ce823821063188d7e46c41d371eebd5" -dependencies = [ - "unicode-width", -] - [[package]] name = "getrandom" version = "0.2.15" @@ -1433,16 +1453,6 @@ dependencies = [ "rayon", ] -[[package]] -name = "kernel32-sys" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" -dependencies = [ - "winapi 0.2.8", - "winapi-build", -] - [[package]] name = "lazy-regex" version = "3.3.0" @@ -1699,10 +1709,11 @@ dependencies = [ "rand", "semver", "serde", + "similar", + "similar-asserts", "strum", "test-case", "test_each_file", - "text-diff", "text_io", "thiserror 2.0.8", "tracing", @@ -1829,7 +1840,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" dependencies = [ "overload", - "winapi 0.3.9", + "winapi", ] [[package]] @@ -2674,6 +2685,26 @@ dependencies = [ "rand_core", ] +[[package]] +name = "similar" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1de1d4f81173b03af4c0cbed3c898f6bff5b870e4a7f5d6f4057d62a7a4b686e" +dependencies = [ + "bstr", + "unicode-segmentation", +] + +[[package]] +name = "similar-asserts" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfe85670573cd6f0fa97940f26e7e6601213c3b0555246c24234131f88c5709e" +dependencies = [ + "console", + "similar", +] + [[package]] name = "siphasher" version = "0.3.11" @@ -2837,16 +2868,6 @@ dependencies = [ "windows-sys 0.59.0", ] -[[package]] -name = "term" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2077e54d38055cf1ca0fd7933a2e00cd3ec8f6fed352b2a377f06dcdaaf3281" -dependencies = [ - "kernel32-sys", - "winapi 0.2.8", -] - [[package]] name = "termimad" version = "0.31.1" @@ -2908,16 +2929,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "text-diff" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "309238dd66f8bf11a20d015b727b926f294a13fcb8d56770bb984e7a22c43897" -dependencies = [ - "getopts", - "term", -] - [[package]] name = "text_io" version = "0.1.12" @@ -3258,6 +3269,12 @@ version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" +[[package]] +name = "unicode-segmentation" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" + [[package]] name = "unicode-width" version = "0.1.14" @@ -3445,12 +3462,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "winapi" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" - [[package]] name = "winapi" version = "0.3.9" @@ -3461,12 +3472,6 @@ dependencies = [ "winapi-x86_64-pc-windows-gnu", ] -[[package]] -name = "winapi-build" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" - [[package]] name = "winapi-i686-pc-windows-gnu" version = "0.4.0" diff --git a/Cargo.toml b/Cargo.toml index 5bbd9356..c9e774b0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -98,7 +98,8 @@ num-traits = "0.2" oneshot = { version = "0.1", default-features = false, features = ["std"] } semver = "1.0.24" strum = { version = "0.26", features = ["derive"] } -text-diff = "0.4" +similar = "*" +similar-asserts = "*" ustr = "1.0" uuid = { version = "1.11", features = ["v4"] } xml-rs = "0.8.24" diff --git a/crates/kernel/Cargo.toml b/crates/kernel/Cargo.toml index efd38b92..3cd1b4e1 100644 --- a/crates/kernel/Cargo.toml +++ b/crates/kernel/Cargo.toml @@ -20,7 +20,8 @@ eyre.workspace = true pretty_assertions.workspace = true test-case.workspace = true test_each_file.workspace = true -text-diff.workspace = true +similar.workspace = true +similar-asserts.workspace = true tracing.workspace = true [[test]] diff --git a/crates/kernel/tests/textdump.rs b/crates/kernel/tests/textdump.rs index d72a6618..0ccff802 100644 --- a/crates/kernel/tests/textdump.rs +++ b/crates/kernel/tests/textdump.rs @@ -20,7 +20,7 @@ mod test { use std::io::{BufReader, Read}; use std::path::PathBuf; use std::sync::Arc; - use text_diff::assert_diff; + use similar_asserts; use moor_compiler::Program; use moor_db::loader::LoaderInterface; @@ -183,7 +183,7 @@ mod test { let input = String::from_utf8(br.bytes().map(|b| b.unwrap()).collect()) .expect("Failed to convert input to string"); - assert_diff(&input, &output, "", 0); + similar_asserts::assert_eq!(&input, &output, ""); } /// Actually load a textdump into an actual *database* and confirm that it has the expected contents. @@ -256,7 +256,7 @@ mod test { let output = write_textdump(db, "** LambdaMOO Database, Format Version 1 **"); - assert_diff(&input, &output, "", 0); + similar_asserts::assert_eq!(&input, &output,""); } #[test]