From 3491d9574d4e9dc34d91b8d6b2805e3ded7152e0 Mon Sep 17 00:00:00 2001 From: Tim Diekmann <21277928+TimDiekmann@users.noreply.github.com> Date: Wed, 31 Aug 2022 16:20:36 +0200 Subject: [PATCH] Fix `anyhow` test to support backtraces (#1011) --- packages/libs/error-stack/tests/test_compatibility.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/packages/libs/error-stack/tests/test_compatibility.rs b/packages/libs/error-stack/tests/test_compatibility.rs index 33bc9f72967..89d94247f89 100644 --- a/packages/libs/error-stack/tests/test_compatibility.rs +++ b/packages/libs/error-stack/tests/test_compatibility.rs @@ -50,20 +50,17 @@ fn anyhow() { #[allow(unused_mut)] let mut report_messages = messages(&report); - // Backtrace from anyhow cannot be captured currently until `Error::provide` is implemented. - // Previously, `backtrace` was a function on `Error`, but this was removed, so it has to be - // provided by the Provider API. + // Backtrace is provided through `anyhow::Error` by `Error::provide` #[cfg(all(rust_1_65, feature = "std"))] - remove_backtrace_context(&mut report_messages); + if has_backtrace(&anyhow) { + remove_backtrace_context(&mut report_messages); + } let anyhow_report = anyhow.into_report().unwrap_err(); #[allow(unused_mut)] let mut anyhow_messages = messages(&anyhow_report); - #[cfg(all(rust_1_65, feature = "std"))] - remove_backtrace_context(&mut anyhow_messages); - for (anyhow, error_stack) in anyhow_messages.into_iter().rev().zip(report_messages) { assert_eq!(anyhow, error_stack); }