Skip to content

Commit

Permalink
Use similar-asserts to show bindgen diff
Browse files Browse the repository at this point in the history
  • Loading branch information
djc committed Feb 24, 2025
1 parent d0f8b59 commit bf1973c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ android-tzdata = { version = "0.1.1", optional = true }
[dev-dependencies]
serde_json = { version = "1" }
serde_derive = { version = "1", default-features = false }
similar-asserts = { version = "1.6.1" }
bincode = { version = "1.3.0" }

[target.'cfg(all(target_arch = "wasm32", not(any(target_os = "emscripten", target_os = "wasi"))))'.dev-dependencies]
Expand Down
9 changes: 8 additions & 1 deletion tests/win_bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,14 @@ fn gen_bindings() {
// Check the output is the same as before.
// Depending on the git configuration the file may have been checked out with `\r\n` newlines or
// with `\n`. Compare line-by-line to ignore this difference.
let new = fs::read_to_string(output).unwrap();
let mut new = fs::read_to_string(output).unwrap();
if existing.contains("\r\n") && !new.contains("\r\n") {
new = new.replace("\n", "\r\n");
} else if !existing.contains("\r\n") && new.contains("\r\n") {
new = new.replace("\r\n", "\n");
}

similar_asserts::assert_eq!(existing, new);
if !new.lines().eq(existing.lines()) {
panic!("generated file `{}` is changed.", output);
}
Expand Down

0 comments on commit bf1973c

Please sign in to comment.