Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update tests.rs to use pretty_assertions for readable diffs #957

Merged
merged 2 commits into from
May 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ features = ["clone-impls", "extra-traits", "fold", "full", "parsing", "printing"

[dev-dependencies]
serial_test = { version = "2.0.0", default-features = false }
pretty_assertions = "1.4.0"

[features]
default = ["clap"]
Expand Down
7 changes: 6 additions & 1 deletion tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ use std::path::Path;
use std::process::Command;
use std::{env, fs, str};

use pretty_assertions::assert_eq;

// Set automatically by cargo for integration tests
static CBINDGEN_PATH: &str = env!("CARGO_BIN_EXE_cbindgen");

Expand Down Expand Up @@ -282,8 +284,11 @@ fn run_compile_test(
}
} else {
if env::var_os("CBINDGEN_TEST_VERIFY").is_some() {
use std::str::from_utf8;
let prev_cbindgen_output = fs::read(&generated_file).unwrap();
assert_eq!(cbindgen_output, prev_cbindgen_output);
let cbindgen_output = from_utf8(&cbindgen_output).unwrap();
let prev_cbindgen_output = from_utf8(&prev_cbindgen_output).unwrap();
assert_eq!(prev_cbindgen_output, cbindgen_output);
} else {
fs::write(&generated_file, &cbindgen_output).unwrap();
}
Expand Down
Loading