Skip to content

Commit bf1973c

Browse files
committed
Use similar-asserts to show bindgen diff
1 parent d0f8b59 commit bf1973c

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ android-tzdata = { version = "0.1.1", optional = true }
6363
[dev-dependencies]
6464
serde_json = { version = "1" }
6565
serde_derive = { version = "1", default-features = false }
66+
similar-asserts = { version = "1.6.1" }
6667
bincode = { version = "1.3.0" }
6768

6869
[target.'cfg(all(target_arch = "wasm32", not(any(target_os = "emscripten", target_os = "wasi"))))'.dev-dependencies]

tests/win_bindings.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,14 @@ fn gen_bindings() {
1414
// Check the output is the same as before.
1515
// Depending on the git configuration the file may have been checked out with `\r\n` newlines or
1616
// with `\n`. Compare line-by-line to ignore this difference.
17-
let new = fs::read_to_string(output).unwrap();
17+
let mut new = fs::read_to_string(output).unwrap();
18+
if existing.contains("\r\n") && !new.contains("\r\n") {
19+
new = new.replace("\n", "\r\n");
20+
} else if !existing.contains("\r\n") && new.contains("\r\n") {
21+
new = new.replace("\r\n", "\n");
22+
}
23+
24+
similar_asserts::assert_eq!(existing, new);
1825
if !new.lines().eq(existing.lines()) {
1926
panic!("generated file `{}` is changed.", output);
2027
}

0 commit comments

Comments
 (0)