MCPcopy Create free account
hub / github.com/hashintel/hash / provided

Function provided

libs/error-stack/tests/test_span_trace.rs:56–91  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

54
55#[test]
56fn provided() {
57 #[tracing::instrument]
58 fn func_b() -> ErrorA {
59 ErrorA::new(0)
60 }
61
62 #[tracing::instrument]
63 fn func_a() -> Result<(), Report<ErrorA>> {
64 Err(Report::new(func_b()))
65 }
66
67 install_tracing_subscriber();
68
69 let report = capture_error(func_a);
70 #[cfg(nightly)]
71 let span_trace = report
72 .request_ref::<SpanTrace>()
73 .next()
74 .expect("No span trace captured");
75 #[cfg(not(nightly))]
76 let span_trace = report
77 .downcast_ref::<SpanTrace>()
78 .expect("No span trace captured");
79
80 let mut num_spans = 0;
81 span_trace.with_spans(|_, _| {
82 num_spans += 1;
83 true
84 });
85
86 #[cfg(not(nightly))]
87 assert_eq!(num_spans, 1);
88
89 #[cfg(nightly)]
90 assert_eq!(num_spans, 2);
91}

Callers

nothing calls this directly

Calls 4

capture_errorFunction · 0.85
expectMethod · 0.45
nextMethod · 0.45

Tested by

no test coverage detected