about summary refs log tree commit diff
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2022-08-16T12·33+0300
committertazjin <tazjin@tvl.su>2022-09-01T12·50+0000
commit16e9703f3810adc4f294fbc723c75f9107e89243 (patch)
treee97cd7d612f5de7dc1e125ae448366424b326581
parentf153a163a692215aa754218e18f6809f1ab0eb48 (diff)
refactor(tvix/eval): use pretty_assertions for tests r/4563
This makes for much more readable output especially when long strings
are involved.

Change-Id: I43dd73a0480535d7181a760788c42883a9b083f8
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6229
Tested-by: BuildkiteCI
Reviewed-by: sterni <sternenseemann@systemli.org>
-rw-r--r--tvix/eval/Cargo.lock44
-rw-r--r--tvix/eval/Cargo.toml1
-rw-r--r--tvix/eval/src/tests/mod.rs9
3 files changed, 50 insertions, 4 deletions
diff --git a/tvix/eval/Cargo.lock b/tvix/eval/Cargo.lock
index 38fbb539309e..59381377bb7b 100644
--- a/tvix/eval/Cargo.lock
+++ b/tvix/eval/Cargo.lock
@@ -202,6 +202,22 @@ dependencies = [
 ]
 
 [[package]]
+name = "ctor"
+version = "0.1.23"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cdffe87e1d521a10f9696f833fe502293ea446d7f256c06128293a4119bdf4cb"
+dependencies = [
+ "quote 1.0.21",
+ "syn 1.0.99",
+]
+
+[[package]]
+name = "diff"
+version = "0.1.13"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8"
+
+[[package]]
 name = "dirs"
 version = "4.0.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -464,6 +480,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575"
 
 [[package]]
+name = "output_vt100"
+version = "0.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "628223faebab4e3e40667ee0b2336d34a5b960ff60ea743ddfdbcf7770bcfb66"
+dependencies = [
+ "winapi",
+]
+
+[[package]]
 name = "path-clean"
 version = "0.1.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -498,6 +523,18 @@ dependencies = [
 ]
 
 [[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-macro2"
 version = "0.4.30"
 source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -850,6 +887,7 @@ dependencies = [
  "criterion",
  "dirs",
  "path-clean",
+ "pretty_assertions",
  "rnix",
  "rustyline",
  "smol_str",
@@ -1041,3 +1079,9 @@ name = "windows_x86_64_msvc"
 version = "0.36.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680"
+
+[[package]]
+name = "yansi"
+version = "0.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec"
diff --git a/tvix/eval/Cargo.toml b/tvix/eval/Cargo.toml
index b0ccabed2e02..0416171c3689 100644
--- a/tvix/eval/Cargo.toml
+++ b/tvix/eval/Cargo.toml
@@ -16,6 +16,7 @@ tabwriter = { version = "1.2", optional = true }
 [dev-dependencies]
 criterion = "0.3.6"
 test-generator = "0.3.0"
+pretty_assertions = "1.2.1"
 
 [features]
 # Enables running the Nix language test suite from the original C++
diff --git a/tvix/eval/src/tests/mod.rs b/tvix/eval/src/tests/mod.rs
index 313498eeb777..ec9ee0d1c9ea 100644
--- a/tvix/eval/src/tests/mod.rs
+++ b/tvix/eval/src/tests/mod.rs
@@ -1,4 +1,5 @@
 use crate::eval::interpret;
+use pretty_assertions::assert_eq;
 
 use test_generator::test_resources;
 
@@ -15,9 +16,9 @@ fn eval_okay_test(code_path: &str) {
     let result_str = format!("{}", result);
 
     assert_eq!(
-        exp.trim(),
         result_str,
-        "result value representation (right) must match expectation (left)"
+        exp.trim(),
+        "result value representation (left) must match expectation (right)"
     );
 }
 
@@ -31,9 +32,9 @@ fn identity(code_path: &str) {
     let result_str = format!("{}", result);
 
     assert_eq!(
-        code.trim(),
         result_str,
-        "result value representation (right) must match expectation (left)"
+        code.trim(),
+        "result value representation (left) must match expectation (right)"
     )
 }