[tor-commits] [stem/master] Tests errored with a '--log' argument

atagar at torproject.org atagar at torproject.org
Mon Feb 10 23:06:56 UTC 2020


commit a668cd8f4958431a3a5dbb33662e2acc304ee67a
Author: Damian Johnson <atagar at torproject.org>
Date:   Mon Feb 10 15:05:17 2020 -0800

    Tests errored with a '--log' argument
    
    Oops, I removed our LogBuffer in commit 76b6b49 but it's still used by
    run_tests.py when we have a '--log' argument. Caught thanks to our Jenkins
    tests...
    
      Traceback (most recent call last):
        File "./run_tests.py", line 478, in <module>
          main()
        File "./run_tests.py", line 238, in main
          handler = logging_buffer = stem.util.log.LogBuffer(args.logging_runlevel)
      AttributeError: module 'stem.util.log' has no attribute 'LogBuffer'
---
 run_tests.py   | 7 +++++--
 test/output.py | 6 +++---
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/run_tests.py b/run_tests.py
index 91333084..16fbe267 100755
--- a/run_tests.py
+++ b/run_tests.py
@@ -10,8 +10,10 @@ import errno
 import io
 import importlib
 import logging
+import logging.handlers
 import multiprocessing
 import os
+import queue
 import signal
 import sys
 import threading
@@ -227,7 +229,7 @@ def main():
   # Test logging. If '--log-file' is provided we log to that location,
   # otherwise we buffer messages and log to stdout after its test completes.
 
-  logging_buffer = None
+  logging_buffer = queue.Queue()
 
   if args.logging_runlevel:
     if args.logging_path:
@@ -235,7 +237,8 @@ def main():
       handler.setLevel(stem.util.log.logging_level(args.logging_runlevel))
       handler.setFormatter(stem.util.log.FORMATTER)
     else:
-      handler = logging_buffer = stem.util.log.LogBuffer(args.logging_runlevel)
+      handler = logging.handlers.QueueHandler(logging_buffer)
+      handler.setLevel(stem.util.log.logging_level(args.logging_runlevel))
 
     stem.util.log.get_logger().addHandler(handler)
 
diff --git a/test/output.py b/test/output.py
index efd27b56..4ee5dfa2 100644
--- a/test/output.py
+++ b/test/output.py
@@ -87,9 +87,9 @@ def print_logging(logging_buffer):
   if SUPPRESS_STDOUT or logging_buffer is None:
     return
 
-  if not logging_buffer.is_empty():
-    for entry in logging_buffer:
-      println(entry.replace('\n', '\n  '), term.Color.MAGENTA)
+  if not logging_buffer.empty():
+    while not logging_buffer.empty():
+      println(logging_buffer.get_nowait().getMessage().replace('\n', '\n  '), term.Color.MAGENTA)
 
     print('')
 



More information about the tor-commits mailing list