no_subscriber.rs 597 B

123456789101112131415
  1. #![cfg(feature = "std")]
  2. use tracing::subscriber::{self, NoSubscriber};
  3. #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
  4. #[test]
  5. fn no_subscriber_disables_global() {
  6. // Reproduces https://github.com/tokio-rs/tracing/issues/1999
  7. let (subscriber, handle) = tracing_mock::subscriber::mock().done().run_with_handle();
  8. subscriber::set_global_default(subscriber).expect("setting global default must succeed");
  9. subscriber::with_default(NoSubscriber::default(), || {
  10. tracing::info!("this should not be recorded");
  11. });
  12. handle.assert_finished();
  13. }