Report span of test when should_panic test failed

Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
This commit is contained in:
xizheyin 2025-03-17 22:22:32 +08:00
parent 6e83046233
commit c73598f0fb
5 changed files with 108 additions and 2 deletions

View file

@ -77,7 +77,12 @@ pub(crate) fn calc_result(
// The test should have panicked, but didn't panic.
(ShouldPanic::Yes, None) | (ShouldPanic::YesWithMessage(_), None) => {
TestResult::TrFailedMsg("test did not panic as expected".to_string())
let fn_location = if !desc.source_file.is_empty() {
&format!(" at {}:{}:{}", desc.source_file, desc.start_line, desc.start_col)
} else {
""
};
TestResult::TrFailedMsg(format!("test did not panic as expected{}", fn_location))
}
// The test should not have panicked, but did panic.