SVN: zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/ Moved some of the subprocess management into its own feature.

Christian Theune <[email protected]>
Newsgroups gmane.comp.web.zope.zope3.cvs
Message-ID <20080504163235.144633998B__16683.4334181205$1209918811$gmane$org@mail.zope.org>
Log message for revision 86404:
  Moved some of the subprocess management into its own feature.
  

Changed:
  U   zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/filter.py
  U   zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/runner.py
  A   zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/subprocess.py

-=-
Modified: zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/filter.py
===================================================================
--- zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/filter.py	2008-05-04 16:31:37 UTC (rev 86403)
+++ zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/filter.py	2008-05-04 16:32:34 UTC (rev 86404)
@@ -47,3 +47,10 @@
 
             if not should_run:
                 tests.pop('unit')
+
+        if self.runner.options.verbose:
+            if self.runner.options.all:
+                msg = "Running tests at all levels"
+            else:
+                msg = "Running tests at level %d" % self.runner.options.at_level
+            self.runner.options.output.info(msg)

Modified: zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/runner.py
===================================================================
--- zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/runner.py	2008-05-04 16:31:37 UTC (rev 86403)
+++ zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/runner.py	2008-05-04 16:32:34 UTC (rev 86404)
@@ -44,6 +44,7 @@
 import zope.testing.testrunner.filter
 import zope.testing.testrunner.garbagecollection
 import zope.testing.testrunner.listing
+import zope.testing.testrunner.subprocess
 
 
 PYREFCOUNT_PATTERN = re.compile('\[[0-9]+ refs\]')
@@ -129,17 +130,6 @@
         for feature in self.features:
             feature.global_setup()
 
-        # XXX Where should this go?
-        if self.options.resume_layer:
-            self.original_stderr = sys.stderr
-            sys.stderr = sys.stdout
-        elif self.options.verbose:
-            if self.options.all:
-                msg = "Running tests at all levels"
-            else:
-                msg = "Running tests at level %d" % self.options.at_level
-            self.options.output.info(msg)
-
         # Late setup
         #
         # Some system tools like profilers are really bad with stack frames.
@@ -204,6 +194,7 @@
         self.features.append(zope.testing.testrunner.garbagecollection.Threshold(self))
         self.features.append(zope.testing.testrunner.garbagecollection.Debug(self))
         self.features.append(zope.testing.testrunner.find.Find(self))
+        self.features.append(zope.testing.testrunner.subprocess.SubProcess(self))
         self.features.append(zope.testing.testrunner.filter.Filter(self))
         self.features.append(zope.testing.testrunner.listing.Listing(self))
 
@@ -267,16 +258,7 @@
         self.failed = bool(self.import_errors or self.failures or self.errors)
 
     def report(self):
-        if self.options.resume_layer:
-            sys.stdout.close()
-            # Communicate with the parent.  The protocol is obvious:
-            print >> self.original_stderr, self.ran, len(self.failures), len(self.errors)
-            for test, exc_info in self.failures:
-                print >> self.original_stderr, ' '.join(str(test).strip().split('\n'))
-            for test, exc_info in self.errors:
-                print >> self.original_stderr, ' '.join(str(test).strip().split('\n'))
-
-        else:
+        if not self.options.resume_layer:
             if self.options.verbose:
                 self.options.output.tests_with_errors(self.errors)
                 self.options.output.tests_with_failures(self.failures)
@@ -286,7 +268,6 @@
                                            len(self.errors), self.total_time)
 
 
-
 def run_tests(options, tests, name, failures, errors):
     repeat = options.repeat or 1
     repeat_range = iter(range(repeat))

Added: zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/subprocess.py
===================================================================
--- zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/subprocess.py	                        (rev 0)
+++ zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/subprocess.py	2008-05-04 16:32:34 UTC (rev 86404)
@@ -0,0 +1,44 @@
+##############################################################################
+#
+# Copyright (c) 2004-2008 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Subprocess support.
+
+$Id: __init__.py 86218 2008-05-03 14:17:26Z ctheune $
+"""
+
+import sys
+import time
+import zope.testing.testrunner.feature
+
+
+class SubProcess(zope.testing.testrunner.feature.Feature):
+    """Lists all tests in the report instead of running the tests."""
+
+    def __init__(self, runner):
+        super(SubProcess, self).__init__(runner)
+        self.active = bool(runner.options.resume_layer)
+
+    def global_setup(self):
+        self.original_stderr = sys.stderr
+        sys.stderr = sys.stdout
+        self.runner.options.verbose = False
+
+    def report(self):
+        sys.stdout.close()
+        # Communicate with the parent.  The protocol is obvious:
+        print >> self.original_stderr, self.runner.ran, \
+                len(self.runner.failures), len(self.runner.errors)
+        for test, exc_info in self.runner.failures:
+            print >> self.original_stderr, ' '.join(str(test).strip().split('\n'))
+        for test, exc_info in self.runner.errors:
+            print >> self.original_stderr, ' '.join(str(test).strip().split('\n'))


Property changes on: zope.testing/branches/ctheune-cleanup/src/zope/testing/testrunner/subprocess.py
___________________________________________________________________
Name: svn:eol-style
   + native
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.