diff options
| author | xizheyin <xizheyin@smail.nju.edu.cn> | 2025-03-17 22:22:32 +0800 |
|---|---|---|
| committer | xizheyin <xizheyin@smail.nju.edu.cn> | 2025-04-14 10:36:11 +0800 |
| commit | c73598f0fb0ef2cfcdc784e577a96bb8041445ba (patch) | |
| tree | f44a0bb38416b3778fa96f68dbd7196e638aeccb /library/test/src | |
| parent | 6e830462330a9e34d8176e86d4580dd0820c6fd5 (diff) | |
| download | rust-c73598f0fb0ef2cfcdc784e577a96bb8041445ba.tar.gz rust-c73598f0fb0ef2cfcdc784e577a96bb8041445ba.zip | |
Report span of test when should_panic test failed
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
Diffstat (limited to 'library/test/src')
| -rw-r--r-- | library/test/src/test_result.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/library/test/src/test_result.rs b/library/test/src/test_result.rs index 959cd730fa4..a312894c25c 100644 --- a/library/test/src/test_result.rs +++ b/library/test/src/test_result.rs @@ -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. |
