Skip to content

Commit fb95ebb

Browse files
committed
Report span of test when should_panic test failed
Signed-off-by: xizheyin <[email protected]>
1 parent d84a83b commit fb95ebb

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Diff for: test/src/test_result.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,12 @@ pub(crate) fn calc_result(
7777

7878
// The test should have panicked, but didn't panic.
7979
(ShouldPanic::Yes, None) | (ShouldPanic::YesWithMessage(_), None) => {
80-
TestResult::TrFailedMsg("test did not panic as expected".to_string())
80+
let fn_location = if !desc.source_file.is_empty() {
81+
&format!(" at {}:{}:{}", desc.source_file, desc.start_line, desc.start_col)
82+
} else {
83+
""
84+
};
85+
TestResult::TrFailedMsg(format!("test did not panic as expected{}", fn_location))
8186
}
8287

8388
// The test should not have panicked, but did panic.

0 commit comments

Comments
 (0)