[Piglit] [PATCH 5/5] framework: Add dummy logger that produces no output

Dylan Baker baker.dylan.c at gmail.com
Wed Aug 13 16:36:23 PDT 2014


From: Dylan Baker <baker.dylan.c at gmail.com>

This adds a new logger option that produces no output. This is aimed at
headless setups or for systems like jenkins where the output data isn't
very useful.

Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
 framework/log.py             | 16 ++++++++++++++++
 framework/tests/log_tests.py |  6 ++++++
 2 files changed, 22 insertions(+)

diff --git a/framework/log.py b/framework/log.py
index 6b350e8..a3d7a25 100644
--- a/framework/log.py
+++ b/framework/log.py
@@ -229,6 +229,21 @@ class VerboseLog(QuietLog):
             super(VerboseLog, self).log(value)
 
 
+class DummyLog(BaseLog):
+    """ A Logger that does nothing """
+    def __init__(self, state):
+        pass
+
+    def start(self, name):
+        pass
+
+    def log(self, status):
+        pass
+
+    def summary(self):
+        pass
+
+
 class LogManager(object):
     """ Creates new log objects
 
@@ -250,6 +265,7 @@ class LogManager(object):
     LOG_MAP = {
         'quiet': QuietLog,
         'verbose': VerboseLog,
+        'dummy': DummyLog,
     }
 
     def __init__(self, logger, total):
diff --git a/framework/tests/log_tests.py b/framework/tests/log_tests.py
index 20ea52c..a71f3ca 100644
--- a/framework/tests/log_tests.py
+++ b/framework/tests/log_tests.py
@@ -147,6 +147,12 @@ def test_noprint_when_expected():
     quiet = log.QuietLog(TEST_STATE)
     printing.append(('QuietLog.start', quiet.start, ['name']))
 
+    # Test DummyLog
+    dummy = log.DummyLog(TEST_STATE)
+    printing.append(('DummyLog.start', dummy.start, ['name']))
+    printing.append(('DummyLog.log', dummy.log, ['pass']))
+    printing.append(('DummyLog.summary', dummy.summary, []))
+
     for name, func, args in printing:
         check_no_output.description = "{} produces no output".format(name)
         yield check_no_output, func, args
-- 
2.0.4



More information about the Piglit mailing list