[llvm-commits] [zorg] r151020 - in /zorg/trunk/lnt/lnt: testing/util/misc.py tests/compile.py

Daniel Dunbar daniel at zuster.org
Mon Feb 20 18:53:27 PST 2012


Author: ddunbar
Date: Mon Feb 20 20:53:26 2012
New Revision: 151020

URL: http://llvm.org/viewvc/llvm-project?rev=151020&view=rev
Log:
[lnt] lnt.tests.compile: Log output to stderr as well.
 - The core infrastructure should just support this, and use the logging module, but I am still lazy.

Modified:
    zorg/trunk/lnt/lnt/testing/util/misc.py
    zorg/trunk/lnt/lnt/tests/compile.py

Modified: zorg/trunk/lnt/lnt/testing/util/misc.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/testing/util/misc.py?rev=151020&r1=151019&r2=151020&view=diff
==============================================================================
--- zorg/trunk/lnt/lnt/testing/util/misc.py (original)
+++ zorg/trunk/lnt/lnt/testing/util/misc.py Mon Feb 20 20:53:26 2012
@@ -1,4 +1,27 @@
 import datetime
 
+class TeeStream(object):
+    """File-like object for writing to multiple output streams."""
+
+    def __init__(self, a, b):
+        self.a = a
+        self.b = b
+
+    def __del__(self):
+        del self.a
+        del self.b
+
+    def close(self):
+        self.a.close()
+        self.b.close()
+
+    def write(self, value):
+        self.a.write(value)
+        self.b.write(value)
+
+    def flush(self):
+        self.a.flush()
+        self.b.flush()
+
 def timestamp():
     return datetime.datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S')

Modified: zorg/trunk/lnt/lnt/tests/compile.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/tests/compile.py?rev=151020&r1=151019&r2=151020&view=diff
==============================================================================
--- zorg/trunk/lnt/lnt/tests/compile.py (original)
+++ zorg/trunk/lnt/lnt/tests/compile.py Mon Feb 20 20:53:26 2012
@@ -10,7 +10,7 @@
 import lnt.testing.util.compilers
 from lnt.testing.util.commands import note, warning, error, fatal
 from lnt.testing.util.commands import capture, rm_f
-from lnt.testing.util.misc import timestamp
+from lnt.testing.util.misc import TeeStream, timestamp
 from lnt.testing.util import machineinfo
 
 # Interface to runN.
@@ -458,6 +458,9 @@
         test_log_path = os.path.join(g_output_dir, 'test.log')
         test_log = open(test_log_path, 'w')
 
+        # Tee the output to stderr as well.
+        test_log = TeeStream(test_log, sys.stderr)
+
         # Execute the run.
         run_info.update(variables)
         run_info['tag'] = tag = 'compile'





More information about the llvm-commits mailing list