summaryrefslogtreecommitdiffstats
path: root/vendor/tracing-attributes/tests
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
commitdc0db358abe19481e475e10c32149b53370f1a1c (patch)
treeab8ce99c4b255ce46f99ef402c27916055b899ee /vendor/tracing-attributes/tests
parentReleasing progress-linux version 1.71.1+dfsg1-2~progress7.99u1. (diff)
downloadrustc-dc0db358abe19481e475e10c32149b53370f1a1c.tar.xz
rustc-dc0db358abe19481e475e10c32149b53370f1a1c.zip
Merging upstream version 1.72.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/tracing-attributes/tests')
-rw-r--r--vendor/tracing-attributes/tests/async_fn.rs26
-rw-r--r--vendor/tracing-attributes/tests/err.rs73
-rw-r--r--vendor/tracing-attributes/tests/follows_from.rs2
-rw-r--r--vendor/tracing-attributes/tests/instrument.rs2
-rw-r--r--vendor/tracing-attributes/tests/levels.rs46
-rw-r--r--vendor/tracing-attributes/tests/ret.rs52
-rw-r--r--vendor/tracing-attributes/tests/ui.rs7
-rw-r--r--vendor/tracing-attributes/tests/ui/async_instrument.stderr8
-rw-r--r--vendor/tracing-attributes/tests/ui/const_instrument.rs8
-rw-r--r--vendor/tracing-attributes/tests/ui/const_instrument.stderr15
10 files changed, 234 insertions, 5 deletions
diff --git a/vendor/tracing-attributes/tests/async_fn.rs b/vendor/tracing-attributes/tests/async_fn.rs
index c89963672..d6d874ffd 100644
--- a/vendor/tracing-attributes/tests/async_fn.rs
+++ b/vendor/tracing-attributes/tests/async_fn.rs
@@ -90,6 +90,8 @@ fn async_fn_only_enters_for_polls() {
.exit(span::mock().named("test_async_fn"))
.enter(span::mock().named("test_async_fn"))
.exit(span::mock().named("test_async_fn"))
+ .enter(span::mock().named("test_async_fn"))
+ .exit(span::mock().named("test_async_fn"))
.drop_span(span::mock().named("test_async_fn"))
.done()
.run_with_handle();
@@ -120,8 +122,12 @@ fn async_fn_nested() {
.enter(span2.clone())
.event(event::mock().with_fields(field::mock("nested").with_value(&true)))
.exit(span2.clone())
+ .enter(span2.clone())
+ .exit(span2.clone())
.drop_span(span2)
.exit(span.clone())
+ .enter(span.clone())
+ .exit(span.clone())
.drop_span(span)
.done()
.run_with_handle();
@@ -199,13 +205,19 @@ fn async_fn_with_async_trait() {
.enter(span3.clone())
.event(event::mock().with_fields(field::mock("val").with_value(&2u64)))
.exit(span3.clone())
+ .enter(span3.clone())
+ .exit(span3.clone())
.drop_span(span3)
.new_span(span2.clone().with_field(field::mock("self")))
.enter(span2.clone())
.event(event::mock().with_fields(field::mock("val").with_value(&5u64)))
.exit(span2.clone())
+ .enter(span2.clone())
+ .exit(span2.clone())
.drop_span(span2)
.exit(span.clone())
+ .enter(span.clone())
+ .exit(span.clone())
.drop_span(span)
.done()
.run_with_handle();
@@ -256,6 +268,8 @@ fn async_fn_with_async_trait_and_fields_expressions() {
)
.enter(span.clone())
.exit(span.clone())
+ .enter(span.clone())
+ .exit(span.clone())
.drop_span(span)
.done()
.run_with_handle();
@@ -331,8 +345,12 @@ fn async_fn_with_async_trait_and_fields_expressions_with_generic_parameter() {
.with_field(field::mock("Self").with_value(&std::any::type_name::<TestImpl>())),
)
.enter(span4.clone())
+ .exit(span4.clone())
+ .enter(span4.clone())
.exit(span4)
.exit(span2.clone())
+ .enter(span2.clone())
+ .exit(span2.clone())
.drop_span(span2)
.new_span(
span3
@@ -341,6 +359,8 @@ fn async_fn_with_async_trait_and_fields_expressions_with_generic_parameter() {
)
.enter(span3.clone())
.exit(span3.clone())
+ .enter(span3.clone())
+ .exit(span3.clone())
.drop_span(span3)
.done()
.run_with_handle();
@@ -382,6 +402,8 @@ fn out_of_scope_fields() {
.new_span(span.clone())
.enter(span.clone())
.exit(span.clone())
+ .enter(span.clone())
+ .exit(span.clone())
.drop_span(span)
.done()
.run_with_handle();
@@ -417,6 +439,8 @@ fn manual_impl_future() {
.enter(span.clone())
.event(poll_event())
.exit(span.clone())
+ .enter(span.clone())
+ .exit(span.clone())
.drop_span(span)
.done()
.run_with_handle();
@@ -448,6 +472,8 @@ fn manual_box_pin() {
.enter(span.clone())
.event(poll_event())
.exit(span.clone())
+ .enter(span.clone())
+ .exit(span.clone())
.drop_span(span)
.done()
.run_with_handle();
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();
+}
diff --git a/vendor/tracing-attributes/tests/follows_from.rs b/vendor/tracing-attributes/tests/follows_from.rs
index da0eec635..a589409de 100644
--- a/vendor/tracing-attributes/tests/follows_from.rs
+++ b/vendor/tracing-attributes/tests/follows_from.rs
@@ -58,6 +58,8 @@ fn follows_from_async_test() {
.follows_from(consequence.clone(), cause_b)
.follows_from(consequence.clone(), cause_c)
.enter(consequence.clone())
+ .exit(consequence.clone())
+ .enter(consequence.clone())
.exit(consequence)
.done()
.run_with_handle();
diff --git a/vendor/tracing-attributes/tests/instrument.rs b/vendor/tracing-attributes/tests/instrument.rs
index 768692748..b215b8455 100644
--- a/vendor/tracing-attributes/tests/instrument.rs
+++ b/vendor/tracing-attributes/tests/instrument.rs
@@ -17,7 +17,7 @@ fn override_everything() {
#[instrument(target = "my_target", level = "debug")]
fn my_fn() {}
- #[instrument(level = "debug", target = "my_target")]
+ #[instrument(level = Level::DEBUG, target = "my_target")]
fn my_other_fn() {}
let span = span::mock()
diff --git a/vendor/tracing-attributes/tests/levels.rs b/vendor/tracing-attributes/tests/levels.rs
index b074ea4f2..94fc7e85a 100644
--- a/vendor/tracing-attributes/tests/levels.rs
+++ b/vendor/tracing-attributes/tests/levels.rs
@@ -94,3 +94,49 @@ fn numeric_levels() {
handle.assert_finished();
}
+
+#[test]
+fn enum_levels() {
+ #[instrument(level = Level::TRACE)]
+ fn trace() {}
+
+ #[instrument(level = Level::DEBUG)]
+ fn debug() {}
+
+ #[instrument(level = tracing::Level::INFO)]
+ fn info() {}
+
+ #[instrument(level = Level::WARN)]
+ fn warn() {}
+
+ #[instrument(level = Level::ERROR)]
+ fn error() {}
+ let (subscriber, handle) = subscriber::mock()
+ .new_span(span::mock().named("trace").at_level(Level::TRACE))
+ .enter(span::mock().named("trace").at_level(Level::TRACE))
+ .exit(span::mock().named("trace").at_level(Level::TRACE))
+ .new_span(span::mock().named("debug").at_level(Level::DEBUG))
+ .enter(span::mock().named("debug").at_level(Level::DEBUG))
+ .exit(span::mock().named("debug").at_level(Level::DEBUG))
+ .new_span(span::mock().named("info").at_level(Level::INFO))
+ .enter(span::mock().named("info").at_level(Level::INFO))
+ .exit(span::mock().named("info").at_level(Level::INFO))
+ .new_span(span::mock().named("warn").at_level(Level::WARN))
+ .enter(span::mock().named("warn").at_level(Level::WARN))
+ .exit(span::mock().named("warn").at_level(Level::WARN))
+ .new_span(span::mock().named("error").at_level(Level::ERROR))
+ .enter(span::mock().named("error").at_level(Level::ERROR))
+ .exit(span::mock().named("error").at_level(Level::ERROR))
+ .done()
+ .run_with_handle();
+
+ with_default(subscriber, || {
+ trace();
+ debug();
+ info();
+ warn();
+ error();
+ });
+
+ handle.assert_finished();
+}
diff --git a/vendor/tracing-attributes/tests/ret.rs b/vendor/tracing-attributes/tests/ret.rs
index cfd2de10d..f56c80baa 100644
--- a/vendor/tracing-attributes/tests/ret.rs
+++ b/vendor/tracing-attributes/tests/ret.rs
@@ -138,6 +138,8 @@ fn test_async() {
.at_level(Level::INFO),
)
.exit(span.clone())
+ .enter(span.clone())
+ .exit(span.clone())
.drop_span(span)
.done()
.run_with_handle();
@@ -253,3 +255,53 @@ fn test_ret_and_ok() {
with_default(subscriber, || ret_and_ok().ok());
handle.assert_finished();
}
+
+#[instrument(level = "warn", ret(level = "info"))]
+fn ret_warn_info() -> i32 {
+ 42
+}
+
+#[test]
+fn test_warn_info() {
+ let span = span::mock().named("ret_warn_info").at_level(Level::WARN);
+ let (subscriber, handle) = subscriber::mock()
+ .new_span(span.clone())
+ .enter(span.clone())
+ .event(
+ event::mock()
+ .with_fields(field::mock("return").with_value(&tracing::field::debug(42)))
+ .at_level(Level::INFO),
+ )
+ .exit(span.clone())
+ .drop_span(span)
+ .done()
+ .run_with_handle();
+
+ with_default(subscriber, ret_warn_info);
+ handle.assert_finished();
+}
+
+#[instrument(ret(level = "warn", Debug))]
+fn ret_dbg_warn() -> i32 {
+ 42
+}
+
+#[test]
+fn test_dbg_warn() {
+ let span = span::mock().named("ret_dbg_warn").at_level(Level::INFO);
+ let (subscriber, handle) = subscriber::mock()
+ .new_span(span.clone())
+ .enter(span.clone())
+ .event(
+ event::mock()
+ .with_fields(field::mock("return").with_value(&tracing::field::debug(42)))
+ .at_level(Level::WARN),
+ )
+ .exit(span.clone())
+ .drop_span(span)
+ .done()
+ .run_with_handle();
+
+ with_default(subscriber, ret_dbg_warn);
+ handle.assert_finished();
+}
diff --git a/vendor/tracing-attributes/tests/ui.rs b/vendor/tracing-attributes/tests/ui.rs
index f11cc019e..73d7fdcef 100644
--- a/vendor/tracing-attributes/tests/ui.rs
+++ b/vendor/tracing-attributes/tests/ui.rs
@@ -5,3 +5,10 @@ fn async_instrument() {
let t = trybuild::TestCases::new();
t.compile_fail("tests/ui/async_instrument.rs");
}
+
+#[rustversion::stable]
+#[test]
+fn const_instrument() {
+ let t = trybuild::TestCases::new();
+ t.compile_fail("tests/ui/const_instrument.rs");
+}
diff --git a/vendor/tracing-attributes/tests/ui/async_instrument.stderr b/vendor/tracing-attributes/tests/ui/async_instrument.stderr
index db6f6b434..2c64b0c15 100644
--- a/vendor/tracing-attributes/tests/ui/async_instrument.stderr
+++ b/vendor/tracing-attributes/tests/ui/async_instrument.stderr
@@ -16,7 +16,7 @@ error[E0308]: mismatched types
10 | ""
| ^^- help: try using a conversion method: `.to_string()`
| |
- | expected struct `String`, found `&str`
+ | expected `String`, found `&str`
|
note: return type inferred to be `String` here
--> tests/ui/async_instrument.rs:9:31
@@ -47,7 +47,7 @@ error[E0308]: mismatched types
--> tests/ui/async_instrument.rs:23:5
|
23 | ""
- | ^^ expected struct `Wrapper`, found `&str`
+ | ^^ expected `Wrapper<_>`, found `&str`
|
= note: expected struct `Wrapper<_>`
found reference `&'static str`
@@ -79,7 +79,7 @@ error[E0308]: mismatched types
36 | return "";
| ^^- help: try using a conversion method: `.to_string()`
| |
- | expected struct `String`, found `&str`
+ | expected `String`, found `&str`
|
note: return type inferred to be `String` here
--> tests/ui/async_instrument.rs:34:28
@@ -93,6 +93,6 @@ error[E0308]: mismatched types
42 | async fn extra_semicolon() -> i32 {
| ___________________________________^
43 | | 1;
- | | - help: remove this semicolon
+ | | - help: remove this semicolon to return this value
44 | | }
| |_^ expected `i32`, found `()`
diff --git a/vendor/tracing-attributes/tests/ui/const_instrument.rs b/vendor/tracing-attributes/tests/ui/const_instrument.rs
new file mode 100644
index 000000000..a251e8f66
--- /dev/null
+++ b/vendor/tracing-attributes/tests/ui/const_instrument.rs
@@ -0,0 +1,8 @@
+#![allow(unreachable_code)]
+
+#[tracing::instrument]
+const fn unit() {
+ ""
+}
+
+fn main() {}
diff --git a/vendor/tracing-attributes/tests/ui/const_instrument.stderr b/vendor/tracing-attributes/tests/ui/const_instrument.stderr
new file mode 100644
index 000000000..e76d4acad
--- /dev/null
+++ b/vendor/tracing-attributes/tests/ui/const_instrument.stderr
@@ -0,0 +1,15 @@
+error: macros that expand to items must be delimited with braces or followed by a semicolon
+ --> tests/ui/const_instrument.rs:3:1
+ |
+3 | #[tracing::instrument]
+ | ^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: this error originates in the attribute macro `tracing::instrument` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: the `#[instrument]` attribute may not be used with `const fn`s
+ --> tests/ui/const_instrument.rs:3:1
+ |
+3 | #[tracing::instrument]
+ | ^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: this error originates in the attribute macro `tracing::instrument` (in Nightly builds, run with -Z macro-backtrace for more info)