diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-07 05:48:48 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-07 05:48:48 +0000 |
commit | ef24de24a82fe681581cc130f342363c47c0969a (patch) | |
tree | 0d494f7e1a38b95c92426f58fe6eaa877303a86c /vendor/tracing/tests | |
parent | Releasing progress-linux version 1.74.1+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-ef24de24a82fe681581cc130f342363c47c0969a.tar.xz rustc-ef24de24a82fe681581cc130f342363c47c0969a.zip |
Merging upstream version 1.75.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | vendor/tracing-0.1.37/tests/macros_redefined_core.rs (renamed from vendor/tracing/tests/macros_redefined_core.rs) | 0 | ||||
-rw-r--r-- | vendor/tracing/tests/enabled.rs | 4 | ||||
-rw-r--r-- | vendor/tracing/tests/event.rs | 208 | ||||
-rw-r--r-- | vendor/tracing/tests/filters_dont_leak.rs | 12 | ||||
-rw-r--r-- | vendor/tracing/tests/instrument.rs | 59 | ||||
-rw-r--r-- | vendor/tracing/tests/macros.rs | 624 | ||||
-rw-r--r-- | vendor/tracing/tests/max_level_hint.rs | 8 | ||||
-rw-r--r-- | vendor/tracing/tests/multiple_max_level_hints.rs | 18 | ||||
-rw-r--r-- | vendor/tracing/tests/no_subscriber.rs | 9 | ||||
-rw-r--r-- | vendor/tracing/tests/scoped_clobbers_default.rs | 4 | ||||
-rw-r--r-- | vendor/tracing/tests/span.rs | 385 | ||||
-rw-r--r-- | vendor/tracing/tests/subscriber.rs | 31 |
12 files changed, 913 insertions, 449 deletions
diff --git a/vendor/tracing/tests/macros_redefined_core.rs b/vendor/tracing-0.1.37/tests/macros_redefined_core.rs index d830dcdb0..d830dcdb0 100644 --- a/vendor/tracing/tests/macros_redefined_core.rs +++ b/vendor/tracing-0.1.37/tests/macros_redefined_core.rs diff --git a/vendor/tracing/tests/enabled.rs b/vendor/tracing/tests/enabled.rs index ea1c69804..5a4596347 100644 --- a/vendor/tracing/tests/enabled.rs +++ b/vendor/tracing/tests/enabled.rs @@ -13,7 +13,7 @@ fn level_and_target() { meta.level() <= &Level::INFO } }) - .done() + .only() .run(); let _guard = tracing::subscriber::set_default(subscriber); @@ -38,7 +38,7 @@ fn span_and_event() { meta.level() <= &Level::INFO } }) - .done() + .only() .run(); let _guard = tracing::subscriber::set_default(subscriber); diff --git a/vendor/tracing/tests/event.rs b/vendor/tracing/tests/event.rs index 61df19ad3..0be7c0bc5 100644 --- a/vendor/tracing/tests/event.rs +++ b/vendor/tracing/tests/event.rs @@ -22,17 +22,17 @@ macro_rules! event_without_message { fn $name() { let (subscriber, handle) = subscriber::mock() .event( - event::mock().with_fields( - field::mock("answer") + expect::event().with_fields( + expect::field("answer") .with_value(&42) .and( - field::mock("to_question") + expect::field("to_question") .with_value(&"life, the universe, and everything"), ) .only(), ), ) - .done() + .only() .run_with_handle(); with_default(subscriber, || { @@ -57,15 +57,19 @@ event_without_message! {nonzeroi32_event_without_message: std::num::NonZeroI32:: #[test] fn event_with_message() { let (subscriber, handle) = subscriber::mock() - .event(event::msg(format_args!( - "hello from my event! yak shaved = {:?}", - true - ))) - .done() + .event( + expect::event().with_fields(expect::field("message").with_value( + &tracing::field::debug(format_args!( + "hello from my tracing::event! yak shaved = {:?}", + true + )), + )), + ) + .only() .run_with_handle(); with_default(subscriber, || { - debug!("hello from my event! yak shaved = {:?}", true); + debug!("hello from my tracing::event! yak shaved = {:?}", true); }); handle.assert_finished(); @@ -76,10 +80,12 @@ fn event_with_message() { fn message_without_delims() { let (subscriber, handle) = subscriber::mock() .event( - event::mock().with_fields( - field::mock("answer") + expect::event().with_fields( + expect::field("answer") .with_value(&42) - .and(field::mock("question").with_value(&"life, the universe, and everything")) + .and( + expect::field("question").with_value(&"life, the universe, and everything"), + ) .and(field::msg(format_args!( "hello from my event! tricky? {:?}!", true @@ -87,7 +93,7 @@ fn message_without_delims() { .only(), ), ) - .done() + .only() .run_with_handle(); with_default(subscriber, || { @@ -103,15 +109,17 @@ fn message_without_delims() { fn string_message_without_delims() { let (subscriber, handle) = subscriber::mock() .event( - event::mock().with_fields( - field::mock("answer") + expect::event().with_fields( + expect::field("answer") .with_value(&42) - .and(field::mock("question").with_value(&"life, the universe, and everything")) + .and( + expect::field("question").with_value(&"life, the universe, and everything"), + ) .and(field::msg(format_args!("hello from my event"))) .only(), ), ) - .done() + .only() .run_with_handle(); with_default(subscriber, || { @@ -127,23 +135,23 @@ fn string_message_without_delims() { fn one_with_everything() { let (subscriber, handle) = subscriber::mock() .event( - event::mock() + expect::event() .with_fields( - field::mock("message") + expect::field("message") .with_value(&tracing::field::debug(format_args!( "{:#x} make me one with{what:.>20}", 4_277_009_102u64, what = "everything" ))) - .and(field::mock("foo").with_value(&666)) - .and(field::mock("bar").with_value(&false)) - .and(field::mock("like_a_butterfly").with_value(&42.0)) + .and(expect::field("foo").with_value(&666)) + .and(expect::field("bar").with_value(&false)) + .and(expect::field("like_a_butterfly").with_value(&42.0)) .only(), ) .at_level(Level::ERROR) .with_target("whatever"), ) - .done() + .only() .run_with_handle(); with_default(subscriber, || { @@ -163,13 +171,13 @@ fn one_with_everything() { fn moved_field() { let (subscriber, handle) = subscriber::mock() .event( - event::mock().with_fields( - field::mock("foo") + expect::event().with_fields( + expect::field("foo") .with_value(&display("hello from my event")) .only(), ), ) - .done() + .only() .run_with_handle(); with_default(subscriber, || { let from = "my event"; @@ -184,14 +192,14 @@ fn moved_field() { fn dotted_field_name() { let (subscriber, handle) = subscriber::mock() .event( - event::mock().with_fields( - field::mock("foo.bar") + expect::event().with_fields( + expect::field("foo.bar") .with_value(&true) - .and(field::mock("foo.baz").with_value(&false)) + .and(expect::field("foo.baz").with_value(&false)) .only(), ), ) - .done() + .only() .run_with_handle(); with_default(subscriber, || { tracing::event!(Level::INFO, foo.bar = true, foo.baz = false); @@ -205,13 +213,13 @@ fn dotted_field_name() { fn borrowed_field() { let (subscriber, handle) = subscriber::mock() .event( - event::mock().with_fields( - field::mock("foo") + expect::event().with_fields( + expect::field("foo") .with_value(&display("hello from my event")) .only(), ), ) - .done() + .only() .run_with_handle(); with_default(subscriber, || { let from = "my event"; @@ -242,15 +250,15 @@ fn move_field_out_of_struct() { }; let (subscriber, handle) = subscriber::mock() .event( - event::mock().with_fields( - field::mock("x") + expect::event().with_fields( + expect::field("x") .with_value(&debug(3.234)) - .and(field::mock("y").with_value(&debug(-1.223))) + .and(expect::field("y").with_value(&debug(-1.223))) .only(), ), ) - .event(event::mock().with_fields(field::mock("position").with_value(&debug(&pos)))) - .done() + .event(expect::event().with_fields(expect::field("position").with_value(&debug(&pos)))) + .only() .run_with_handle(); with_default(subscriber, || { @@ -269,13 +277,13 @@ fn move_field_out_of_struct() { fn display_shorthand() { let (subscriber, handle) = subscriber::mock() .event( - event::mock().with_fields( - field::mock("my_field") + expect::event().with_fields( + expect::field("my_field") .with_value(&display("hello world")) .only(), ), ) - .done() + .only() .run_with_handle(); with_default(subscriber, || { tracing::event!(Level::TRACE, my_field = %"hello world"); @@ -289,13 +297,13 @@ fn display_shorthand() { fn debug_shorthand() { let (subscriber, handle) = subscriber::mock() .event( - event::mock().with_fields( - field::mock("my_field") + expect::event().with_fields( + expect::field("my_field") .with_value(&debug("hello world")) .only(), ), ) - .done() + .only() .run_with_handle(); with_default(subscriber, || { tracing::event!(Level::TRACE, my_field = ?"hello world"); @@ -309,14 +317,14 @@ fn debug_shorthand() { fn both_shorthands() { let (subscriber, handle) = subscriber::mock() .event( - event::mock().with_fields( - field::mock("display_field") + expect::event().with_fields( + expect::field("display_field") .with_value(&display("hello world")) - .and(field::mock("debug_field").with_value(&debug("hello world"))) + .and(expect::field("debug_field").with_value(&debug("hello world"))) .only(), ), ) - .done() + .only() .run_with_handle(); with_default(subscriber, || { tracing::event!(Level::TRACE, display_field = %"hello world", debug_field = ?"hello world"); @@ -329,9 +337,9 @@ fn both_shorthands() { #[test] fn explicit_child() { let (subscriber, handle) = subscriber::mock() - .new_span(span::mock().named("foo")) - .event(event::mock().with_explicit_parent(Some("foo"))) - .done() + .new_span(expect::span().named("foo")) + .event(expect::event().with_explicit_parent(Some("foo"))) + .only() .run_with_handle(); with_default(subscriber, || { @@ -346,13 +354,13 @@ fn explicit_child() { #[test] fn explicit_child_at_levels() { let (subscriber, handle) = subscriber::mock() - .new_span(span::mock().named("foo")) - .event(event::mock().with_explicit_parent(Some("foo"))) - .event(event::mock().with_explicit_parent(Some("foo"))) - .event(event::mock().with_explicit_parent(Some("foo"))) - .event(event::mock().with_explicit_parent(Some("foo"))) - .event(event::mock().with_explicit_parent(Some("foo"))) - .done() + .new_span(expect::span().named("foo")) + .event(expect::event().with_explicit_parent(Some("foo"))) + .event(expect::event().with_explicit_parent(Some("foo"))) + .event(expect::event().with_explicit_parent(Some("foo"))) + .event(expect::event().with_explicit_parent(Some("foo"))) + .event(expect::event().with_explicit_parent(Some("foo"))) + .only() .run_with_handle(); with_default(subscriber, || { @@ -372,15 +380,15 @@ fn explicit_child_at_levels() { fn option_values() { let (subscriber, handle) = subscriber::mock() .event( - event::mock().with_fields( - field::mock("some_str") + expect::event().with_fields( + expect::field("some_str") .with_value(&"yes") - .and(field::mock("some_bool").with_value(&true)) - .and(field::mock("some_u64").with_value(&42_u64)) + .and(expect::field("some_bool").with_value(&true)) + .and(expect::field("some_u64").with_value(&42_u64)) .only(), ), ) - .done() + .only() .run_with_handle(); with_default(subscriber, || { @@ -408,15 +416,15 @@ fn option_values() { fn option_ref_values() { let (subscriber, handle) = subscriber::mock() .event( - event::mock().with_fields( - field::mock("some_str") + expect::event().with_fields( + expect::field("some_str") .with_value(&"yes") - .and(field::mock("some_bool").with_value(&true)) - .and(field::mock("some_u64").with_value(&42_u64)) + .and(expect::field("some_bool").with_value(&true)) + .and(expect::field("some_u64").with_value(&42_u64)) .only(), ), ) - .done() + .only() .run_with_handle(); with_default(subscriber, || { @@ -444,15 +452,15 @@ fn option_ref_values() { fn option_ref_mut_values() { let (subscriber, handle) = subscriber::mock() .event( - event::mock().with_fields( - field::mock("some_str") + expect::event().with_fields( + expect::field("some_str") .with_value(&"yes") - .and(field::mock("some_bool").with_value(&true)) - .and(field::mock("some_u64").with_value(&42_u64)) + .and(expect::field("some_bool").with_value(&true)) + .and(expect::field("some_u64").with_value(&42_u64)) .only(), ), ) - .done() + .only() .run_with_handle(); with_default(subscriber, || { @@ -479,11 +487,15 @@ fn option_ref_mut_values() { #[test] fn string_field() { let (subscriber, handle) = subscriber::mock() - .event(event::mock().with_fields(field::mock("my_string").with_value(&"hello").only())) + .event(expect::event().with_fields(expect::field("my_string").with_value(&"hello").only())) .event( - event::mock().with_fields(field::mock("my_string").with_value(&"hello world!").only()), + expect::event().with_fields( + expect::field("my_string") + .with_value(&"hello world!") + .only(), + ), ) - .done() + .only() .run_with_handle(); with_default(subscriber, || { let mut my_string = String::from("hello"); @@ -498,3 +510,45 @@ fn string_field() { handle.assert_finished(); } + +#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] +#[test] +fn constant_field_name() { + let expect_event = || { + expect::event().with_fields( + expect::field("foo") + .with_value(&"bar") + .and(expect::field("constant string").with_value(&"also works")) + .and(expect::field("foo.bar").with_value(&"baz")) + .and(expect::field("message").with_value(&debug(format_args!("quux")))) + .only(), + ) + }; + let (subscriber, handle) = subscriber::mock() + .event(expect_event()) + .event(expect_event()) + .only() + .run_with_handle(); + + with_default(subscriber, || { + const FOO: &str = "foo"; + tracing::event!( + Level::INFO, + { std::convert::identity(FOO) } = "bar", + { "constant string" } = "also works", + foo.bar = "baz", + "quux" + ); + tracing::event!( + Level::INFO, + { + { std::convert::identity(FOO) } = "bar", + { "constant string" } = "also works", + foo.bar = "baz", + }, + "quux" + ); + }); + + handle.assert_finished(); +} diff --git a/vendor/tracing/tests/filters_dont_leak.rs b/vendor/tracing/tests/filters_dont_leak.rs index 2ef1c9c70..c46b91f18 100644 --- a/vendor/tracing/tests/filters_dont_leak.rs +++ b/vendor/tracing/tests/filters_dont_leak.rs @@ -13,14 +13,14 @@ fn spans_dont_leak() { let (subscriber, handle) = subscriber::mock() .named("spans/subscriber1") .with_filter(|_| false) - .done() + .only() .run_with_handle(); let _guard = tracing::subscriber::set_default(subscriber); do_span(); - let alice = span::mock().named("alice"); + let alice = expect::span().named("alice"); let (subscriber2, handle2) = subscriber::mock() .named("spans/subscriber2") .with_filter(|_| true) @@ -28,7 +28,7 @@ fn spans_dont_leak() { .enter(alice.clone()) .exit(alice.clone()) .drop_span(alice) - .done() + .only() .run_with_handle(); tracing::subscriber::with_default(subscriber2, || { @@ -53,7 +53,7 @@ fn events_dont_leak() { let (subscriber, handle) = subscriber::mock() .named("events/subscriber1") .with_filter(|_| false) - .done() + .only() .run_with_handle(); let _guard = tracing::subscriber::set_default(subscriber); @@ -63,8 +63,8 @@ fn events_dont_leak() { let (subscriber2, handle2) = subscriber::mock() .named("events/subscriber2") .with_filter(|_| true) - .event(event::mock()) - .done() + .event(expect::event()) + .only() .run_with_handle(); tracing::subscriber::with_default(subscriber2, || { diff --git a/vendor/tracing/tests/instrument.rs b/vendor/tracing/tests/instrument.rs new file mode 100644 index 000000000..524724994 --- /dev/null +++ b/vendor/tracing/tests/instrument.rs @@ -0,0 +1,59 @@ +// These tests require the thread-local scoped dispatcher, which only works when +// we have a standard library. The behaviour being tested should be the same +// with the standard lib disabled. +#![cfg(feature = "std")] + +use std::{future::Future, pin::Pin, task}; + +use futures::FutureExt as _; +use tracing::{subscriber::with_default, Instrument as _, Level}; +use tracing_mock::*; + +#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] +#[test] +fn span_on_drop() { + #[derive(Clone, Debug)] + struct AssertSpanOnDrop; + + impl Drop for AssertSpanOnDrop { + fn drop(&mut self) { + tracing::info!("Drop"); + } + } + + struct Fut(Option<AssertSpanOnDrop>); + + impl Future for Fut { + type Output = (); + + fn poll(mut self: Pin<&mut Self>, _: &mut task::Context<'_>) -> task::Poll<Self::Output> { + self.set(Fut(None)); + task::Poll::Ready(()) + } + } + + let subscriber = subscriber::mock() + .enter(expect::span().named("foo")) + .event(expect::event().at_level(Level::INFO)) + .exit(expect::span().named("foo")) + .enter(expect::span().named("foo")) + .exit(expect::span().named("foo")) + .drop_span(expect::span().named("foo")) + .enter(expect::span().named("bar")) + .event(expect::event().at_level(Level::INFO)) + .exit(expect::span().named("bar")) + .drop_span(expect::span().named("bar")) + .only() + .run(); + + with_default(subscriber, || { + // polled once + Fut(Some(AssertSpanOnDrop)) + .instrument(tracing::span!(Level::TRACE, "foo")) + .now_or_never() + .unwrap(); + + // never polled + drop(Fut(Some(AssertSpanOnDrop)).instrument(tracing::span!(Level::TRACE, "bar"))); + }); +} diff --git a/vendor/tracing/tests/macros.rs b/vendor/tracing/tests/macros.rs index a9679a3e9..81b929d1d 100644 --- a/vendor/tracing/tests/macros.rs +++ b/vendor/tracing/tests/macros.rs @@ -1,4 +1,14 @@ #![deny(warnings)] +// We call all macros in this module with `no_implicit_prelude` to ensure they do not depend on the standard prelude. +#![no_implicit_prelude] +extern crate tracing; +#[cfg(target_arch = "wasm32")] +extern crate wasm_bindgen_test; + +// TODO: remove this once https://github.com/tokio-rs/tracing/pull/2675#issuecomment-1667628907 is resolved +#[cfg(target_arch = "wasm32")] +use ::core::option::Option::None; + use tracing::{ callsite, debug, debug_span, enabled, error, error_span, event, event_enabled, info, info_span, span, span_enabled, trace, trace_span, warn, warn_span, Level, @@ -111,80 +121,142 @@ fn error_span() { #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] #[test] fn span_root() { - span!(target: "foo_events", parent: None, Level::TRACE, "foo", bar.baz = 2, quux = 3); - span!(target: "foo_events", parent: None, Level::TRACE, "foo", bar.baz = 2, quux = 3); - span!(target: "foo_events", parent: None, Level::TRACE, "foo", bar.baz = 2, quux = 4,); - span!(target: "foo_events", parent: None, Level::TRACE, "foo"); - span!(target: "foo_events", parent: None, Level::TRACE, "bar",); - span!(parent: None, Level::DEBUG, "foo", bar.baz = 2, quux = 3); - span!(parent: None, Level::DEBUG, "foo", bar.baz = 2, quux = 4,); - span!(parent: None, Level::DEBUG, "foo"); - span!(parent: None, Level::DEBUG, "bar",); + span!(target: "foo_events", parent: ::core::option::Option::None, Level::TRACE, "foo", bar.baz = 2, quux = 3); + span!(target: "foo_events", parent: ::core::option::Option::None, Level::TRACE, "foo", bar.baz = 2, quux = 3); + span!(target: "foo_events", parent: ::core::option::Option::None, Level::TRACE, "foo", bar.baz = 2, quux = 4,); + span!(target: "foo_events", parent: ::core::option::Option::None, Level::TRACE, "foo"); + span!(target: "foo_events", parent: ::core::option::Option::None, Level::TRACE, "bar",); + span!( + parent: ::core::option::Option::None, + Level::DEBUG, + "foo", + bar.baz = 2, + quux = 3 + ); + span!( + parent: ::core::option::Option::None, + Level::DEBUG, + "foo", + bar.baz = 2, + quux = 4, + ); + span!(parent: ::core::option::Option::None, Level::DEBUG, "foo"); + span!(parent: ::core::option::Option::None, Level::DEBUG, "bar",); } #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] #[test] fn trace_span_root() { - trace_span!(target: "foo_events", parent: None, "foo", bar.baz = 2, quux = 3); - trace_span!(target: "foo_events", parent: None, "foo", bar.baz = 2, quux = 4,); - trace_span!(target: "foo_events", parent: None, "foo"); - trace_span!(target: "foo_events", parent: None, "bar",); - trace_span!(parent: None, "foo", bar.baz = 2, quux = 3); - trace_span!(parent: None, "foo", bar.baz = 2, quux = 4,); - trace_span!(parent: None, "foo"); - trace_span!(parent: None, "bar",); + trace_span!(target: "foo_events", parent: ::core::option::Option::None, "foo", bar.baz = 2, quux = 3); + trace_span!(target: "foo_events", parent: ::core::option::Option::None, "foo", bar.baz = 2, quux = 4,); + trace_span!(target: "foo_events", parent: ::core::option::Option::None, "foo"); + trace_span!(target: "foo_events", parent: ::core::option::Option::None, "bar",); + trace_span!( + parent: ::core::option::Option::None, + "foo", + bar.baz = 2, + quux = 3 + ); + trace_span!( + parent: ::core::option::Option::None, + "foo", + bar.baz = 2, + quux = 4, + ); + trace_span!(parent: ::core::option::Option::None, "foo"); + trace_span!(parent: ::core::option::Option::None, "bar",); } #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] #[test] fn debug_span_root() { - debug_span!(target: "foo_events", parent: None, "foo", bar.baz = 2, quux = 3); - debug_span!(target: "foo_events", parent: None, "foo", bar.baz = 2, quux = 4,); - debug_span!(target: "foo_events", parent: None, "foo"); - debug_span!(target: "foo_events", parent: None, "bar",); - debug_span!(parent: None, "foo", bar.baz = 2, quux = 3); - debug_span!(parent: None, "foo", bar.baz = 2, quux = 4,); - debug_span!(parent: None, "foo"); - debug_span!(parent: None, "bar",); + debug_span!(target: "foo_events", parent: ::core::option::Option::None, "foo", bar.baz = 2, quux = 3); + debug_span!(target: "foo_events", parent: ::core::option::Option::None, "foo", bar.baz = 2, quux = 4,); + debug_span!(target: "foo_events", parent: ::core::option::Option::None, "foo"); + debug_span!(target: "foo_events", parent: ::core::option::Option::None, "bar",); + debug_span!( + parent: ::core::option::Option::None, + "foo", + bar.baz = 2, + quux = 3 + ); + debug_span!( + parent: ::core::option::Option::None, + "foo", + bar.baz = 2, + quux = 4, + ); + debug_span!(parent: ::core::option::Option::None, "foo"); + debug_span!(parent: ::core::option::Option::None, "bar",); } #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] #[test] fn info_span_root() { - info_span!(target: "foo_events", parent: None, "foo", bar.baz = 2, quux = 3); - info_span!(target: "foo_events", parent: None, "foo", bar.baz = 2, quux = 4,); - info_span!(target: "foo_events", parent: None, "foo"); - info_span!(target: "foo_events", parent: None, "bar",); - info_span!(parent: None, "foo", bar.baz = 2, quux = 3); - info_span!(parent: None, "foo", bar.baz = 2, quux = 4,); - info_span!(parent: None, "foo"); - info_span!(parent: None, "bar",); + info_span!(target: "foo_events", parent: ::core::option::Option::None, "foo", bar.baz = 2, quux = 3); + info_span!(target: "foo_events", parent: ::core::option::Option::None, "foo", bar.baz = 2, quux = 4,); + info_span!(target: "foo_events", parent: ::core::option::Option::None, "foo"); + info_span!(target: "foo_events", parent: ::core::option::Option::None, "bar",); + info_span!( + parent: ::core::option::Option::None, + "foo", + bar.baz = 2, + quux = 3 + ); + info_span!( + parent: ::core::option::Option::None, + "foo", + bar.baz = 2, + quux = 4, + ); + info_span!(parent: ::core::option::Option::None, "foo"); + info_span!(parent: ::core::option::Option::None, "bar",); } #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] #[test] fn warn_span_root() { - warn_span!(target: "foo_events", parent: None, "foo", bar.baz = 2, quux = 3); - warn_span!(target: "foo_events", parent: None, "foo", bar.baz = 2, quux = 4,); - warn_span!(target: "foo_events", parent: None, "foo"); - warn_span!(target: "foo_events", parent: None, "bar",); - warn_span!(parent: None, "foo", bar.baz = 2, quux = 3); - warn_span!(parent: None, "foo", bar.baz = 2, quux = 4,); - warn_span!(parent: None, "foo"); - warn_span!(parent: None, "bar",); + warn_span!(target: "foo_events", parent: ::core::option::Option::None, "foo", bar.baz = 2, quux = 3); + warn_span!(target: "foo_events", parent: ::core::option::Option::None, "foo", bar.baz = 2, quux = 4,); + warn_span!(target: "foo_events", parent: ::core::option::Option::None, "foo"); + warn_span!(target: "foo_events", parent: ::core::option::Option::None, "bar",); + warn_span!( + parent: ::core::option::Option::None, + "foo", + bar.baz = 2, + quux = 3 + ); + warn_span!( + parent: ::core::option::Option::None, + "foo", + bar.baz = 2, + quux = 4, + ); + warn_span!(parent: ::core::option::Option::None, "foo"); + warn_span!(parent: ::core::option::Option::None, "bar",); } #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] #[test] fn error_span_root() { - error_span!(target: "foo_events", parent: None, "foo", bar.baz = 2, quux = 3); - error_span!(target: "foo_events", parent: None, "foo", bar.baz = 2, quux = 4,); - error_span!(target: "foo_events", parent: None, "foo"); - error_span!(target: "foo_events", parent: None, "bar",); - error_span!(parent: None, "foo", bar.baz = 2, quux = 3); - error_span!(parent: None, "foo", bar.baz = 2, quux = 4,); - error_span!(parent: None, "foo"); - error_span!(parent: None, "bar",); + error_span!(target: "foo_events", parent: ::core::option::Option::None, "foo", bar.baz = 2, quux = 3); + error_span!(target: "foo_events", parent: ::core::option::Option::None, "foo", bar.baz = 2, quux = 4,); + error_span!(target: "foo_events", parent: ::core::option::Option::None, "foo"); + error_span!(target: "foo_events", parent: ::core::option::Option::None, "bar",); + error_span!( + parent: ::core::option::Option::None, + "foo", + bar.baz = 2, + quux = 3 + ); + error_span!( + parent: ::core::option::Option::None, + "foo", + bar.baz = 2, + quux = 4, + ); + error_span!(parent: ::core::option::Option::None, "foo"); + error_span!(parent: ::core::option::Option::None, "bar",); } #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] @@ -300,6 +372,48 @@ fn span_with_non_rust_symbol() { #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] #[test] +fn large_span() { + span!( + Level::TRACE, + "spans with more than 32 fields have been supported since #2508", + a = 1, + b = 2, + c = 3, + d = 4, + e = 5, + f = 6, + g = 7, + h = 8, + i = 9, + j = 10, + k = 11, + l = 12, + m = 13, + n = 14, + o = 15, + p = 16, + q = 17, + r = 18, + s = 19, + t = 20, + u = 21, + v = 22, + w = 23, + x = 24, + y = 25, + z = 26, + aa = 27, + bb = 28, + cc = 29, + dd = 30, + ee = 31, + ff = 32, + gg = 33 + ); +} + +#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] +#[test] fn event() { event!(Level::DEBUG, foo = ?3, bar.baz = %2, quux = false); event!(Level::DEBUG, foo = 3, bar.baz = 2, quux = false); @@ -400,6 +514,13 @@ fn locals_no_message() { let private_data = "private"; let error = "a bad error"; event!( + name: "foo", + target: "app_events", + Level::WARN, + private_data, + ?data, + ); + event!( target: "app_events", Level::WARN, private_data, @@ -438,6 +559,8 @@ fn trace() { trace!({ foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); trace!({ foo = 2, bar.baz = 78 }, "quux"); trace!({ foo = ?2, bar.baz = %78 }, "quux"); + trace!(name: "foo", foo = 3, bar.baz = 2, quux = false); + trace!(name: "foo", target: "foo_events", foo = 3, bar.baz = 2, quux = false); trace!(target: "foo_events", foo = 3, bar.baz = 2, quux = false); trace!(target: "foo_events", foo = 3, bar.baz = 3,); trace!(target: "foo_events", "foo"); @@ -450,6 +573,12 @@ fn trace() { trace!(?foo); trace!(%foo); trace!(foo); + trace!(name: "foo", ?foo); + trace!(name: "foo", %foo); + trace!(name: "foo", foo); + trace!(name: "foo", ?foo, true, "message"); + trace!(name: "foo", %foo, true, "message"); + trace!(name: "foo", foo, true, "message"); trace!(target: "foo_events", ?foo); trace!(target: "foo_events", %foo); trace!(target: "foo_events", foo); @@ -474,6 +603,8 @@ fn debug() { debug!({ foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); debug!({ foo = 2, bar.baz = 78 }, "quux"); debug!({ foo = ?2, bar.baz = %78 }, "quux"); + debug!(name: "foo", foo = 3, bar.baz = 2, quux = false); + debug!(name: "foo", target: "foo_events", foo = 3, bar.baz = 2, quux = false); debug!(target: "foo_events", foo = 3, bar.baz = 2, quux = false); debug!(target: "foo_events", foo = 3, bar.baz = 3,); debug!(target: "foo_events", "foo"); @@ -486,6 +617,12 @@ fn debug() { debug!(?foo); debug!(%foo); debug!(foo); + debug!(name: "foo", ?foo); + debug!(name: "foo", %foo); + debug!(name: "foo", foo); + debug!(name: "foo", ?foo, true, "message"); + debug!(name: "foo", %foo, true, "message"); + debug!(name: "foo", foo, true, "message"); debug!(target: "foo_events", ?foo); debug!(target: "foo_events", %foo); debug!(target: "foo_events", foo); @@ -510,6 +647,8 @@ fn info() { info!({ foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); info!({ foo = 2, bar.baz = 78 }, "quux"); info!({ foo = ?2, bar.baz = %78 }, "quux"); + info!(name: "foo", foo = 3, bar.baz = 2, quux = false); + info!(name: "foo", target: "foo_events", foo = 3, bar.baz = 2, quux = false); info!(target: "foo_events", foo = 3, bar.baz = 2, quux = false); info!(target: "foo_events", foo = 3, bar.baz = 3,); info!(target: "foo_events", "foo"); @@ -522,6 +661,12 @@ fn info() { info!(?foo); info!(%foo); info!(foo); + info!(name: "foo", ?foo); + info!(name: "foo", %foo); + info!(name: "foo", foo); + info!(name: "foo", ?foo, true, "message"); + info!(name: "foo", %foo, true, "message"); + info!(name: "foo", foo, true, "message"); info!(target: "foo_events", ?foo); info!(target: "foo_events", %foo); info!(target: "foo_events", foo); @@ -546,6 +691,8 @@ fn warn() { warn!({ foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); warn!({ foo = 2, bar.baz = 78 }, "quux"); warn!({ foo = ?2, bar.baz = %78 }, "quux"); + warn!(name: "foo", foo = 3, bar.baz = 2, quux = false); + warn!(name: "foo", target: "foo_events", foo = 3, bar.baz = 2, quux = false); warn!(target: "foo_events", foo = 3, bar.baz = 2, quux = false); warn!(target: "foo_events", foo = 3, bar.baz = 3,); warn!(target: "foo_events", "foo"); @@ -558,6 +705,12 @@ fn warn() { warn!(?foo); warn!(%foo); warn!(foo); + warn!(name: "foo", ?foo); + warn!(name: "foo", %foo); + warn!(name: "foo", foo); + warn!(name: "foo", ?foo, true, "message"); + warn!(name: "foo", %foo, true, "message"); + warn!(name: "foo", foo, true, "message"); warn!(target: "foo_events", ?foo); warn!(target: "foo_events", %foo); warn!(target: "foo_events", foo); @@ -582,6 +735,8 @@ fn error() { error!({ foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); error!({ foo = 2, bar.baz = 78, }, "quux"); error!({ foo = ?2, bar.baz = %78 }, "quux"); + error!(name: "foo", foo = 3, bar.baz = 2, quux = false); + error!(name: "foo", target: "foo_events", foo = 3, bar.baz = 2, quux = false); error!(target: "foo_events", foo = 3, bar.baz = 2, quux = false); error!(target: "foo_events", foo = 3, bar.baz = 3,); error!(target: "foo_events", "foo"); @@ -594,6 +749,12 @@ fn error() { error!(?foo); error!(%foo); error!(foo); + error!(name: "foo", ?foo); + error!(name: "foo", %foo); + error!(name: "foo", foo); + error!(name: "foo", ?foo, true, "message"); + error!(name: "foo", %foo, true, "message"); + error!(name: "foo", foo, true, "message"); error!(target: "foo_events", ?foo); error!(target: "foo_events", %foo); error!(target: "foo_events", foo); @@ -605,144 +766,227 @@ fn error() { #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] #[test] fn event_root() { - event!(parent: None, Level::DEBUG, foo = ?3, bar.baz = %2, quux = false); + event!(parent: ::core::option::Option::None, Level::DEBUG, foo = ?3, bar.baz = %2, quux = false); event!( - parent: None, + parent: ::core::option::Option::None, Level::DEBUG, foo = 3, bar.baz = 2, quux = false ); - event!(parent: None, Level::DEBUG, foo = 3, bar.baz = 3,); - event!(parent: None, Level::DEBUG, "foo"); - event!(parent: None, Level::DEBUG, "foo: {}", 3); - event!(parent: None, Level::DEBUG, { foo = 3, bar.baz = 80 }, "quux"); - event!(parent: None, Level::DEBUG, { foo = 2, bar.baz = 79 }, "quux {:?}", true); - event!(parent: None, Level::DEBUG, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); - event!(parent: None, Level::DEBUG, { foo = ?2, bar.baz = %78 }, "quux"); - event!(target: "foo_events", parent: None, Level::DEBUG, foo = 3, bar.baz = 2, quux = false); - event!(target: "foo_events", parent: None, Level::DEBUG, foo = 3, bar.baz = 3,); - event!(target: "foo_events", parent: None, Level::DEBUG, "foo"); - event!(target: "foo_events", parent: None, Level::DEBUG, "foo: {}", 3); - event!(target: "foo_events", parent: None, Level::DEBUG, { foo = 3, bar.baz = 80 }, "quux"); - event!(target: "foo_events", parent: None, Level::DEBUG, { foo = 2, bar.baz = 79 }, "quux {:?}", true); - event!(target: "foo_events", parent: None, Level::DEBUG, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); - event!(target: "foo_events", parent: None, Level::DEBUG, { foo = 2, bar.baz = 78, }, "quux"); + event!( + parent: ::core::option::Option::None, + Level::DEBUG, + foo = 3, + bar.baz = 3, + ); + event!(parent: ::core::option::Option::None, Level::DEBUG, "foo"); + event!( + parent: ::core::option::Option::None, + Level::DEBUG, + "foo: {}", + 3 + ); + event!(parent: ::core::option::Option::None, Level::DEBUG, { foo = 3, bar.baz = 80 }, "quux"); + event!(parent: ::core::option::Option::None, Level::DEBUG, { foo = 2, bar.baz = 79 }, "quux {:?}", true); + event!(parent: ::core::option::Option::None, Level::DEBUG, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); + event!(parent: ::core::option::Option::None, Level::DEBUG, { foo = ?2, bar.baz = %78 }, "quux"); + event!(target: "foo_events", parent: ::core::option::Option::None, Level::DEBUG, foo = 3, bar.baz = 2, quux = false); + event!(target: "foo_events", parent: ::core::option::Option::None, Level::DEBUG, foo = 3, bar.baz = 3,); + event!(target: "foo_events", parent: ::core::option::Option::None, Level::DEBUG, "foo"); + event!(target: "foo_events", parent: ::core::option::Option::None, Level::DEBUG, "foo: {}", 3); + event!(target: "foo_events", parent: ::core::option::Option::None, Level::DEBUG, { foo = 3, bar.baz = 80 }, "quux"); + event!(target: "foo_events", parent: ::core::option::Option::None, Level::DEBUG, { foo = 2, bar.baz = 79 }, "quux {:?}", true); + event!(target: "foo_events", parent: ::core::option::Option::None, Level::DEBUG, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); + event!(target: "foo_events", parent: ::core::option::Option::None, Level::DEBUG, { foo = 2, bar.baz = 78, }, "quux"); + event!(name: "foo", target: "foo_events", parent: ::core::option::Option::None, Level::DEBUG, foo = 3, bar.baz = 2, quux = false); + event!(name: "foo", target: "foo_events", parent: ::core::option::Option::None, Level::DEBUG, foo = 3, bar.baz = 3,); + event!(name: "foo", target: "foo_events", parent: ::core::option::Option::None, Level::DEBUG, "foo"); + event!(name: "foo", target: "foo_events", parent: ::core::option::Option::None, Level::DEBUG, "foo: {}", 3); + event!(name: "foo", target: "foo_events", parent: ::core::option::Option::None, Level::DEBUG, { foo = 3, bar.baz = 80 }, "quux"); + event!(name: "foo", target: "foo_events", parent: ::core::option::Option::None, Level::DEBUG, { foo = 2, bar.baz = 79 }, "quux {:?}", true); + event!(name: "foo", target: "foo_events", parent: ::core::option::Option::None, Level::DEBUG, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); + event!(name: "foo", target: "foo_events", parent: ::core::option::Option::None, Level::DEBUG, { foo = 2, bar.baz = 78, }, "quux"); } #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] #[test] fn trace_root() { - trace!(parent: None, foo = ?3, bar.baz = %2, quux = false); - trace!(parent: None, foo = 3, bar.baz = 2, quux = false); - trace!(parent: None, foo = 3, bar.baz = 3,); - trace!(parent: None, "foo"); - trace!(parent: None, "foo: {}", 3); - trace!(parent: None, { foo = 3, bar.baz = 80 }, "quux"); - trace!(parent: None, { foo = 2, bar.baz = 79 }, "quux {:?}", true); - trace!(parent: None, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); - trace!(parent: None, { foo = 2, bar.baz = 78 }, "quux"); - trace!(parent: None, { foo = ?2, bar.baz = %78 }, "quux"); - trace!(target: "foo_events", parent: None, foo = 3, bar.baz = 2, quux = false); - trace!(target: "foo_events", parent: None, foo = 3, bar.baz = 3,); - trace!(target: "foo_events", parent: None, "foo"); - trace!(target: "foo_events", parent: None, "foo: {}", 3); - trace!(target: "foo_events", parent: None, { foo = 3, bar.baz = 80 }, "quux"); - trace!(target: "foo_events", parent: None, { foo = 2, bar.baz = 79 }, "quux {:?}", true); - trace!(target: "foo_events", parent: None, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); - trace!(target: "foo_events", parent: None, { foo = 2, bar.baz = 78, }, "quux"); + trace!(parent: ::core::option::Option::None, foo = ?3, bar.baz = %2, quux = false); + trace!( + parent: ::core::option::Option::None, + foo = 3, + bar.baz = 2, + quux = false + ); + trace!(parent: ::core::option::Option::None, foo = 3, bar.baz = 3,); + trace!(parent: ::core::option::Option::None, "foo"); + trace!(parent: ::core::option::Option::None, "foo: {}", 3); + trace!(parent: ::core::option::Option::None, { foo = 3, bar.baz = 80 }, "quux"); + trace!(parent: ::core::option::Option::None, { foo = 2, bar.baz = 79 }, "quux {:?}", true); + trace!(parent: ::core::option::Option::None, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); + trace!(parent: ::core::option::Option::None, { foo = 2, bar.baz = 78 }, "quux"); + trace!(parent: ::core::option::Option::None, { foo = ?2, bar.baz = %78 }, "quux"); + trace!(target: "foo_events", parent: ::core::option::Option::None, foo = 3, bar.baz = 2, quux = false); + trace!(target: "foo_events", parent: ::core::option::Option::None, foo = 3, bar.baz = 3,); + trace!(target: "foo_events", parent: ::core::option::Option::None, "foo"); + trace!(target: "foo_events", parent: ::core::option::Option::None, "foo: {}", 3); + trace!(target: "foo_events", parent: ::core::option::Option::None, { foo = 3, bar.baz = 80 }, "quux"); + trace!(target: "foo_events", parent: ::core::option::Option::None, { foo = 2, bar.baz = 79 }, "quux {:?}", true); + trace!(target: "foo_events", parent: ::core::option::Option::None, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); + trace!(target: "foo_events", parent: ::core::option::Option::None, { foo = 2, bar.baz = 78, }, "quux"); + trace!(name: "foo", target: "foo_events", parent: ::core::option::Option::None, foo = 3, bar.baz = 2, quux = false); + trace!(name: "foo", target: "foo_events", parent: ::core::option::Option::None, foo = 3, bar.baz = 3,); + trace!(name: "foo", target: "foo_events", parent: ::core::option::Option::None, "foo"); + trace!(name: "foo", target: "foo_events", parent: ::core::option::Option::None, "foo: {}", 3); + trace!(name: "foo", target: "foo_events", parent: ::core::option::Option::None, { foo = 3, bar.baz = 80 }, "quux"); + trace!(name: "foo", target: "foo_events", parent: ::core::option::Option::None, { foo = 2, bar.baz = 79 }, "quux {:?}", true); + trace!(name: "foo", target: "foo_events", parent: ::core::option::Option::None, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); + trace!(name: "foo", target: "foo_events", parent: ::core::option::Option::None, { foo = 2, bar.baz = 78, }, "quux"); } #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] #[test] fn debug_root() { - debug!(parent: None, foo = ?3, bar.baz = %2, quux = false); - debug!(parent: None, foo = 3, bar.baz = 2, quux = false); - debug!(parent: None, foo = 3, bar.baz = 3,); - debug!(parent: None, "foo"); - debug!(parent: None, "foo: {}", 3); - debug!(parent: None, { foo = 3, bar.baz = 80 }, "quux"); - debug!(parent: None, { foo = 2, bar.baz = 79 }, "quux {:?}", true); - debug!(parent: None, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); - debug!(parent: None, { foo = 2, bar.baz = 78 }, "quux"); - debug!(parent: None, { foo = ?2, bar.baz = %78 }, "quux"); - debug!(target: "foo_events", parent: None, foo = 3, bar.baz = 2, quux = false); - debug!(target: "foo_events", parent: None, foo = 3, bar.baz = 3,); - debug!(target: "foo_events", parent: None, "foo"); - debug!(target: "foo_events", parent: None, "foo: {}", 3); - debug!(target: "foo_events", parent: None, { foo = 3, bar.baz = 80 }, "quux"); - debug!(target: "foo_events", parent: None, { foo = 2, bar.baz = 79 }, "quux {:?}", true); - debug!(target: "foo_events", parent: None, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); - debug!(target: "foo_events", parent: None, { foo = 2, bar.baz = 78, }, "quux"); + debug!(parent: ::core::option::Option::None, foo = ?3, bar.baz = %2, quux = false); + debug!( + parent: ::core::option::Option::None, + foo = 3, + bar.baz = 2, + quux = false + ); + debug!(parent: ::core::option::Option::None, foo = 3, bar.baz = 3,); + debug!(parent: ::core::option::Option::None, "foo"); + debug!(parent: ::core::option::Option::None, "foo: {}", 3); + debug!(parent: ::core::option::Option::None, { foo = 3, bar.baz = 80 }, "quux"); + debug!(parent: ::core::option::Option::None, { foo = 2, bar.baz = 79 }, "quux {:?}", true); + debug!(parent: ::core::option::Option::None, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); + debug!(parent: ::core::option::Option::None, { foo = 2, bar.baz = 78 }, "quux"); + debug!(parent: ::core::option::Option::None, { foo = ?2, bar.baz = %78 }, "quux"); + debug!(target: "foo_events", parent: ::core::option::Option::None, foo = 3, bar.baz = 2, quux = false); + debug!(target: "foo_events", parent: ::core::option::Option::None, foo = 3, bar.baz = 3,); + debug!(target: "foo_events", parent: ::core::option::Option::None, "foo"); + debug!(target: "foo_events", parent: ::core::option::Option::None, "foo: {}", 3); + debug!(target: "foo_events", parent: ::core::option::Option::None, { foo = 3, bar.baz = 80 }, "quux"); + debug!(target: "foo_events", parent: ::core::option::Option::None, { foo = 2, bar.baz = 79 }, "quux {:?}", true); + debug!(target: "foo_events", parent: ::core::option::Option::None, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); + debug!(target: "foo_events", parent: ::core::option::Option::None, { foo = 2, bar.baz = 78, }, "quux"); + debug!(name: "foo", target: "foo_events", parent: ::core::option::Option::None, foo = 3, bar.baz = 2, quux = false); + debug!(name: "foo", target: "foo_events", parent: ::core::option::Option::None, foo = 3, bar.baz = 3,); + debug!(name: "foo", target: "foo_events", parent: ::core::option::Option::None, "foo"); + debug!(name: "foo", target: "foo_events", parent: ::core::option::Option::None, "foo: {}", 3); + debug!(name: "foo", target: "foo_events", parent: ::core::option::Option::None, { foo = 3, bar.baz = 80 }, "quux"); + debug!(name: "foo", target: "foo_events", parent: ::core::option::Option::None, { foo = 2, bar.baz = 79 }, "quux {:?}", true); + debug!(name: "foo", target: "foo_events", parent: ::core::option::Option::None, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); + debug!(name: "foo", target: "foo_events", parent: ::core::option::Option::None, { foo = 2, bar.baz = 78, }, "quux"); } #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] #[test] fn info_root() { - info!(parent: None, foo = ?3, bar.baz = %2, quux = false); - info!(parent: None, foo = 3, bar.baz = 2, quux = false); - info!(parent: None, foo = 3, bar.baz = 3,); - info!(parent: None, "foo"); - info!(parent: None, "foo: {}", 3); - info!(parent: None, { foo = 3, bar.baz = 80 }, "quux"); - info!(parent: None, { foo = 2, bar.baz = 79 }, "quux {:?}", true); - info!(parent: None, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); - info!(parent: None, { foo = 2, bar.baz = 78 }, "quux"); - info!(parent: None, { foo = ?2, bar.baz = %78 }, "quux"); - info!(target: "foo_events", parent: None, foo = 3, bar.baz = 2, quux = false); - info!(target: "foo_events", parent: None, foo = 3, bar.baz = 3,); - info!(target: "foo_events", parent: None, "foo"); - info!(target: "foo_events", parent: None, "foo: {}", 3); - info!(target: "foo_events", parent: None, { foo = 3, bar.baz = 80 }, "quux"); - info!(target: "foo_events", parent: None, { foo = 2, bar.baz = 79 }, "quux {:?}", true); - info!(target: "foo_events", parent: None, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); - info!(target: "foo_events", parent: None, { foo = 2, bar.baz = 78, }, "quux"); + info!(parent: ::core::option::Option::None, foo = ?3, bar.baz = %2, quux = false); + info!( + parent: ::core::option::Option::None, + foo = 3, + bar.baz = 2, + quux = false + ); + info!(parent: ::core::option::Option::None, foo = 3, bar.baz = 3,); + info!(parent: ::core::option::Option::None, "foo"); + info!(parent: ::core::option::Option::None, "foo: {}", 3); + info!(parent: ::core::option::Option::None, { foo = 3, bar.baz = 80 }, "quux"); + info!(parent: ::core::option::Option::None, { foo = 2, bar.baz = 79 }, "quux {:?}", true); + info!(parent: ::core::option::Option::None, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); + info!(parent: ::core::option::Option::None, { foo = 2, bar.baz = 78 }, "quux"); + info!(parent: ::core::option::Option::None, { foo = ?2, bar.baz = %78 }, "quux"); + info!(target: "foo_events", parent: ::core::option::Option::None, foo = 3, bar.baz = 2, quux = false); + info!(target: "foo_events", parent: ::core::option::Option::None, foo = 3, bar.baz = 3,); + info!(target: "foo_events", parent: ::core::option::Option::None, "foo"); + info!(target: "foo_events", parent: ::core::option::Option::None, "foo: {}", 3); + info!(target: "foo_events", parent: ::core::option::Option::None, { foo = 3, bar.baz = 80 }, "quux"); + info!(target: "foo_events", parent: ::core::option::Option::None, { foo = 2, bar.baz = 79 }, "quux {:?}", true); + info!(target: "foo_events", parent: ::core::option::Option::None, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); + info!(target: "foo_events", parent: ::core::option::Option::None, { foo = 2, bar.baz = 78, }, "quux"); + info!(name: "foo", target: "foo_events", parent: ::core::option::Option::None, foo = 3, bar.baz = 2, quux = false); + info!(name: "foo", target: "foo_events", parent: ::core::option::Option::None, foo = 3, bar.baz = 3,); + info!(name: "foo", target: "foo_events", parent: ::core::option::Option::None, "foo"); + info!(name: "foo", target: "foo_events", parent: ::core::option::Option::None, "foo: {}", 3); + info!(name: "foo", target: "foo_events", parent: ::core::option::Option::None, { foo = 3, bar.baz = 80 }, "quux"); + info!(name: "foo", target: "foo_events", parent: ::core::option::Option::None, { foo = 2, bar.baz = 79 }, "quux {:?}", true); + info!(name: "foo", target: "foo_events", parent: ::core::option::Option::None, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); + info!(name: "foo", target: "foo_events", parent: ::core::option::Option::None, { foo = 2, bar.baz = 78, }, "quux"); } #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] #[test] fn warn_root() { - warn!(parent: None, foo = ?3, bar.baz = %2, quux = false); - warn!(parent: None, foo = 3, bar.baz = 2, quux = false); - warn!(parent: None, foo = 3, bar.baz = 3,); - warn!(parent: None, "foo"); - warn!(parent: None, "foo: {}", 3); - warn!(parent: None, { foo = 3, bar.baz = 80 }, "quux"); - warn!(parent: None, { foo = 2, bar.baz = 79 }, "quux {:?}", true); - warn!(parent: None, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); - warn!(parent: None, { foo = 2, bar.baz = 78 }, "quux"); - warn!(parent: None, { foo = ?2, bar.baz = %78 }, "quux"); - warn!(target: "foo_events", parent: None, foo = 3, bar.baz = 2, quux = false); - warn!(target: "foo_events", parent: None, foo = 3, bar.baz = 3,); - warn!(target: "foo_events", parent: None, "foo"); - warn!(target: "foo_events", parent: None, "foo: {}", 3); - warn!(target: "foo_events", parent: None, { foo = 3, bar.baz = 80 }, "quux"); - warn!(target: "foo_events", parent: None, { foo = 2, bar.baz = 79 }, "quux {:?}", true); - warn!(target: "foo_events", parent: None, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); - warn!(target: "foo_events", parent: None, { foo = 2, bar.baz = 78, }, "quux"); + warn!(parent: ::core::option::Option::None, foo = ?3, bar.baz = %2, quux = false); + warn!( + parent: ::core::option::Option::None, + foo = 3, + bar.baz = 2, + quux = false + ); + warn!(parent: ::core::option::Option::None, foo = 3, bar.baz = 3,); + warn!(parent: ::core::option::Option::None, "foo"); + warn!(parent: ::core::option::Option::None, "foo: {}", 3); + warn!(parent: ::core::option::Option::None, { foo = 3, bar.baz = 80 }, "quux"); + warn!(parent: ::core::option::Option::None, { foo = 2, bar.baz = 79 }, "quux {:?}", true); + warn!(parent: ::core::option::Option::None, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); + warn!(parent: ::core::option::Option::None, { foo = 2, bar.baz = 78 }, "quux"); + warn!(parent: ::core::option::Option::None, { foo = ?2, bar.baz = %78 }, "quux"); + warn!(target: "foo_events", parent: ::core::option::Option::None, foo = 3, bar.baz = 2, quux = false); + warn!(target: "foo_events", parent: ::core::option::Option::None, foo = 3, bar.baz = 3,); + warn!(target: "foo_events", parent: ::core::option::Option::None, "foo"); + warn!(target: "foo_events", parent: ::core::option::Option::None, "foo: {}", 3); + warn!(target: "foo_events", parent: ::core::option::Option::None, { foo = 3, bar.baz = 80 }, "quux"); + warn!(target: "foo_events", parent: ::core::option::Option::None, { foo = 2, bar.baz = 79 }, "quux {:?}", true); + warn!(target: "foo_events", parent: ::core::option::Option::None, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); + warn!(target: "foo_events", parent: ::core::option::Option::None, { foo = 2, bar.baz = 78, }, "quux"); + warn!(name: "foo", target: "foo_events", parent: ::core::option::Option::None, foo = 3, bar.baz = 2, quux = false); + warn!(name: "foo", target: "foo_events", parent: ::core::option::Option::None, foo = 3, bar.baz = 3,); + warn!(name: "foo", target: "foo_events", parent: ::core::option::Option::None, "foo"); + warn!(name: "foo", target: "foo_events", parent: ::core::option::Option::None, "foo: {}", 3); + warn!(name: "foo", target: "foo_events", parent: ::core::option::Option::None, { foo = 3, bar.baz = 80 }, "quux"); + warn!(name: "foo", target: "foo_events", parent: ::core::option::Option::None, { foo = 2, bar.baz = 79 }, "quux {:?}", true); + warn!(name: "foo", target: "foo_events", parent: ::core::option::Option::None, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); + warn!(name: "foo", target: "foo_events", parent: ::core::option::Option::None, { foo = 2, bar.baz = 78, }, "quux"); } #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] #[test] fn error_root() { - error!(parent: None, foo = ?3, bar.baz = %2, quux = false); - error!(parent: None, foo = 3, bar.baz = 2, quux = false); - error!(parent: None, foo = 3, bar.baz = 3,); - error!(parent: None, "foo"); - error!(parent: None, "foo: {}", 3); - error!(parent: None, { foo = 3, bar.baz = 80 }, "quux"); - error!(parent: None, { foo = 2, bar.baz = 79 }, "quux {:?}", true); - error!(parent: None, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); - error!(parent: None, { foo = 2, bar.baz = 78 }, "quux"); - error!(parent: None, { foo = ?2, bar.baz = %78 }, "quux"); - error!(target: "foo_events", parent: None, foo = 3, bar.baz = 2, quux = false); - error!(target: "foo_events", parent: None, foo = 3, bar.baz = 3,); - error!(target: "foo_events", parent: None, "foo"); - error!(target: "foo_events", parent: None, "foo: {}", 3); - error!(target: "foo_events", parent: None, { foo = 3, bar.baz = 80 }, "quux"); - error!(target: "foo_events", parent: None, { foo = 2, bar.baz = 79 }, "quux {:?}", true); - error!(target: "foo_events", parent: None, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); - error!(target: "foo_events", parent: None, { foo = 2, bar.baz = 78, }, "quux"); + error!(parent: ::core::option::Option::None, foo = ?3, bar.baz = %2, quux = false); + error!( + parent: ::core::option::Option::None, + foo = 3, + bar.baz = 2, + quux = false + ); + error!(parent: ::core::option::Option::None, foo = 3, bar.baz = 3,); + error!(parent: ::core::option::Option::None, "foo"); + error!(parent: ::core::option::Option::None, "foo: {}", 3); + error!(parent: ::core::option::Option::None, { foo = 3, bar.baz = 80 }, "quux"); + error!(parent: ::core::option::Option::None, { foo = 2, bar.baz = 79 }, "quux {:?}", true); + error!(parent: ::core::option::Option::None, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); + error!(parent: ::core::option::Option::None, { foo = 2, bar.baz = 78 }, "quux"); + error!(parent: ::core::option::Option::None, { foo = ?2, bar.baz = %78 }, "quux"); + error!(target: "foo_events", parent: ::core::option::Option::None, foo = 3, bar.baz = 2, quux = false); + error!(target: "foo_events", parent: ::core::option::Option::None, foo = 3, bar.baz = 3,); + error!(target: "foo_events", parent: ::core::option::Option::None, "foo"); + error!(target: "foo_events", parent: ::core::option::Option::None, "foo: {}", 3); + error!(target: "foo_events", parent: ::core::option::Option::None, { foo = 3, bar.baz = 80 }, "quux"); + error!(target: "foo_events", parent: ::core::option::Option::None, { foo = 2, bar.baz = 79 }, "quux {:?}", true); + error!(target: "foo_events", parent: ::core::option::Option::None, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); + error!(target: "foo_events", parent: ::core::option::Option::None, { foo = 2, bar.baz = 78, }, "quux"); + error!(name: "foo", target: "foo_events", parent: ::core::option::Option::None, foo = 3, bar.baz = 2, quux = false); + error!(name: "foo", target: "foo_events", parent: ::core::option::Option::None, foo = 3, bar.baz = 3,); + error!(name: "foo", target: "foo_events", parent: ::core::option::Option::None, "foo"); + error!(name: "foo", target: "foo_events", parent: ::core::option::Option::None, "foo: {}", 3); + error!(name: "foo", target: "foo_events", parent: ::core::option::Option::None, { foo = 3, bar.baz = 80 }, "quux"); + error!(name: "foo", target: "foo_events", parent: ::core::option::Option::None, { foo = 2, bar.baz = 79 }, "quux {:?}", true); + error!(name: "foo", target: "foo_events", parent: ::core::option::Option::None, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); + error!(name: "foo", target: "foo_events", parent: ::core::option::Option::None, { foo = 2, bar.baz = 78, }, "quux"); } #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] @@ -766,6 +1010,14 @@ fn event_with_parent() { event!(target: "foo_events", parent: &p, Level::DEBUG, { foo = 2, bar.baz = 79 }, "quux {:?}", true); event!(target: "foo_events", parent: &p, Level::DEBUG, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); event!(target: "foo_events", parent: &p, Level::DEBUG, { foo = 2, bar.baz = 78, }, "quux"); + event!(name: "foo", target: "foo_events", parent: &p, Level::DEBUG, foo = 3, bar.baz = 2, quux = false); + event!(name: "foo", target: "foo_events", parent: &p, Level::DEBUG, foo = 3, bar.baz = 3,); + event!(name: "foo", target: "foo_events", parent: &p, Level::DEBUG, "foo"); + event!(name: "foo", target: "foo_events", parent: &p, Level::DEBUG, "foo: {}", 3); + event!(name: "foo", target: "foo_events", parent: &p, Level::DEBUG, { foo = 3, bar.baz = 80 }, "quux"); + event!(name: "foo", target: "foo_events", parent: &p, Level::DEBUG, { foo = 2, bar.baz = 79 }, "quux {:?}", true); + event!(name: "foo", target: "foo_events", parent: &p, Level::DEBUG, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); + event!(name: "foo", target: "foo_events", parent: &p, Level::DEBUG, { foo = 2, bar.baz = 78, }, "quux"); } #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] @@ -790,6 +1042,14 @@ fn trace_with_parent() { trace!(target: "foo_events", parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}", true); trace!(target: "foo_events", parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); trace!(target: "foo_events", parent: &p, { foo = 2, bar.baz = 78, }, "quux"); + trace!(name: "foo", target: "foo_events", parent: &p, foo = 3, bar.baz = 2, quux = false); + trace!(name: "foo", target: "foo_events", parent: &p, foo = 3, bar.baz = 3,); + trace!(name: "foo", target: "foo_events", parent: &p, "foo"); + trace!(name: "foo", target: "foo_events", parent: &p, "foo: {}", 3); + trace!(name: "foo", target: "foo_events", parent: &p, { foo = 3, bar.baz = 80 }, "quux"); + trace!(name: "foo", target: "foo_events", parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}", true); + trace!(name: "foo", target: "foo_events", parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); + trace!(name: "foo", target: "foo_events", parent: &p, { foo = 2, bar.baz = 78, }, "quux"); } #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] @@ -814,6 +1074,14 @@ fn debug_with_parent() { debug!(target: "foo_events", parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}", true); debug!(target: "foo_events", parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); debug!(target: "foo_events", parent: &p, { foo = 2, bar.baz = 78, }, "quux"); + debug!(name: "foo", target: "foo_events", parent: &p, foo = 3, bar.baz = 2, quux = false); + debug!(name: "foo", target: "foo_events", parent: &p, foo = 3, bar.baz = 3,); + debug!(name: "foo", target: "foo_events", parent: &p, "foo"); + debug!(name: "foo", target: "foo_events", parent: &p, "foo: {}", 3); + debug!(name: "foo", target: "foo_events", parent: &p, { foo = 3, bar.baz = 80 }, "quux"); + debug!(name: "foo", target: "foo_events", parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}", true); + debug!(name: "foo", target: "foo_events", parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); + debug!(name: "foo", target: "foo_events", parent: &p, { foo = 2, bar.baz = 78, }, "quux"); } #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] @@ -838,6 +1106,14 @@ fn info_with_parent() { info!(target: "foo_events", parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}", true); info!(target: "foo_events", parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); info!(target: "foo_events", parent: &p, { foo = 2, bar.baz = 78, }, "quux"); + info!(name: "foo", target: "foo_events", parent: &p, foo = 3, bar.baz = 2, quux = false); + info!(name: "foo", target: "foo_events", parent: &p, foo = 3, bar.baz = 3,); + info!(name: "foo", target: "foo_events", parent: &p, "foo"); + info!(name: "foo", target: "foo_events", parent: &p, "foo: {}", 3); + info!(name: "foo", target: "foo_events", parent: &p, { foo = 3, bar.baz = 80 }, "quux"); + info!(name: "foo", target: "foo_events", parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}", true); + info!(name: "foo", target: "foo_events", parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); + info!(name: "foo", target: "foo_events", parent: &p, { foo = 2, bar.baz = 78, }, "quux"); } #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] @@ -862,6 +1138,14 @@ fn warn_with_parent() { warn!(target: "foo_events", parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}", true); warn!(target: "foo_events", parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); warn!(target: "foo_events", parent: &p, { foo = 2, bar.baz = 78, }, "quux"); + warn!(name: "foo", target: "foo_events", parent: &p, foo = 3, bar.baz = 2, quux = false); + warn!(name: "foo", target: "foo_events", parent: &p, foo = 3, bar.baz = 3,); + warn!(name: "foo", target: "foo_events", parent: &p, "foo"); + warn!(name: "foo", target: "foo_events", parent: &p, "foo: {}", 3); + warn!(name: "foo", target: "foo_events", parent: &p, { foo = 3, bar.baz = 80 }, "quux"); + warn!(name: "foo", target: "foo_events", parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}", true); + warn!(name: "foo", target: "foo_events", parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); + warn!(name: "foo", target: "foo_events", parent: &p, { foo = 2, bar.baz = 78, }, "quux"); } #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] @@ -886,6 +1170,14 @@ fn error_with_parent() { error!(target: "foo_events", parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}", true); error!(target: "foo_events", parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); error!(target: "foo_events", parent: &p, { foo = 2, bar.baz = 78, }, "quux"); + error!(name: "foo", target: "foo_events", parent: &p, foo = 3, bar.baz = 2, quux = false); + error!(name: "foo", target: "foo_events", parent: &p, foo = 3, bar.baz = 3,); + error!(name: "foo", target: "foo_events", parent: &p, "foo"); + error!(name: "foo", target: "foo_events", parent: &p, "foo: {}", 3); + error!(name: "foo", target: "foo_events", parent: &p, { foo = 3, bar.baz = 80 }, "quux"); + error!(name: "foo", target: "foo_events", parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}", true); + error!(name: "foo", target: "foo_events", parent: &p, { foo = 2, bar.baz = 79 }, "quux {:?}, {quux}", true, quux = false); + error!(name: "foo", target: "foo_events", parent: &p, { foo = 2, bar.baz = 78, }, "quux"); } #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] @@ -913,7 +1205,7 @@ fn field_shorthand_only() { #[test] fn borrow_val_events() { // Reproduces https://github.com/tokio-rs/tracing/issues/954 - let mut foo = (String::new(), String::new()); + let mut foo = (::std::string::String::new(), ::std::string::String::new()); let zero = &mut foo.0; trace!(one = ?foo.1); debug!(one = ?foo.1); @@ -927,7 +1219,7 @@ fn borrow_val_events() { #[test] fn borrow_val_spans() { // Reproduces https://github.com/tokio-rs/tracing/issues/954 - let mut foo = (String::new(), String::new()); + let mut foo = (::std::string::String::new(), ::std::string::String::new()); let zero = &mut foo.0; let _span = trace_span!("span", one = ?foo.1); let _span = debug_span!("span", one = ?foo.1); @@ -961,3 +1253,19 @@ fn callsite_macro_api() { fields: foo, }; } + +#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] +#[test] +fn format_args_already_defined() { + // Reproduces: https://github.com/tokio-rs/tracing/issues/2721 + #[allow(unused)] + macro_rules! format_args { + ($i:expr) => {}; + } + event!(Level::DEBUG, "foo: {}", 3); + trace!("foo: {}", 3); + debug!("foo: {}", 3); + info!("foo: {}", 3); + warn!("foo: {}", 3); + error!("foo: {}", 3); +} diff --git a/vendor/tracing/tests/max_level_hint.rs b/vendor/tracing/tests/max_level_hint.rs index 63d3af635..2e04bc3f1 100644 --- a/vendor/tracing/tests/max_level_hint.rs +++ b/vendor/tracing/tests/max_level_hint.rs @@ -20,10 +20,10 @@ fn max_level_hints() { ); true }) - .event(event::mock().at_level(Level::INFO)) - .event(event::mock().at_level(Level::WARN)) - .event(event::mock().at_level(Level::ERROR)) - .done() + .event(expect::event().at_level(Level::INFO)) + .event(expect::event().at_level(Level::WARN)) + .event(expect::event().at_level(Level::ERROR)) + .only() .run_with_handle(); tracing::subscriber::set_global_default(subscriber).unwrap(); diff --git a/vendor/tracing/tests/multiple_max_level_hints.rs b/vendor/tracing/tests/multiple_max_level_hints.rs index dd50a193b..f78fda70f 100644 --- a/vendor/tracing/tests/multiple_max_level_hints.rs +++ b/vendor/tracing/tests/multiple_max_level_hints.rs @@ -35,10 +35,10 @@ fn multiple_max_level_hints() { ); level <= &Level::INFO }) - .event(event::mock().at_level(Level::INFO)) - .event(event::mock().at_level(Level::WARN)) - .event(event::mock().at_level(Level::ERROR)) - .done() + .event(expect::event().at_level(Level::INFO)) + .event(expect::event().at_level(Level::WARN)) + .event(expect::event().at_level(Level::ERROR)) + .only() .run_with_handle(); let (subscriber2, handle2) = subscriber::mock() .named("subscriber2") @@ -51,11 +51,11 @@ fn multiple_max_level_hints() { ); level <= &Level::DEBUG }) - .event(event::mock().at_level(Level::INFO)) - .event(event::mock().at_level(Level::DEBUG)) - .event(event::mock().at_level(Level::WARN)) - .event(event::mock().at_level(Level::ERROR)) - .done() + .event(expect::event().at_level(Level::INFO)) + .event(expect::event().at_level(Level::DEBUG)) + .event(expect::event().at_level(Level::WARN)) + .event(expect::event().at_level(Level::ERROR)) + .only() .run_with_handle(); let dispatch1 = tracing::Dispatch::new(subscriber1); diff --git a/vendor/tracing/tests/no_subscriber.rs b/vendor/tracing/tests/no_subscriber.rs index 5f927c1de..d15a2c8a1 100644 --- a/vendor/tracing/tests/no_subscriber.rs +++ b/vendor/tracing/tests/no_subscriber.rs @@ -1,14 +1,15 @@ #![cfg(feature = "std")] -use tracing::subscriber::{self, NoSubscriber}; +use tracing_mock::subscriber; #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] #[test] fn no_subscriber_disables_global() { // Reproduces https://github.com/tokio-rs/tracing/issues/1999 - let (subscriber, handle) = tracing_mock::subscriber::mock().done().run_with_handle(); - subscriber::set_global_default(subscriber).expect("setting global default must succeed"); - subscriber::with_default(NoSubscriber::default(), || { + let (subscriber, handle) = subscriber::mock().only().run_with_handle(); + tracing::subscriber::set_global_default(subscriber) + .expect("setting global default must succeed"); + tracing::subscriber::with_default(tracing::subscriber::NoSubscriber::default(), || { tracing::info!("this should not be recorded"); }); handle.assert_finished(); diff --git a/vendor/tracing/tests/scoped_clobbers_default.rs b/vendor/tracing/tests/scoped_clobbers_default.rs index 362d34a82..dfd6fc9de 100644 --- a/vendor/tracing/tests/scoped_clobbers_default.rs +++ b/vendor/tracing/tests/scoped_clobbers_default.rs @@ -8,12 +8,12 @@ fn scoped_clobbers_global() { let (scoped, scoped_handle) = subscriber::mock() .event(event::msg("before global")) .event(event::msg("before drop")) - .done() + .only() .run_with_handle(); let (global, global_handle) = subscriber::mock() .event(event::msg("after drop")) - .done() + .only() .run_with_handle(); // Set a scoped default subscriber, returning a guard. diff --git a/vendor/tracing/tests/span.rs b/vendor/tracing/tests/span.rs index 4ed650023..09f1be895 100644 --- a/vendor/tracing/tests/span.rs +++ b/vendor/tracing/tests/span.rs @@ -21,7 +21,12 @@ fn handles_to_the_same_span_are_equal() { // expect to see any spans. with_default(subscriber::mock().run(), || { let foo1 = tracing::span!(Level::TRACE, "foo"); + + // The purpose of this test is to assert that two clones of the same + // span are equal, so the clone here is kind of the whole point :) + #[allow(clippy::redundant_clone)] let foo2 = foo1.clone(); + // Two handles that point to the same span are equal. assert_eq!(foo1, foo2); }); @@ -62,12 +67,12 @@ fn handles_to_different_spans_with_the_same_metadata_are_not_equal() { #[test] fn spans_always_go_to_the_subscriber_that_tagged_them() { let subscriber1 = subscriber::mock() - .enter(span::mock().named("foo")) - .exit(span::mock().named("foo")) - .enter(span::mock().named("foo")) - .exit(span::mock().named("foo")) - .drop_span(span::mock().named("foo")) - .done() + .enter(expect::span().named("foo")) + .exit(expect::span().named("foo")) + .enter(expect::span().named("foo")) + .exit(expect::span().named("foo")) + .drop_span(expect::span().named("foo")) + .only() .run(); let subscriber2 = subscriber::mock().run(); @@ -89,12 +94,12 @@ fn spans_always_go_to_the_subscriber_that_tagged_them() { #[test] fn spans_always_go_to_the_subscriber_that_tagged_them_even_across_threads() { let subscriber1 = subscriber::mock() - .enter(span::mock().named("foo")) - .exit(span::mock().named("foo")) - .enter(span::mock().named("foo")) - .exit(span::mock().named("foo")) - .drop_span(span::mock().named("foo")) - .done() + .enter(expect::span().named("foo")) + .exit(expect::span().named("foo")) + .enter(expect::span().named("foo")) + .exit(expect::span().named("foo")) + .drop_span(expect::span().named("foo")) + .only() .run(); let foo = with_default(subscriber1, || { let foo = tracing::span!(Level::TRACE, "foo"); @@ -117,10 +122,10 @@ fn spans_always_go_to_the_subscriber_that_tagged_them_even_across_threads() { #[test] fn dropping_a_span_calls_drop_span() { let (subscriber, handle) = subscriber::mock() - .enter(span::mock().named("foo")) - .exit(span::mock().named("foo")) - .drop_span(span::mock().named("foo")) - .done() + .enter(expect::span().named("foo")) + .exit(expect::span().named("foo")) + .drop_span(expect::span().named("foo")) + .only() .run_with_handle(); with_default(subscriber, || { let span = tracing::span!(Level::TRACE, "foo"); @@ -135,11 +140,11 @@ fn dropping_a_span_calls_drop_span() { #[test] fn span_closes_after_event() { let (subscriber, handle) = subscriber::mock() - .enter(span::mock().named("foo")) - .event(event::mock()) - .exit(span::mock().named("foo")) - .drop_span(span::mock().named("foo")) - .done() + .enter(expect::span().named("foo")) + .event(expect::event()) + .exit(expect::span().named("foo")) + .drop_span(expect::span().named("foo")) + .only() .run_with_handle(); with_default(subscriber, || { tracing::span!(Level::TRACE, "foo").in_scope(|| { @@ -154,14 +159,14 @@ fn span_closes_after_event() { #[test] fn new_span_after_event() { let (subscriber, handle) = subscriber::mock() - .enter(span::mock().named("foo")) - .event(event::mock()) - .exit(span::mock().named("foo")) - .drop_span(span::mock().named("foo")) - .enter(span::mock().named("bar")) - .exit(span::mock().named("bar")) - .drop_span(span::mock().named("bar")) - .done() + .enter(expect::span().named("foo")) + .event(expect::event()) + .exit(expect::span().named("foo")) + .drop_span(expect::span().named("foo")) + .enter(expect::span().named("bar")) + .exit(expect::span().named("bar")) + .drop_span(expect::span().named("bar")) + .only() .run_with_handle(); with_default(subscriber, || { tracing::span!(Level::TRACE, "foo").in_scope(|| { @@ -177,11 +182,11 @@ fn new_span_after_event() { #[test] fn event_outside_of_span() { let (subscriber, handle) = subscriber::mock() - .event(event::mock()) - .enter(span::mock().named("foo")) - .exit(span::mock().named("foo")) - .drop_span(span::mock().named("foo")) - .done() + .event(expect::event()) + .enter(expect::span().named("foo")) + .exit(expect::span().named("foo")) + .drop_span(expect::span().named("foo")) + .only() .run_with_handle(); with_default(subscriber, || { tracing::debug!("my tracing::event!"); @@ -195,7 +200,7 @@ fn event_outside_of_span() { #[test] fn cloning_a_span_calls_clone_span() { let (subscriber, handle) = subscriber::mock() - .clone_span(span::mock().named("foo")) + .clone_span(expect::span().named("foo")) .run_with_handle(); with_default(subscriber, || { let span = tracing::span!(Level::TRACE, "foo"); @@ -211,9 +216,9 @@ fn cloning_a_span_calls_clone_span() { #[test] fn drop_span_when_exiting_dispatchers_context() { let (subscriber, handle) = subscriber::mock() - .clone_span(span::mock().named("foo")) - .drop_span(span::mock().named("foo")) - .drop_span(span::mock().named("foo")) + .clone_span(expect::span().named("foo")) + .drop_span(expect::span().named("foo")) + .drop_span(expect::span().named("foo")) .run_with_handle(); with_default(subscriber, || { let span = tracing::span!(Level::TRACE, "foo"); @@ -228,15 +233,15 @@ fn drop_span_when_exiting_dispatchers_context() { #[test] fn clone_and_drop_span_always_go_to_the_subscriber_that_tagged_the_span() { let (subscriber1, handle1) = subscriber::mock() - .enter(span::mock().named("foo")) - .exit(span::mock().named("foo")) - .clone_span(span::mock().named("foo")) - .enter(span::mock().named("foo")) - .exit(span::mock().named("foo")) - .drop_span(span::mock().named("foo")) - .drop_span(span::mock().named("foo")) + .enter(expect::span().named("foo")) + .exit(expect::span().named("foo")) + .clone_span(expect::span().named("foo")) + .enter(expect::span().named("foo")) + .exit(expect::span().named("foo")) + .drop_span(expect::span().named("foo")) + .drop_span(expect::span().named("foo")) .run_with_handle(); - let subscriber2 = subscriber::mock().done().run(); + let subscriber2 = subscriber::mock().only().run(); let foo = with_default(subscriber1, || { let foo = tracing::span!(Level::TRACE, "foo"); @@ -259,10 +264,10 @@ fn clone_and_drop_span_always_go_to_the_subscriber_that_tagged_the_span() { #[test] fn span_closes_when_exited() { let (subscriber, handle) = subscriber::mock() - .enter(span::mock().named("foo")) - .exit(span::mock().named("foo")) - .drop_span(span::mock().named("foo")) - .done() + .enter(expect::span().named("foo")) + .exit(expect::span().named("foo")) + .drop_span(expect::span().named("foo")) + .only() .run_with_handle(); with_default(subscriber, || { let foo = tracing::span!(Level::TRACE, "foo"); @@ -279,11 +284,11 @@ fn span_closes_when_exited() { #[test] fn enter() { let (subscriber, handle) = subscriber::mock() - .enter(span::mock().named("foo")) - .event(event::mock()) - .exit(span::mock().named("foo")) - .drop_span(span::mock().named("foo")) - .done() + .enter(expect::span().named("foo")) + .event(expect::event()) + .exit(expect::span().named("foo")) + .drop_span(expect::span().named("foo")) + .only() .run_with_handle(); with_default(subscriber, || { let foo = tracing::span!(Level::TRACE, "foo"); @@ -298,11 +303,11 @@ fn enter() { #[test] fn entered() { let (subscriber, handle) = subscriber::mock() - .enter(span::mock().named("foo")) - .event(event::mock()) - .exit(span::mock().named("foo")) - .drop_span(span::mock().named("foo")) - .done() + .enter(expect::span().named("foo")) + .event(expect::event()) + .exit(expect::span().named("foo")) + .drop_span(expect::span().named("foo")) + .only() .run_with_handle(); with_default(subscriber, || { let _span = tracing::span!(Level::TRACE, "foo").entered(); @@ -316,11 +321,11 @@ fn entered() { #[test] fn entered_api() { let (subscriber, handle) = subscriber::mock() - .enter(span::mock().named("foo")) - .event(event::mock()) - .exit(span::mock().named("foo")) - .drop_span(span::mock().named("foo")) - .done() + .enter(expect::span().named("foo")) + .event(expect::event()) + .exit(expect::span().named("foo")) + .drop_span(expect::span().named("foo")) + .only() .run_with_handle(); with_default(subscriber, || { let span = tracing::span!(Level::TRACE, "foo").entered(); @@ -337,16 +342,16 @@ fn entered_api() { fn moved_field() { let (subscriber, handle) = subscriber::mock() .new_span( - span::mock().named("foo").with_field( - field::mock("bar") + expect::span().named("foo").with_field( + expect::field("bar") .with_value(&display("hello from my span")) .only(), ), ) - .enter(span::mock().named("foo")) - .exit(span::mock().named("foo")) - .drop_span(span::mock().named("foo")) - .done() + .enter(expect::span().named("foo")) + .exit(expect::span().named("foo")) + .drop_span(expect::span().named("foo")) + .only() .run_with_handle(); with_default(subscriber, || { let from = "my span"; @@ -366,11 +371,11 @@ fn moved_field() { fn dotted_field_name() { let (subscriber, handle) = subscriber::mock() .new_span( - span::mock() + expect::span() .named("foo") - .with_field(field::mock("fields.bar").with_value(&true).only()), + .with_field(expect::field("fields.bar").with_value(&true).only()), ) - .done() + .only() .run_with_handle(); with_default(subscriber, || { tracing::span!(Level::TRACE, "foo", fields.bar = true); @@ -384,16 +389,16 @@ fn dotted_field_name() { fn borrowed_field() { let (subscriber, handle) = subscriber::mock() .new_span( - span::mock().named("foo").with_field( - field::mock("bar") + expect::span().named("foo").with_field( + expect::field("bar") .with_value(&display("hello from my span")) .only(), ), ) - .enter(span::mock().named("foo")) - .exit(span::mock().named("foo")) - .drop_span(span::mock().named("foo")) - .done() + .enter(expect::span().named("foo")) + .exit(expect::span().named("foo")) + .drop_span(expect::span().named("foo")) + .only() .run_with_handle(); with_default(subscriber, || { @@ -427,17 +432,17 @@ fn move_field_out_of_struct() { }; let (subscriber, handle) = subscriber::mock() .new_span( - span::mock().named("foo").with_field( - field::mock("x") + expect::span().named("foo").with_field( + expect::field("x") .with_value(&debug(3.234)) - .and(field::mock("y").with_value(&debug(-1.223))) + .and(expect::field("y").with_value(&debug(-1.223))) .only(), ), ) .new_span( - span::mock() + expect::span() .named("bar") - .with_field(field::mock("position").with_value(&debug(&pos)).only()), + .with_field(expect::field("position").with_value(&debug(&pos)).only()), ) .run_with_handle(); @@ -460,10 +465,10 @@ fn move_field_out_of_struct() { fn float_values() { let (subscriber, handle) = subscriber::mock() .new_span( - span::mock().named("foo").with_field( - field::mock("x") + expect::span().named("foo").with_field( + expect::field("x") .with_value(&3.234) - .and(field::mock("y").with_value(&-1.223)) + .and(expect::field("y").with_value(&-1.223)) .only(), ), ) @@ -485,19 +490,19 @@ fn float_values() { fn add_field_after_new_span() { let (subscriber, handle) = subscriber::mock() .new_span( - span::mock() + expect::span() .named("foo") - .with_field(field::mock("bar").with_value(&5) - .and(field::mock("baz").with_value).only()), + .with_field(expect::field("bar").with_value(&5) + .and(expect::field("baz").with_value).only()), ) .record( - span::mock().named("foo"), - field::mock("baz").with_value(&true).only(), + expect::span().named("foo"), + field::expect("baz").with_value(&true).only(), ) - .enter(span::mock().named("foo")) - .exit(span::mock().named("foo")) - .drop_span(span::mock().named("foo")) - .done() + .enter(expect::span().named("foo")) + .exit(expect::span().named("foo")) + .drop_span(expect::span().named("foo")) + .only() .run_with_handle(); with_default(subscriber, || { @@ -513,19 +518,19 @@ fn add_field_after_new_span() { #[test] fn add_fields_only_after_new_span() { let (subscriber, handle) = subscriber::mock() - .new_span(span::mock().named("foo")) + .new_span(expect::span().named("foo")) .record( - span::mock().named("foo"), - field::mock("bar").with_value(&5).only(), + expect::span().named("foo"), + field::expect("bar").with_value(&5).only(), ) .record( - span::mock().named("foo"), - field::mock("baz").with_value(&true).only(), + expect::span().named("foo"), + field::expect("baz").with_value(&true).only(), ) - .enter(span::mock().named("foo")) - .exit(span::mock().named("foo")) - .drop_span(span::mock().named("foo")) - .done() + .enter(expect::span().named("foo")) + .exit(expect::span().named("foo")) + .drop_span(expect::span().named("foo")) + .only() .run_with_handle(); with_default(subscriber, || { @@ -544,26 +549,26 @@ fn add_fields_only_after_new_span() { fn record_new_value_for_field() { let (subscriber, handle) = subscriber::mock() .new_span( - span::mock().named("foo").with_field( - field::mock("bar") + expect::span().named("foo").with_field( + expect::field("bar") .with_value(&5) - .and(field::mock("baz").with_value(&false)) + .and(expect::field("baz").with_value(&false)) .only(), ), ) .record( - span::mock().named("foo"), - field::mock("baz").with_value(&true).only(), + expect::span().named("foo"), + expect::field("baz").with_value(&true).only(), ) - .enter(span::mock().named("foo")) - .exit(span::mock().named("foo")) - .drop_span(span::mock().named("foo")) - .done() + .enter(expect::span().named("foo")) + .exit(expect::span().named("foo")) + .drop_span(expect::span().named("foo")) + .only() .run_with_handle(); with_default(subscriber, || { let span = tracing::span!(Level::TRACE, "foo", bar = 5, baz = false); - span.record("baz", &true); + span.record("baz", true); span.in_scope(|| {}) }); @@ -575,31 +580,31 @@ fn record_new_value_for_field() { fn record_new_values_for_fields() { let (subscriber, handle) = subscriber::mock() .new_span( - span::mock().named("foo").with_field( - field::mock("bar") + expect::span().named("foo").with_field( + expect::field("bar") .with_value(&4) - .and(field::mock("baz").with_value(&false)) + .and(expect::field("baz").with_value(&false)) .only(), ), ) .record( - span::mock().named("foo"), - field::mock("bar").with_value(&5).only(), + expect::span().named("foo"), + expect::field("bar").with_value(&5).only(), ) .record( - span::mock().named("foo"), - field::mock("baz").with_value(&true).only(), + expect::span().named("foo"), + expect::field("baz").with_value(&true).only(), ) - .enter(span::mock().named("foo")) - .exit(span::mock().named("foo")) - .drop_span(span::mock().named("foo")) - .done() + .enter(expect::span().named("foo")) + .exit(expect::span().named("foo")) + .drop_span(expect::span().named("foo")) + .only() .run_with_handle(); with_default(subscriber, || { let span = tracing::span!(Level::TRACE, "foo", bar = 4, baz = false); - span.record("bar", &5); - span.record("baz", &true); + span.record("bar", 5); + span.record("baz", true); span.in_scope(|| {}) }); @@ -611,12 +616,12 @@ fn record_new_values_for_fields() { fn new_span_with_target_and_log_level() { let (subscriber, handle) = subscriber::mock() .new_span( - span::mock() + expect::span() .named("foo") .with_target("app_span") .at_level(Level::DEBUG), ) - .done() + .only() .run_with_handle(); with_default(subscriber, || { @@ -630,8 +635,8 @@ fn new_span_with_target_and_log_level() { #[test] fn explicit_root_span_is_root() { let (subscriber, handle) = subscriber::mock() - .new_span(span::mock().named("foo").with_explicit_parent(None)) - .done() + .new_span(expect::span().named("foo").with_explicit_parent(None)) + .only() .run_with_handle(); with_default(subscriber, || { @@ -645,11 +650,11 @@ fn explicit_root_span_is_root() { #[test] fn explicit_root_span_is_root_regardless_of_ctx() { let (subscriber, handle) = subscriber::mock() - .new_span(span::mock().named("foo")) - .enter(span::mock().named("foo")) - .new_span(span::mock().named("bar").with_explicit_parent(None)) - .exit(span::mock().named("foo")) - .done() + .new_span(expect::span().named("foo")) + .enter(expect::span().named("foo")) + .new_span(expect::span().named("bar").with_explicit_parent(None)) + .exit(expect::span().named("foo")) + .only() .run_with_handle(); with_default(subscriber, || { @@ -665,9 +670,13 @@ fn explicit_root_span_is_root_regardless_of_ctx() { #[test] fn explicit_child() { let (subscriber, handle) = subscriber::mock() - .new_span(span::mock().named("foo")) - .new_span(span::mock().named("bar").with_explicit_parent(Some("foo"))) - .done() + .new_span(expect::span().named("foo")) + .new_span( + expect::span() + .named("bar") + .with_explicit_parent(Some("foo")), + ) + .only() .run_with_handle(); with_default(subscriber, || { @@ -682,13 +691,13 @@ fn explicit_child() { #[test] fn explicit_child_at_levels() { let (subscriber, handle) = subscriber::mock() - .new_span(span::mock().named("foo")) - .new_span(span::mock().named("a").with_explicit_parent(Some("foo"))) - .new_span(span::mock().named("b").with_explicit_parent(Some("foo"))) - .new_span(span::mock().named("c").with_explicit_parent(Some("foo"))) - .new_span(span::mock().named("d").with_explicit_parent(Some("foo"))) - .new_span(span::mock().named("e").with_explicit_parent(Some("foo"))) - .done() + .new_span(expect::span().named("foo")) + .new_span(expect::span().named("a").with_explicit_parent(Some("foo"))) + .new_span(expect::span().named("b").with_explicit_parent(Some("foo"))) + .new_span(expect::span().named("c").with_explicit_parent(Some("foo"))) + .new_span(expect::span().named("d").with_explicit_parent(Some("foo"))) + .new_span(expect::span().named("e").with_explicit_parent(Some("foo"))) + .only() .run_with_handle(); with_default(subscriber, || { @@ -707,12 +716,16 @@ fn explicit_child_at_levels() { #[test] fn explicit_child_regardless_of_ctx() { let (subscriber, handle) = subscriber::mock() - .new_span(span::mock().named("foo")) - .new_span(span::mock().named("bar")) - .enter(span::mock().named("bar")) - .new_span(span::mock().named("baz").with_explicit_parent(Some("foo"))) - .exit(span::mock().named("bar")) - .done() + .new_span(expect::span().named("foo")) + .new_span(expect::span().named("bar")) + .enter(expect::span().named("bar")) + .new_span( + expect::span() + .named("baz") + .with_explicit_parent(Some("foo")), + ) + .exit(expect::span().named("bar")) + .only() .run_with_handle(); with_default(subscriber, || { @@ -728,8 +741,8 @@ fn explicit_child_regardless_of_ctx() { #[test] fn contextual_root() { let (subscriber, handle) = subscriber::mock() - .new_span(span::mock().named("foo").with_contextual_parent(None)) - .done() + .new_span(expect::span().named("foo").with_contextual_parent(None)) + .only() .run_with_handle(); with_default(subscriber, || { @@ -743,15 +756,15 @@ fn contextual_root() { #[test] fn contextual_child() { let (subscriber, handle) = subscriber::mock() - .new_span(span::mock().named("foo")) - .enter(span::mock().named("foo")) + .new_span(expect::span().named("foo")) + .enter(expect::span().named("foo")) .new_span( - span::mock() + expect::span() .named("bar") .with_contextual_parent(Some("foo")), ) - .exit(span::mock().named("foo")) - .done() + .exit(expect::span().named("foo")) + .only() .run_with_handle(); with_default(subscriber, || { @@ -768,13 +781,13 @@ fn contextual_child() { fn display_shorthand() { let (subscriber, handle) = subscriber::mock() .new_span( - span::mock().named("my_span").with_field( - field::mock("my_field") + expect::span().named("my_span").with_field( + expect::field("my_field") .with_value(&display("hello world")) .only(), ), ) - .done() + .only() .run_with_handle(); with_default(subscriber, || { tracing::span!(Level::TRACE, "my_span", my_field = %"hello world"); @@ -788,13 +801,13 @@ fn display_shorthand() { fn debug_shorthand() { let (subscriber, handle) = subscriber::mock() .new_span( - span::mock().named("my_span").with_field( - field::mock("my_field") + expect::span().named("my_span").with_field( + expect::field("my_field") .with_value(&debug("hello world")) .only(), ), ) - .done() + .only() .run_with_handle(); with_default(subscriber, || { tracing::span!(Level::TRACE, "my_span", my_field = ?"hello world"); @@ -808,14 +821,14 @@ fn debug_shorthand() { fn both_shorthands() { let (subscriber, handle) = subscriber::mock() .new_span( - span::mock().named("my_span").with_field( - field::mock("display_field") + expect::span().named("my_span").with_field( + expect::field("display_field") .with_value(&display("hello world")) - .and(field::mock("debug_field").with_value(&debug("hello world"))) + .and(expect::field("debug_field").with_value(&debug("hello world"))) .only(), ), ) - .done() + .only() .run_with_handle(); with_default(subscriber, || { tracing::span!(Level::TRACE, "my_span", display_field = %"hello world", debug_field = ?"hello world"); @@ -823,3 +836,33 @@ fn both_shorthands() { handle.assert_finished(); } + +#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] +#[test] +fn constant_field_name() { + let (subscriber, handle) = subscriber::mock() + .new_span( + expect::span().named("my_span").with_field( + expect::field("foo") + .with_value(&"bar") + .and(expect::field("constant string").with_value(&"also works")) + .and(expect::field("foo.bar").with_value(&"baz")) + .only(), + ), + ) + .only() + .run_with_handle(); + + with_default(subscriber, || { + const FOO: &str = "foo"; + tracing::span!( + Level::TRACE, + "my_span", + { std::convert::identity(FOO) } = "bar", + { "constant string" } = "also works", + foo.bar = "baz", + ); + }); + + handle.assert_finished(); +} diff --git a/vendor/tracing/tests/subscriber.rs b/vendor/tracing/tests/subscriber.rs index 15557c107..f676efeee 100644 --- a/vendor/tracing/tests/subscriber.rs +++ b/vendor/tracing/tests/subscriber.rs @@ -11,8 +11,7 @@ use tracing::{ subscriber::{with_default, Interest, Subscriber}, Event, Level, Metadata, }; - -use tracing_mock::*; +use tracing_mock::{expect, subscriber}; #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] #[test] @@ -61,16 +60,16 @@ fn event_macros_dont_infinite_loop() { fn boxed_subscriber() { let (subscriber, handle) = subscriber::mock() .new_span( - span::mock().named("foo").with_field( - field::mock("bar") + expect::span().named("foo").with_field( + expect::field("bar") .with_value(&display("hello from my span")) .only(), ), ) - .enter(span::mock().named("foo")) - .exit(span::mock().named("foo")) - .drop_span(span::mock().named("foo")) - .done() + .enter(expect::span().named("foo")) + .exit(expect::span().named("foo")) + .drop_span(expect::span().named("foo")) + .only() .run_with_handle(); let subscriber: Box<dyn Subscriber + Send + Sync + 'static> = Box::new(subscriber); @@ -94,20 +93,20 @@ fn arced_subscriber() { let (subscriber, handle) = subscriber::mock() .new_span( - span::mock().named("foo").with_field( - field::mock("bar") + expect::span().named("foo").with_field( + expect::field("bar") .with_value(&display("hello from my span")) .only(), ), ) - .enter(span::mock().named("foo")) - .exit(span::mock().named("foo")) - .drop_span(span::mock().named("foo")) + .enter(expect::span().named("foo")) + .exit(expect::span().named("foo")) + .drop_span(expect::span().named("foo")) .event( - event::mock() - .with_fields(field::mock("message").with_value(&display("hello from my event"))), + expect::event() + .with_fields(expect::field("message").with_value(&display("hello from my event"))), ) - .done() + .only() .run_with_handle(); let subscriber: Arc<dyn Subscriber + Send + Sync + 'static> = Arc::new(subscriber); |