# HG changeset patch # User Bastien Orivel # Date 1465865609 -7200 # Node ID c06d12a81637060a7bff79ebaa72ad2eb6e4259e # Parent 7977a52c3202ab12358e1fe1061f6914a18d19d0 Better test failure. Use assert_diff! instead of assert_eq! so we can actually see what the differences are. diff --git a/Cargo.lock b/Cargo.lock --- a/Cargo.lock +++ b/Cargo.lock @@ -3,6 +3,7 @@ name = "python-compiler" version = "0.0.1" dependencies = [ "cpython 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "difference 0.4.1 (git+https://github.com/johannhof/difference.rs.git)", ] [[package]] @@ -31,6 +32,19 @@ dependencies = [ ] [[package]] +name = "difference" +version = "0.4.1" +source = "git+https://github.com/johannhof/difference.rs.git#d5b2ad5b9670b9b1e097113bb60c13894b94e33a" +dependencies = [ + "getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "getopts" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] name = "interpolate_idents" version = "0.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" diff --git a/Cargo.toml b/Cargo.toml --- a/Cargo.toml +++ b/Cargo.toml @@ -6,3 +6,4 @@ build = "build.rs" [dependencies] cpython = "0.0" +difference = { "git" = "https://github.com/johannhof/difference.rs.git" } diff --git a/src/main.rs b/src/main.rs --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,8 @@ +#[macro_use(assert_diff)] +extern crate difference; extern crate cpython; + #[cfg(test)] mod tests; diff --git a/src/tests/test_parse_files.rs b/src/tests/test_parse_files.rs --- a/src/tests/test_parse_files.rs +++ b/src/tests/test_parse_files.rs @@ -27,8 +27,8 @@ fn test_parse_file(filename: &str) { }; let module_ast = ast_convert::convert_ast("__main__".to_string(), &module); - let dumped_ast = ast_dump::dump_ast(&module_ast); - assert_eq!(code, dumped_ast + "\n"); + let dumped_ast = ast_dump::dump_ast(&module_ast) + "\n"; + assert_diff!(code.as_str(), dumped_ast.as_str(), "\n", 0); } include!(concat!(env!("OUT_DIR"), "/generated_parse_tests.rs"));