Vendor things
This commit is contained in:
parent
5deceec006
commit
977e3c17e5
19434 changed files with 10682014 additions and 0 deletions
30
third-party/vendor/tracing-core/tests/common/mod.rs
vendored
Normal file
30
third-party/vendor/tracing-core/tests/common/mod.rs
vendored
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
use tracing_core::{metadata::Metadata, span, subscriber::Subscriber, Event};
|
||||
|
||||
pub struct TestSubscriberA;
|
||||
impl Subscriber for TestSubscriberA {
|
||||
fn enabled(&self, _: &Metadata<'_>) -> bool {
|
||||
true
|
||||
}
|
||||
fn new_span(&self, _: &span::Attributes<'_>) -> span::Id {
|
||||
span::Id::from_u64(1)
|
||||
}
|
||||
fn record(&self, _: &span::Id, _: &span::Record<'_>) {}
|
||||
fn record_follows_from(&self, _: &span::Id, _: &span::Id) {}
|
||||
fn event(&self, _: &Event<'_>) {}
|
||||
fn enter(&self, _: &span::Id) {}
|
||||
fn exit(&self, _: &span::Id) {}
|
||||
}
|
||||
pub struct TestSubscriberB;
|
||||
impl Subscriber for TestSubscriberB {
|
||||
fn enabled(&self, _: &Metadata<'_>) -> bool {
|
||||
true
|
||||
}
|
||||
fn new_span(&self, _: &span::Attributes<'_>) -> span::Id {
|
||||
span::Id::from_u64(1)
|
||||
}
|
||||
fn record(&self, _: &span::Id, _: &span::Record<'_>) {}
|
||||
fn record_follows_from(&self, _: &span::Id, _: &span::Id) {}
|
||||
fn event(&self, _: &Event<'_>) {}
|
||||
fn enter(&self, _: &span::Id) {}
|
||||
fn exit(&self, _: &span::Id) {}
|
||||
}
|
||||
56
third-party/vendor/tracing-core/tests/dispatch.rs
vendored
Normal file
56
third-party/vendor/tracing-core/tests/dispatch.rs
vendored
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
#![cfg(feature = "std")]
|
||||
mod common;
|
||||
|
||||
use common::*;
|
||||
use tracing_core::dispatcher::*;
|
||||
|
||||
#[test]
|
||||
fn set_default_dispatch() {
|
||||
set_global_default(Dispatch::new(TestSubscriberA)).expect("global dispatch set failed");
|
||||
get_default(|current| {
|
||||
assert!(
|
||||
current.is::<TestSubscriberA>(),
|
||||
"global dispatch get failed"
|
||||
)
|
||||
});
|
||||
|
||||
let guard = set_default(&Dispatch::new(TestSubscriberB));
|
||||
get_default(|current| assert!(current.is::<TestSubscriberB>(), "set_default get failed"));
|
||||
|
||||
// Drop the guard, setting the dispatch back to the global dispatch
|
||||
drop(guard);
|
||||
|
||||
get_default(|current| {
|
||||
assert!(
|
||||
current.is::<TestSubscriberA>(),
|
||||
"global dispatch get failed"
|
||||
)
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn nested_set_default() {
|
||||
let _guard = set_default(&Dispatch::new(TestSubscriberA));
|
||||
get_default(|current| {
|
||||
assert!(
|
||||
current.is::<TestSubscriberA>(),
|
||||
"set_default for outer subscriber failed"
|
||||
)
|
||||
});
|
||||
|
||||
let inner_guard = set_default(&Dispatch::new(TestSubscriberB));
|
||||
get_default(|current| {
|
||||
assert!(
|
||||
current.is::<TestSubscriberB>(),
|
||||
"set_default inner subscriber failed"
|
||||
)
|
||||
});
|
||||
|
||||
drop(inner_guard);
|
||||
get_default(|current| {
|
||||
assert!(
|
||||
current.is::<TestSubscriberA>(),
|
||||
"set_default outer subscriber failed"
|
||||
)
|
||||
});
|
||||
}
|
||||
34
third-party/vendor/tracing-core/tests/global_dispatch.rs
vendored
Normal file
34
third-party/vendor/tracing-core/tests/global_dispatch.rs
vendored
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
mod common;
|
||||
|
||||
use common::*;
|
||||
use tracing_core::dispatcher::*;
|
||||
#[test]
|
||||
fn global_dispatch() {
|
||||
set_global_default(Dispatch::new(TestSubscriberA)).expect("global dispatch set failed");
|
||||
get_default(|current| {
|
||||
assert!(
|
||||
current.is::<TestSubscriberA>(),
|
||||
"global dispatch get failed"
|
||||
)
|
||||
});
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
with_default(&Dispatch::new(TestSubscriberB), || {
|
||||
get_default(|current| {
|
||||
assert!(
|
||||
current.is::<TestSubscriberB>(),
|
||||
"thread-local override of global dispatch failed"
|
||||
)
|
||||
});
|
||||
});
|
||||
|
||||
get_default(|current| {
|
||||
assert!(
|
||||
current.is::<TestSubscriberA>(),
|
||||
"reset to global override failed"
|
||||
)
|
||||
});
|
||||
|
||||
set_global_default(Dispatch::new(TestSubscriberA))
|
||||
.expect_err("double global dispatch set succeeded");
|
||||
}
|
||||
43
third-party/vendor/tracing-core/tests/local_dispatch_before_init.rs
vendored
Normal file
43
third-party/vendor/tracing-core/tests/local_dispatch_before_init.rs
vendored
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
mod common;
|
||||
|
||||
use common::*;
|
||||
use tracing_core::{
|
||||
dispatcher::{self, Dispatch},
|
||||
subscriber::NoSubscriber,
|
||||
};
|
||||
|
||||
/// This test reproduces the following issues:
|
||||
/// - https://github.com/tokio-rs/tracing/issues/2587
|
||||
/// - https://github.com/tokio-rs/tracing/issues/2411
|
||||
/// - https://github.com/tokio-rs/tracing/issues/2436
|
||||
#[test]
|
||||
fn local_dispatch_before_init() {
|
||||
dispatcher::get_default(|current| assert!(dbg!(current).is::<NoSubscriber>()));
|
||||
|
||||
// Temporarily override the default dispatcher with a scoped dispatcher.
|
||||
// Using a scoped dispatcher makes the thread local state attempt to cache
|
||||
// the scoped default.
|
||||
#[cfg(feature = "std")]
|
||||
{
|
||||
dispatcher::with_default(&Dispatch::new(TestSubscriberB), || {
|
||||
dispatcher::get_default(|current| {
|
||||
assert!(
|
||||
dbg!(current).is::<TestSubscriberB>(),
|
||||
"overriden subscriber not set",
|
||||
);
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
dispatcher::get_default(|current| assert!(current.is::<NoSubscriber>()));
|
||||
|
||||
dispatcher::set_global_default(Dispatch::new(TestSubscriberA))
|
||||
.expect("set global dispatch failed");
|
||||
|
||||
dispatcher::get_default(|current| {
|
||||
assert!(
|
||||
dbg!(current).is::<TestSubscriberA>(),
|
||||
"default subscriber not set"
|
||||
);
|
||||
});
|
||||
}
|
||||
48
third-party/vendor/tracing-core/tests/macros.rs
vendored
Normal file
48
third-party/vendor/tracing-core/tests/macros.rs
vendored
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
use tracing_core::{
|
||||
callsite::Callsite,
|
||||
metadata,
|
||||
metadata::{Kind, Level, Metadata},
|
||||
subscriber::Interest,
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn metadata_macro_api() {
|
||||
// This test should catch any inadvertent breaking changes
|
||||
// caused by changes to the macro.
|
||||
struct TestCallsite;
|
||||
|
||||
impl Callsite for TestCallsite {
|
||||
fn set_interest(&self, _: Interest) {
|
||||
unimplemented!("test")
|
||||
}
|
||||
fn metadata(&self) -> &Metadata<'_> {
|
||||
unimplemented!("test")
|
||||
}
|
||||
}
|
||||
|
||||
static CALLSITE: TestCallsite = TestCallsite;
|
||||
let _metadata = metadata! {
|
||||
name: "test_metadata",
|
||||
target: "test_target",
|
||||
level: Level::DEBUG,
|
||||
fields: &["foo", "bar", "baz"],
|
||||
callsite: &CALLSITE,
|
||||
kind: Kind::SPAN,
|
||||
};
|
||||
let _metadata = metadata! {
|
||||
name: "test_metadata",
|
||||
target: "test_target",
|
||||
level: Level::TRACE,
|
||||
fields: &[],
|
||||
callsite: &CALLSITE,
|
||||
kind: Kind::EVENT,
|
||||
};
|
||||
let _metadata = metadata! {
|
||||
name: "test_metadata",
|
||||
target: "test_target",
|
||||
level: Level::INFO,
|
||||
fields: &[],
|
||||
callsite: &CALLSITE,
|
||||
kind: Kind::EVENT
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue