about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAdam Joseph <adam@westernsemico.com>2022-10-25T19·51-0700
committerclbot <clbot@tvl.fyi>2022-10-26T10·20+0000
commitdc3543e0ca03b5954c4c740f984078f11e57b867 (patch)
treef5005669390f562df6e3f4bc7f7e3136457224cf
parent8425c2016c9a29008cdec8414fc647b8076a7e34 (diff)
feat(tvix/eval): include filename of failing test when failing r/5199
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 <adam@westernsemico.com>
Reviewed-on: https://cl.tvl.fyi/c/depot/+/7092
Tested-by: BuildkiteCI
Reviewed-by: tazjin <tazjin@tvl.su>
-rw-r--r--tvix/eval/src/tests/mod.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/tvix/eval/src/tests/mod.rs b/tvix/eval/src/tests/mod.rs
index 798cc7b87b..84fc89641c 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
                 );
             }