refactor(tvix/eval): use pretty_assertions for tests
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>
This commit is contained in:
parent
f153a163a6
commit
16e9703f38
3 changed files with 50 additions and 4 deletions
44
tvix/eval/Cargo.lock
generated
44
tvix/eval/Cargo.lock
generated
|
@ -201,6 +201,22 @@ dependencies = [
|
|||
"memchr",
|
||||
]
|
||||
|
||||
[[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"
|
||||
|
@ -463,6 +479,15 @@ version = "11.1.3"
|
|||
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"
|
||||
|
@ -497,6 +522,18 @@ dependencies = [
|
|||
"plotters-backend",
|
||||
]
|
||||
|
||||
[[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"
|
||||
|
@ -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"
|
||||
|
|
|
@ -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++
|
||||
|
|
|
@ -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)"
|
||||
)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue