bug cleanup related to error handling (#552)
* cleanup error handling fixes
This commit is contained in:
parent
71de6de701
commit
f3dd24bb3c
|
|
@ -49,12 +49,14 @@ static GET_TIP_TRANSCRIPT: Lazy<Vec<(Request, Response)>> = Lazy::new(|| {
|
||||||
});
|
});
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
|
#[spandoc::spandoc]
|
||||||
async fn check_transcripts() -> Result<(), Report> {
|
async fn check_transcripts() -> Result<(), Report> {
|
||||||
zebra_test::init();
|
zebra_test::init();
|
||||||
|
|
||||||
for transcript_data in &[&ADD_BLOCK_TRANSCRIPT, &GET_TIP_TRANSCRIPT] {
|
for transcript_data in &[&ADD_BLOCK_TRANSCRIPT, &GET_TIP_TRANSCRIPT] {
|
||||||
let service = in_memory::init();
|
let service = in_memory::init();
|
||||||
let transcript = Transcript::from(transcript_data.iter().cloned());
|
let transcript = Transcript::from(transcript_data.iter().cloned());
|
||||||
|
/// SPANDOC: check the in memory service against the transcript
|
||||||
transcript.check(service).await?;
|
transcript.check(service).await?;
|
||||||
|
|
||||||
let storage_guard = TempDir::new("")?;
|
let storage_guard = TempDir::new("")?;
|
||||||
|
|
@ -62,6 +64,7 @@ async fn check_transcripts() -> Result<(), Report> {
|
||||||
path: storage_guard.path().to_owned(),
|
path: storage_guard.path().to_owned(),
|
||||||
});
|
});
|
||||||
let transcript = Transcript::from(transcript_data.iter().cloned());
|
let transcript = Transcript::from(transcript_data.iter().cloned());
|
||||||
|
/// SPANDOC: check the on disk service against the transcript
|
||||||
transcript.check(service).await?;
|
transcript.check(service).await?;
|
||||||
// Delete the contents of the temp directory before going to the next case.
|
// Delete the contents of the temp directory before going to the next case.
|
||||||
std::mem::drop(storage_guard);
|
std::mem::drop(storage_guard);
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,47 @@ pub fn init() {
|
||||||
.with(ErrorLayer::default())
|
.with(ErrorLayer::default())
|
||||||
.init();
|
.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();
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue