Преглед изворни кода

Remove manual `log::set_logger` from tests.

No longer needed since `net_debug!` and `net_trace!` now call `println!` directly
when testing!
Dario Nieuwenhuis пре 3 година
родитељ
комит
e0ace4b8ee
2 измењених фајлова са 0 додато и 57 уклоњено
  1. 0 27
      src/socket/dhcpv4.rs
  2. 0 30
      src/socket/tcp.rs

+ 0 - 27
src/socket/dhcpv4.rs

@@ -651,30 +651,6 @@ mod test {
         });
     }
 
-    #[cfg(feature = "log")]
-    fn init_logger() {
-        struct Logger;
-        static LOGGER: Logger = Logger;
-
-        impl log::Log for Logger {
-            fn enabled(&self, _metadata: &log::Metadata) -> bool {
-                true
-            }
-
-            fn log(&self, record: &log::Record) {
-                println!("{}", record.args());
-            }
-
-            fn flush(&self) {}
-        }
-
-        // If it fails, that just means we've already set it to the same value.
-        let _ = log::set_logger(&LOGGER);
-        log::set_max_level(log::LevelFilter::Trace);
-
-        println!();
-    }
-
     // =========================================================================================//
     // Constants
 
@@ -822,9 +798,6 @@ mod test {
     // Tests
 
     fn socket() -> Dhcpv4Socket {
-        #[cfg(feature = "log")]
-        init_logger();
-
         let mut s = Dhcpv4Socket::new();
         assert_eq!(s.poll(), Some(Event::Deconfigured));
         s

+ 0 - 30
src/socket/tcp.rs

@@ -2648,38 +2648,11 @@ mod test {
         }};
     }
 
-    #[cfg(feature = "log")]
-    fn init_logger() {
-        struct Logger;
-        static LOGGER: Logger = Logger;
-
-        impl log::Log for Logger {
-            fn enabled(&self, _metadata: &log::Metadata) -> bool {
-                true
-            }
-
-            fn log(&self, record: &log::Record) {
-                println!("{}", record.args());
-            }
-
-            fn flush(&self) {}
-        }
-
-        // If it fails, that just means we've already set it to the same value.
-        let _ = log::set_logger(&LOGGER);
-        log::set_max_level(log::LevelFilter::Trace);
-
-        println!();
-    }
-
     fn socket() -> TcpSocket<'static> {
         socket_with_buffer_sizes(64, 64)
     }
 
     fn socket_with_buffer_sizes(tx_len: usize, rx_len: usize) -> TcpSocket<'static> {
-        #[cfg(feature = "log")]
-        init_logger();
-
         let rx_buffer = SocketBuffer::new(vec![0; rx_len]);
         let tx_buffer = SocketBuffer::new(vec![0; tx_len]);
         let mut socket = TcpSocket::new(rx_buffer, tx_buffer);
@@ -7048,9 +7021,6 @@ mod test {
 
     #[test]
     fn test_rtt_estimator() {
-        #[cfg(feature = "log")]
-        init_logger();
-
         let mut r = RttEstimator::default();
 
         let rtos = &[