Skip to content

Commit 543820f

Browse files
committed
Auto merge of rust-lang#138603 - xizheyin:issue-137405, r=chenyukang
Report line number of test when should_panic test failed Closes rust-lang#137405 --- try-job: x86_64-gnu-llvm-19-3 try-job: test-various
2 parents 0e2c537 + fb95ebb commit 543820f

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)