Skip to content

Commit

Permalink
Rollup merge of rust-lang#82274 - andersk:test-unwrap, r=Mark-Simulacrum
Browse files Browse the repository at this point in the history
libtest: Fix unwrap panic on duplicate TestDesc

It is possible for different tests to collide to the same `TestDesc` when macros are involved. That is a bug, but it didn’t cause a panic until rust-lang#81367. For now, change the code to ignore this problem.

Fixes rust-lang#81852.

This will need to be applied to `beta` too.
  • Loading branch information
Dylan-DPC authored Feb 19, 2021
2 parents d9bc16c + 1605af0 commit 36a348b
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions library/test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,12 +353,13 @@ where
}

let mut completed_test = res.unwrap();
let running_test = running_tests.remove(&completed_test.desc).unwrap();
if let Some(join_handle) = running_test.join_handle {
if let Err(_) = join_handle.join() {
if let TrOk = completed_test.result {
completed_test.result =
TrFailedMsg("panicked after reporting success".to_string());
if let Some(running_test) = running_tests.remove(&completed_test.desc) {
if let Some(join_handle) = running_test.join_handle {
if let Err(_) = join_handle.join() {
if let TrOk = completed_test.result {
completed_test.result =
TrFailedMsg("panicked after reporting success".to_string());
}
}
}
}
Expand Down

0 comments on commit 36a348b

Please sign in to comment.