Skip to content

Commit

Permalink
Fix anyhow test to support backtraces (#1011)
Browse files Browse the repository at this point in the history
  • Loading branch information
TimDiekmann authored Aug 31, 2022
1 parent e44ad8e commit 3491d95
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions packages/libs/error-stack/tests/test_compatibility.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 3491d95

Please sign in to comment.