From 165c57f0a49ac6239e65eece9af155c66c2bc27b Mon Sep 17 00:00:00 2001 From: Hocuri Date: Wed, 3 Mar 2021 11:09:06 +0100 Subject: [PATCH] Rust-tests: Don't panic while panicking --- src/test_utils.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/test_utils.rs b/src/test_utils.rs index 3957a39dd..c5cee1540 100644 --- a/src/test_utils.rs +++ b/src/test_utils.rs @@ -2,11 +2,11 @@ //! //! This private module is only compiled for test runs. -use std::fmt; use std::ops::Deref; use std::str::FromStr; use std::time::{Duration, Instant}; use std::{collections::BTreeMap, panic}; +use std::{fmt, thread}; use ansi_term::Color; use async_std::future::Future; @@ -423,8 +423,10 @@ impl Deref for TestContext { impl Drop for TestContext { fn drop(&mut self) { - if let Ok(p) = self.poison_receiver.try_recv() { - panic!(p); + if !thread::panicking() { + if let Ok(p) = self.poison_receiver.try_recv() { + panic!(p); + } } } }