summaryrefslogtreecommitdiffstats
path: root/vendor/tracing-attributes/tests/err.rs
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/tracing-attributes/tests/err.rs')
-rw-r--r--vendor/tracing-attributes/tests/err.rs73
1 files changed, 73 insertions, 0 deletions
diff --git a/vendor/tracing-attributes/tests/err.rs b/vendor/tracing-attributes/tests/err.rs
index 9e6d6b78c..485dd1196 100644
--- a/vendor/tracing-attributes/tests/err.rs
+++ b/vendor/tracing-attributes/tests/err.rs
@@ -57,6 +57,8 @@ fn test_async() {
.enter(span.clone())
.event(event::mock().at_level(Level::ERROR))
.exit(span.clone())
+ .enter(span.clone())
+ .exit(span.clone())
.drop_span(span)
.done()
.run_with_handle();
@@ -111,6 +113,8 @@ fn test_mut_async() {
.enter(span.clone())
.event(event::mock().at_level(Level::ERROR))
.exit(span.clone())
+ .enter(span.clone())
+ .exit(span.clone())
.drop_span(span)
.done()
.run_with_handle();
@@ -231,3 +235,72 @@ fn test_err_custom_target() {
});
handle.assert_finished();
}
+
+#[instrument(err(level = "info"))]
+fn err_info() -> Result<u8, TryFromIntError> {
+ u8::try_from(1234)
+}
+
+#[test]
+fn test_err_info() {
+ let span = span::mock().named("err_info");
+ let (subscriber, handle) = subscriber::mock()
+ .new_span(span.clone())
+ .enter(span.clone())
+ .event(event::mock().at_level(Level::INFO))
+ .exit(span.clone())
+ .drop_span(span)
+ .done()
+ .run_with_handle();
+ with_default(subscriber, || err_info().ok());
+ handle.assert_finished();
+}
+
+#[instrument(err(Debug, level = "info"))]
+fn err_dbg_info() -> Result<u8, TryFromIntError> {
+ u8::try_from(1234)
+}
+
+#[test]
+fn test_err_dbg_info() {
+ let span = span::mock().named("err_dbg_info");
+ let (subscriber, handle) = subscriber::mock()
+ .new_span(span.clone())
+ .enter(span.clone())
+ .event(
+ event::mock().at_level(Level::INFO).with_fields(
+ field::mock("error")
+ // use the actual error value that will be emitted, so
+ // that this test doesn't break if the standard library
+ // changes the `fmt::Debug` output from the error type
+ // in the future.
+ .with_value(&tracing::field::debug(u8::try_from(1234).unwrap_err())),
+ ),
+ )
+ .exit(span.clone())
+ .drop_span(span)
+ .done()
+ .run_with_handle();
+ with_default(subscriber, || err_dbg_info().ok());
+ handle.assert_finished();
+}
+
+#[instrument(level = "warn", err(level = "info"))]
+fn err_warn_info() -> Result<u8, TryFromIntError> {
+ u8::try_from(1234)
+}
+
+#[test]
+fn test_err_warn_info() {
+ let span = span::mock().named("err_warn_info").at_level(Level::WARN);
+ let (subscriber, handle) = subscriber::mock()
+ .new_span(span.clone())
+ .enter(span.clone())
+ .event(event::mock().at_level(Level::INFO))
+ .exit(span.clone())
+ .drop_span(span)
+ .done()
+ .run_with_handle();
+ with_default(subscriber, || err_warn_info().ok());
+ handle.assert_finished();
+}