[llvm-commits] [zorg] r141466 - /zorg/trunk/lnt/lnt/tests/nt.py

Daniel Dunbar daniel at zuster.org
Fri Oct 7 18:01:33 PDT 2011


Author: ddunbar
Date: Fri Oct  7 20:01:33 2011
New Revision: 141466

URL: http://llvm.org/viewvc/llvm-project?rev=141466&view=rev
Log:
LNT/nt: Add a TestModule.log ivar for use by test module implementations.

Modified:
    zorg/trunk/lnt/lnt/tests/nt.py

Modified: zorg/trunk/lnt/lnt/tests/nt.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/tests/nt.py?rev=141466&r1=141465&r2=141466&view=diff
==============================================================================
--- zorg/trunk/lnt/lnt/tests/nt.py (original)
+++ zorg/trunk/lnt/lnt/tests/nt.py Fri Oct  7 20:01:33 2011
@@ -23,12 +23,29 @@
     Base class for extension test modules.
     """
 
+    def __init__(self):
+        self._log = None
+
     def main(self):
         raise NotImplementedError
 
     def execute_test(self, options):
         abstract
 
+    def _execute_test(self, test_log, options):
+        self._log = test_log
+        try:
+            return self.execute_test(options)
+        finally:
+            self._log = None
+
+    @property
+    def log(self):
+        """Get the test log output stream."""
+        if self._log is None:
+            raise ValueError("log() unavailable outside test execution")
+        return self._log
+        
 ###
 
 def timestamp():
@@ -82,7 +99,9 @@
         try:
             exec module_file in locals, globals
         except:
-            fatal("unable to import test module: %r" % module_path)
+            info = traceback.format_exc()
+            fatal("unable to import test module: %r\n%s" % (
+                    module_path, info))
 
         # Lookup and instantiate the test class.
         test_class = globals.get('test_class')
@@ -107,7 +126,7 @@
 
         # Execute the tests.
         try:
-            test_samples = test_instance.execute_test(variables)
+            test_samples = test_instance._execute_test(test_log, variables)
         except:
             info = traceback.format_exc()
             fatal("exception executing tests for: %r\n%s" % (





More information about the llvm-commits mailing list