diff --git a/Cargo.lock b/Cargo.lock index 4ebc494..e31ea95 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7,6 +7,7 @@ name = "alejandra" version = "3.0.0" dependencies = [ "mimalloc", + "pretty_assertions", "rnix", "rowan", ] @@ -112,6 +113,22 @@ version = "2.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "328b822bdcba4d4e402be8d9adb6eebf269f969f8eadef977a553ff3c4fbcb58" +[[package]] +name = "ctor" +version = "0.1.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d2301688392eb071b0bf1a37be05c469d3cc4dbbd95df672fe28ab021e6a096" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "diff" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8" + [[package]] name = "futures" version = "0.3.25" @@ -308,6 +325,15 @@ version = "6.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b5bf27447411e9ee3ff51186bf7a08e16c341efdde93f4d823e8844429bed7e" +[[package]] +name = "output_vt100" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "628223faebab4e3e40667ee0b2336d34a5b960ff60ea743ddfdbcf7770bcfb66" +dependencies = [ + "winapi", +] + [[package]] name = "pin-project-lite" version = "0.2.9" @@ -320,6 +346,18 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "pretty_assertions" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a25e9bcb20aa780fd0bb16b72403a9064d6b3f22f026946029acb941a50af755" +dependencies = [ + "ctor", + "diff", + "output_vt100", + "yansi", +] + [[package]] name = "proc-macro-error" version = "1.0.4" @@ -540,3 +578,9 @@ name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "yansi" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" diff --git a/src/alejandra/Cargo.toml b/src/alejandra/Cargo.toml index c00a132..4018e93 100644 --- a/src/alejandra/Cargo.toml +++ b/src/alejandra/Cargo.toml @@ -34,3 +34,6 @@ license = "Unlicense" name = "alejandra" repository = "https://github.com/kamadorueda/alejandra" version = "3.0.0" + +[dev-dependencies] +pretty_assertions = "1.3.0" diff --git a/src/alejandra/tests/fmt.rs b/src/alejandra/tests/fmt.rs index b947c4e..d1fbbd8 100644 --- a/src/alejandra/tests/fmt.rs +++ b/src/alejandra/tests/fmt.rs @@ -1,3 +1,4 @@ +use pretty_assertions::assert_eq; use std::io::Write; #[test] @@ -26,6 +27,6 @@ fn cases() { let content_out = std::fs::read_to_string(path_out.clone()).unwrap(); - assert!(content_got == content_out); + assert_eq!(content_out, content_got, "Test case `{case}` failed; see `src/alejandra/tests/cases/{case}/`"); } }