Skip to content

Commit

Permalink
Use pretty_assertions instead of diff in tests (#1776)
Browse files Browse the repository at this point in the history
The very large diffs from errors in development #1775 caused OOMs so I
figured now's as good a time as any to switch over to using
`pretty_assertions` which other crates in the workspace are already using.
  • Loading branch information
alexcrichton authored Sep 11, 2024
1 parent 5ee4030 commit a21c5d0
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 29 deletions.
5 changes: 0 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ is_executable = { version = "1.0.1", optional = true }
[dev-dependencies]
serde_json = "1.0"
tempfile = "3.1"
diff = "0.1"
wast = { path = 'crates/wast' }
pretty_assertions = { workspace = true }
libtest-mimic = { workspace = true }
Expand Down
4 changes: 0 additions & 4 deletions crates/wasmprinter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,4 @@ wasmparser = { workspace = true, features = ['std'] }
termcolor = { workspace = true }

[dev-dependencies]
diff = "0.1"
rayon = { workspace = true }
tempfile = "3.0"
wat = { path = "../wat" }
wast = { path = "../wast" }
20 changes: 1 addition & 19 deletions tests/roundtrip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -428,27 +428,9 @@ impl TestState {
// Handle git possibly doing some newline shenanigans on windows.
let snapshot = snapshot.replace("\r\n", "\n");
if snapshot != contents {
let mut result = String::with_capacity(snapshot.len());
for diff in diff::lines(&snapshot, &contents) {
match diff {
diff::Result::Left(s) => {
result.push_str("-");
result.push_str(s);
}
diff::Result::Right(s) => {
result.push_str("+");
result.push_str(s);
}
diff::Result::Both(s, _) => {
result.push_str(" ");
result.push_str(s);
}
}
result.push_str("\n");
}
anyhow::bail!(
"snapshot does not match the expected result, try `env BLESS=1`\n{}",
result
pretty_assertions::StrComparison::new(&snapshot, &contents)
);
}
}
Expand Down

0 comments on commit a21c5d0

Please sign in to comment.