Ver código fonte

Better error message when handling test loggers.

Jing Yang 4 anos atrás
pai
commit
5cec503a1c
2 arquivos alterados com 4 adições e 2 exclusões
  1. 2 1
      test_utils/src/logging.rs
  2. 2 1
      test_utils/src/thread_local_logger.rs

+ 2 - 1
test_utils/src/logging.rs

@@ -6,7 +6,8 @@ use rand::Rng;
 #[macro_export]
 macro_rules! init_test_log {
     () => {
-        $crate::init_log(stdext::function_name!()).unwrap()
+        $crate::init_log(stdext::function_name!())
+            .expect("Initializing test log should never fail")
     };
 }
 

+ 2 - 1
test_utils/src/thread_local_logger.rs

@@ -20,7 +20,8 @@ pub fn global_init_once() {
     static INIT_LOG_ONCE: Once = Once::new();
 
     INIT_LOG_ONCE.call_once(|| {
-        log::set_logger(&GLOBAL_LOGGER).unwrap();
+        log::set_logger(&GLOBAL_LOGGER)
+            .expect("Set global logger should never fail");
         // Enable all logging globally. Each local logger should have its own
         // filtering, which could be less efficient.
         log::set_max_level(log::LevelFilter::max());