bug cleanup related to error handling (#552)

* cleanup error handling fixes
This commit is contained in:
Jane Lusby 2020-07-17 15:19:00 -07:00 committed by GitHub
parent 71de6de701
commit f3dd24bb3c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 44 additions and 1 deletions

View File

@ -49,12 +49,14 @@ static GET_TIP_TRANSCRIPT: Lazy<Vec<(Request, Response)>> = Lazy::new(|| {
});
#[tokio::test]
#[spandoc::spandoc]
async fn check_transcripts() -> Result<(), Report> {
zebra_test::init();
for transcript_data in &[&ADD_BLOCK_TRANSCRIPT, &GET_TIP_TRANSCRIPT] {
let service = in_memory::init();
let transcript = Transcript::from(transcript_data.iter().cloned());
/// SPANDOC: check the in memory service against the transcript
transcript.check(service).await?;
let storage_guard = TempDir::new("")?;
@ -62,6 +64,7 @@ async fn check_transcripts() -> Result<(), Report> {
path: storage_guard.path().to_owned(),
});
let transcript = Transcript::from(transcript_data.iter().cloned());
/// SPANDOC: check the on disk service against the transcript
transcript.check(service).await?;
// Delete the contents of the temp directory before going to the next case.
std::mem::drop(storage_guard);

View File

@ -20,7 +20,47 @@ pub fn init() {
.with(ErrorLayer::default())
.init();
color_eyre::install().unwrap();
color_eyre::config::HookBuilder::default()
.add_frame_filter(Box::new(|frames| {
let mut displayed = std::collections::HashSet::new();
let filters = &[
"tokio::",
"<futures_util::",
"std::panic",
"test::run_test_in_process",
"core::ops::function::FnOnce::call_once",
"std::thread::local",
"<core::future::",
"<alloc::boxed::Box",
"<std::panic::AssertUnwindSafe",
"core::result::Result",
"<T as futures_util",
"<tracing_futures::Instrumented",
"test::assert_test_result",
"spandoc::",
];
frames.retain(|frame| {
let loc = (frame.lineno, &frame.filename);
let inserted = displayed.insert(loc);
if !inserted {
return false;
}
!filters.iter().any(|f| {
let name = if let Some(name) = frame.name.as_ref() {
name.as_str()
} else {
return true;
};
name.starts_with(f)
})
});
}))
.install()
.unwrap();
})
}