[Zope3-checkins]
SVN: zope.testing/branches/benji-optimize/src/zope/testing/testrunner/runner.py
checkpoint; tests pass
Benji York
benji at zope.com
Sat Jul 12 06:45:38 EDT 2008
Log message for revision 88281:
checkpoint; tests pass
Changed:
U zope.testing/branches/benji-optimize/src/zope/testing/testrunner/runner.py
-=-
Modified: zope.testing/branches/benji-optimize/src/zope/testing/testrunner/runner.py
===================================================================
--- zope.testing/branches/benji-optimize/src/zope/testing/testrunner/runner.py 2008-07-12 10:45:10 UTC (rev 88280)
+++ zope.testing/branches/benji-optimize/src/zope/testing/testrunner/runner.py 2008-07-12 10:45:38 UTC (rev 88281)
@@ -21,6 +21,7 @@
import glob
import os
import pdb
+import pickle
import re
import sys
import tempfile
@@ -74,6 +75,26 @@
"""
+def fork_and_call(func, *args, **kws):
+ if not hasattr(os, 'fork'):
+ return func(*args, **kws)
+
+ read_pipe, write_pipe = os.pipe()
+ pid = os.fork()
+ if pid: # am parent
+ os.close(write_pipe)
+ child_exit = os.waitpid(pid)
+ assert child_exit == 0
+ result = pickle.loads(os.read(read_pipe, 999999))
+ else: # am child
+ os.close(read_pipe)
+ result = func(*args, **kws)
+ os.write(write_pipe, pickle.dumps(result))
+ os.exit(0)
+
+ return result # will only get here in the parent
+
+
class Runner(object):
"""The test runner.
@@ -212,8 +233,10 @@
for feature in self.features:
feature.layer_setup(layer)
try:
- self.ran += run_layer(self.options, layer_name, layer, tests,
- setup_layers, self.failures, self.errors)
+ (ran, self.options, layer, tests, setup_layers, self.failures,
+ self.errors) = run_layer(self.options, layer_name, layer,
+ tests, setup_layers, self.failures, self.errors)
+ self.ran += ran
except EndRun:
self.failed = True
return
@@ -360,10 +383,12 @@
traceback.print_exc(file=f)
output.error(f.getvalue())
errors.append((SetUpLayerFailure(), sys.exc_info()))
- return 0
+ ran = 0
else:
- return run_tests(options, tests, layer_name, failures, errors)
+ ran = run_tests(options, tests, layer_name, failures, errors)
+ return ran, options, layer, tests, setup_layers, failures, errors
+
class SetUpLayerFailure(unittest.TestCase):
def runTest(self):
More information about the Zope3-Checkins
mailing list