mirror of
https://github.com/eyre-rs/eyre.git
synced 2025-09-29 05:52:13 +00:00

* Add must-install feature, so that a non-default handler can be the only handler consuming .text. * Provide a better panic message if `must-install` feature is enabled. Co-authored-by: Jane Lusby <jlusby42@gmail.com> * Bump version because new feature was added. * Convert must-install feature to auto-install to avoid negative features. * Add ability to manually install DefaultHandler (for when auto-install is disabled). * Ensure doctests pass when auto-install feature is disabled. * Integration tests now succeed without auto-install feature. * Add integration test for when auto-install feature is disabled. * Add auto-install feature testing to CI. * cargo fmt. Co-authored-by: Jane Lusby <jlusby42@gmail.com> Co-authored-by: Jane Lusby <jlusby@yaah.dev>
55 lines
1.5 KiB
Rust
55 lines
1.5 KiB
Rust
mod common;
|
|
|
|
use self::common::maybe_install_handler;
|
|
use eyre::{eyre, Report};
|
|
|
|
fn error() -> Report {
|
|
eyre!({ 0 }).wrap_err(1).wrap_err(2).wrap_err(3)
|
|
}
|
|
|
|
#[test]
|
|
fn test_iter() {
|
|
maybe_install_handler().unwrap();
|
|
|
|
let e = error();
|
|
let mut chain = e.chain();
|
|
assert_eq!("3", chain.next().unwrap().to_string());
|
|
assert_eq!("2", chain.next().unwrap().to_string());
|
|
assert_eq!("1", chain.next().unwrap().to_string());
|
|
assert_eq!("0", chain.next().unwrap().to_string());
|
|
assert!(chain.next().is_none());
|
|
assert!(chain.next_back().is_none());
|
|
}
|
|
|
|
#[test]
|
|
fn test_rev() {
|
|
maybe_install_handler().unwrap();
|
|
|
|
let e = error();
|
|
let mut chain = e.chain().rev();
|
|
assert_eq!("0", chain.next().unwrap().to_string());
|
|
assert_eq!("1", chain.next().unwrap().to_string());
|
|
assert_eq!("2", chain.next().unwrap().to_string());
|
|
assert_eq!("3", chain.next().unwrap().to_string());
|
|
assert!(chain.next().is_none());
|
|
assert!(chain.next_back().is_none());
|
|
}
|
|
|
|
#[test]
|
|
fn test_len() {
|
|
maybe_install_handler().unwrap();
|
|
|
|
let e = error();
|
|
let mut chain = e.chain();
|
|
assert_eq!(4, chain.len());
|
|
assert_eq!("3", chain.next().unwrap().to_string());
|
|
assert_eq!(3, chain.len());
|
|
assert_eq!("0", chain.next_back().unwrap().to_string());
|
|
assert_eq!(2, chain.len());
|
|
assert_eq!("2", chain.next().unwrap().to_string());
|
|
assert_eq!(1, chain.len());
|
|
assert_eq!("1", chain.next_back().unwrap().to_string());
|
|
assert_eq!(0, chain.len());
|
|
assert!(chain.next().is_none());
|
|
}
|