From dc3543e0ca03b5954c4c740f984078f11e57b867 Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Tue, 25 Oct 2022 12:51:59 -0700 Subject: feat(tvix/eval): include filename of failing test when failing Unfortunately we have to mangle test case filenames into rust-valid symbols, since test-generator doesn't use `r#"..."` (deliberately?). This means that when a test fails, there's nothing on the console you can copy-and-paste in order to view/edit the code of the failing test case. This commit (partially) fixes it by including the unmangled name in the panic!() string. However failures due to panic!()s inside the vm (including deliberate panics due to panic!()-debugging) still won't display an unmangled filename. Maybe we should reconsider the use of test-generator? Change-Id: I2208a859ffab1264f17f48fd303ff5e19675967e Signed-off-by: Adam Joseph Reviewed-on: https://cl.tvl.fyi/c/depot/+/7092 Tested-by: BuildkiteCI Reviewed-by: tazjin --- tvix/eval/src/tests/mod.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'tvix') diff --git a/tvix/eval/src/tests/mod.rs b/tvix/eval/src/tests/mod.rs index 798cc7b87b6e..84fc89641c85 100644 --- a/tvix/eval/src/tests/mod.rs +++ b/tvix/eval/src/tests/mod.rs @@ -27,21 +27,21 @@ fn eval_test(code_path: &str, expect_success: bool) { assert_eq!( result_str, exp.trim(), - "result value representation (left) must match expectation (right)" + "{code_path}: result value representation (left) must match expectation (right)" ); } else { assert_ne!( result_str, exp.trim(), - "test passed unexpectedly! consider moving it out of notyetpassing" + "{code_path}: test passed unexpectedly! consider moving it out of notyetpassing" ); } } else { if expect_success { - panic!("should be able to read test expectation"); + panic!("{code_path}: should be able to read test expectation"); } else { panic!( - "test should have failed, but succeeded with output {}", + "{code_path}: test should have failed, but succeeded with output {}", result ); } @@ -50,7 +50,7 @@ fn eval_test(code_path: &str, expect_success: bool) { Err(e) => { if expect_success { panic!( - "evaluation of eval-okay test should succeed, but failed with {:?}", + "{code_path}: evaluation of eval-okay test should succeed, but failed with {:?}", e ); } -- cgit 1.4.1