Support SUBUNIT_FORMATTER environment variable.
authorJelmer Vernooij <jelmer@samba.org>
Fri, 15 Jan 2010 04:16:50 +0000 (17:16 +1300)
committerJelmer Vernooij <jelmer@samba.org>
Fri, 15 Jan 2010 04:16:50 +0000 (17:16 +1300)
NEWS
python/subunit/__init__.py
python/subunit/run.py

diff --git a/NEWS b/NEWS
index 9646c3c6b2d918ab36c91e10470a32bd161fc0ce..85c5bb0615145485d9a3d80946448a2681cee624 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -11,6 +11,15 @@ BUG FIXES
 * make check was failing if subunit wasn't installed due to a missing include
   path for the test program test_child.
 
+IMPROVEMENTS
+~~~~~~~~~~~~
+
+* New filter `subunit-notify` that will show a notification window with test 
+  statistics when the test run finishes.
+
+* subunit.run will now pipe its output to the command in the 
+  SUBUNIT_FORMATTER environment variable, if set.
+
 0.0.4
 -----
 
@@ -22,12 +31,6 @@ BUG FIXES
 
 * Building with autoconf 2.65 is now supported.
 
-IMPROVEMENTS
-~~~~~~~~~~~~
-
-* New filter `subunit-notify` that will show a notification window with test 
-  statistics when the test run finishes.
-
 
 0.0.3
 -----
index 6e8df90317444eb29a957094ea4e94307871c8d3..754f9748139fcec9a64a76fb9427152e25ff52a1 100644 (file)
@@ -1111,3 +1111,16 @@ class TestResultStats(unittest.TestResult):
     def wasSuccessful(self):
         """Tells whether or not this result was a success"""
         return self.failed_tests == 0
+
+
+def get_default_formatter():
+    """Obtain the default formatter to write to.
+    
+    :return: A file-like object.
+    """
+    formatter = os.getenv("SUBUNIT_FORMATTER")
+    if formatter is not None:
+        return os.popen(formatter, "w")
+    else:
+        return sys.stdout
+
index 2b90791d69cc4a5a1a10bc878925978790985f03..01c0b0e9e6b35911b06db3e3a534769a1cbe41de 100755 (executable)
@@ -22,7 +22,7 @@
 
 import sys
 
-from subunit import TestProtocolClient
+from subunit import TestProtocolClient, get_default_formatter
 
 
 class SubunitTestRunner(object):
@@ -41,6 +41,7 @@ if __name__ == '__main__':
     from unittest import TestProgram
     parser = optparse.OptionParser(__doc__)
     args = parser.parse_args()[1]
-    runner = SubunitTestRunner()
+    stream = get_default_formatter()
+    runner = SubunitTestRunner(stream)
     program = TestProgram(module=None, argv=[sys.argv[0]] + args,
                           testRunner=runner)