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 <adam@westernsemico.com>
Reviewed-on: https://cl.tvl.fyi/c/depot/+/7092
Tested-by: BuildkiteCI
Reviewed-by: tazjin <tazjin@tvl.su>
This commit is contained in:
Adam Joseph 2022-10-25 12:51:59 -07:00 committed by clbot
parent 8425c2016c
commit dc3543e0ca

View file

@ -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
);
}