1mod common;
2
3use common::*;
4use tracing_core::dispatcher::*;
5#[test]
6fn global_dispatch() {
7 set_global_default(Dispatch::new(TestSubscriberA)).expect("global dispatch set failed");
8 get_default(|current| {
9 assert!(
10 current.is::<TestSubscriberA>(),
11 "global dispatch get failed"
12 )
13 });
14
15 #[cfg(feature = "std")]
16 with_default(&Dispatch::new(TestSubscriberB), || {
17 get_default(|current| {
18 assert!(
19 current.is::<TestSubscriberB>(),
20 "thread-local override of global dispatch failed"
21 )
22 });
23 });
24
25 get_default(|current| {
26 assert!(
27 current.is::<TestSubscriberA>(),
28 "reset to global override failed"
29 )
30 });
31
32 set_global_default(Dispatch::new(TestSubscriberA))
33 .expect_err("double global dispatch set succeeded");
34}
35