Skip to content

Commit

Permalink
fixup tests for combined from and backtrace
Browse files Browse the repository at this point in the history
  • Loading branch information
astraw committed Jun 13, 2021
1 parent 52dc286 commit cd2b9db
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions tests/test_backtrace.rs
Expand Up @@ -6,9 +6,16 @@ use thiserror::Error;
#[error("...")]
pub struct Inner;

#[cfg(thiserror_nightly_testing)]
#[derive(Error, Debug)]
#[error("...")]
pub struct InnerBacktrace {
backtrace: std::backtrace::Backtrace,
}

#[cfg(thiserror_nightly_testing)]
pub mod structs {
use super::Inner;
use super::{Inner, InnerBacktrace};
use std::backtrace::Backtrace;
use std::error::Error;
use std::sync::Arc;
Expand Down Expand Up @@ -55,7 +62,7 @@ pub mod structs {
pub struct CombinedBacktraceFrom {
#[from]
#[backtrace]
source: Inner,
source: InnerBacktrace,
}

#[derive(Error, Debug)]
Expand Down Expand Up @@ -101,7 +108,9 @@ pub mod structs {
let error = BacktraceFrom::from(Inner);
assert!(error.backtrace().is_some());

let error = CombinedBacktraceFrom::from(Inner);
let error = CombinedBacktraceFrom::from(InnerBacktrace {
backtrace: Backtrace::capture(),
});
assert!(error.backtrace().is_some());

let error = OptBacktraceFrom::from(Inner);
Expand All @@ -114,7 +123,7 @@ pub mod structs {

#[cfg(thiserror_nightly_testing)]
pub mod enums {
use super::Inner;
use super::{Inner, InnerBacktrace};
use std::backtrace::Backtrace;
use std::error::Error;
use std::sync::Arc;
Expand Down Expand Up @@ -170,7 +179,7 @@ pub mod enums {
Test {
#[from]
#[backtrace]
source: Inner,
source: InnerBacktrace,
},
}

Expand Down Expand Up @@ -221,7 +230,9 @@ pub mod enums {
let error = BacktraceFrom::from(Inner);
assert!(error.backtrace().is_some());

let error = CombinedBacktraceFrom::from(Inner);
let error = CombinedBacktraceFrom::from(InnerBacktrace {
backtrace: Backtrace::capture(),
});
assert!(error.backtrace().is_some());

let error = OptBacktraceFrom::from(Inner);
Expand Down

0 comments on commit cd2b9db

Please sign in to comment.