Rev 4230: Fix selftest --parallel for ConcurrentTestSuite uses. in file:///home/vila/src/bzr/experimental/parallel-selftest/
Vincent Ladeuil
v.ladeuil+lp at free.fr
Wed Apr 1 11:44:19 BST 2009
At file:///home/vila/src/bzr/experimental/parallel-selftest/
------------------------------------------------------------
revno: 4230
revision-id: v.ladeuil+lp at free.fr-20090401104418-tev44lw48rzxcfw0
parent: pqm at pqm.ubuntu.com-20090401063434-motksin95y4undi6
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: parallel-selftest
timestamp: Wed 2009-04-01 12:44:18 +0200
message:
Fix selftest --parallel for ConcurrentTestSuite uses.
* bzrlib/tests/__init__.py:
(TextTestRunner.run): The test type matters here, not the
result (which is set just above).
-------------- next part --------------
=== modified file 'bzrlib/tests/__init__.py'
--- a/bzrlib/tests/__init__.py 2009-04-01 04:55:36 +0000
+++ b/bzrlib/tests/__init__.py 2009-04-01 10:44:18 +0000
@@ -545,11 +545,12 @@
actionTaken = "Listed"
else:
try:
- from testtools import ThreadsafeForwardingResult
+ import testtools
except ImportError:
test.run(result)
else:
- if type(result) == ThreadsafeForwardingResult:
+ if type(test) == testtools.ConcurrentTestSuite:
+ # We need to catch bzr specific behaviors
test.run(BZRTransformingResult(result))
else:
test.run(result)
@@ -2676,19 +2677,27 @@
# A registry where get() returns a suite decorator.
parallel_registry = registry.Registry()
+
+
def fork_decorator(suite):
concurrency = local_concurrency()
if concurrency == 1:
return suite
from testtools import ConcurrentTestSuite
return ConcurrentTestSuite(suite, fork_for_tests)
+
+
parallel_registry.register('fork', fork_decorator)
+
+
def subprocess_decorator(suite):
concurrency = local_concurrency()
if concurrency == 1:
return suite
from testtools import ConcurrentTestSuite
return ConcurrentTestSuite(suite, reinvoke_for_tests)
+
+
parallel_registry.register('subprocess', subprocess_decorator)
@@ -2874,8 +2883,7 @@
"""Take suite and start up one runner per CPU by forking()
:return: An iterable of TestCase-like objects which can each have
- run(result) called on them to feed tests to result, and
- cleanup() called on them to stop them/kill children/end threads.
+ run(result) called on them to feed tests to result.
"""
concurrency = local_concurrency()
result = []
@@ -2891,7 +2899,6 @@
ProtocolTestCase.run(self, result)
finally:
os.waitpid(self.pid, os.WNOHANG)
- # print "pid %d finished" % finished_process
test_blocks = partition_tests(suite, concurrency)
for process_tests in test_blocks:
@@ -2905,10 +2912,10 @@
# Leave stderr and stdout open so we can see test noise
# Close stdin so that the child goes away if it decides to
# read from stdin (otherwise its a roulette to see what
- # child actually gets keystrokes for pdb etc.
+ # child actually gets keystrokes for pdb etc).
sys.stdin.close()
sys.stdin = None
- stream = os.fdopen(c2pwrite, 'wb', 0)
+ stream = os.fdopen(c2pwrite, 'wb', 1)
subunit_result = TestProtocolClient(stream)
process_suite.run(subunit_result)
finally:
@@ -2925,8 +2932,7 @@
"""Take suite and start up one runner per CPU using subprocess().
:return: An iterable of TestCase-like objects which can each have
- run(result) called on them to feed tests to result, and
- cleanup() called on them to stop them/kill children/end threads.
+ run(result) called on them to feed tests to result.
"""
concurrency = local_concurrency()
result = []
More information about the bazaar-commits
mailing list