167
168
:param bench_history: Optionally, a writable file object to accumulate
168
169
benchmark results.
170
unittest._TextTestResult.__init__(self, stream, descriptions, verbosity)
171
testtools.TextTestResult.__init__(self, stream)
171
172
if bench_history is not None:
172
173
from bzrlib.version import _get_bzr_source_tree
173
174
src_tree = _get_bzr_source_tree()
200
201
actionTaken = "Ran"
201
202
stopTime = time.time()
202
203
timeTaken = stopTime - self.startTime
204
self.stream.writeln(self.separator2)
205
self.stream.writeln("%s %d test%s in %.3fs" % (actionTaken,
204
# GZ 2010-07-19: Seems testtools has no printErrors method, and though
205
# the parent class method is similar have to duplicate
206
self._show_list('ERROR', self.errors)
207
self._show_list('FAIL', self.failures)
208
self.stream.write(self.sep2)
209
self.stream.write("%s %d test%s in %.3fs\n\n" % (actionTaken,
206
210
run, run != 1 and "s" or "", timeTaken))
207
self.stream.writeln()
208
211
if not self.wasSuccessful():
209
212
self.stream.write("FAILED (")
210
213
failed, errored = map(len, (self.failures, self.errors))
217
220
if failed or errored: self.stream.write(", ")
218
221
self.stream.write("known_failure_count=%d" %
219
222
self.known_failure_count)
220
self.stream.writeln(")")
223
self.stream.write(")\n")
222
225
if self.known_failure_count:
223
self.stream.writeln("OK (known_failures=%d)" %
226
self.stream.write("OK (known_failures=%d)\n" %
224
227
self.known_failure_count)
226
self.stream.writeln("OK")
229
self.stream.write("OK\n")
227
230
if self.skip_count > 0:
228
231
skipped = self.skip_count
229
self.stream.writeln('%d test%s skipped' %
232
self.stream.write('%d test%s skipped\n' %
230
233
(skipped, skipped != 1 and "s" or ""))
231
234
if self.unsupported:
232
235
for feature, count in sorted(self.unsupported.items()):
233
self.stream.writeln("Missing feature '%s' skipped %d tests." %
236
self.stream.write("Missing feature '%s' skipped %d tests.\n" %
234
237
(feature, count))
236
239
ok = self.wasStrictlySuccessful()
275
278
def _shortened_test_description(self, test):
277
what = re.sub(r'^bzrlib\.(tests|benchmarks)\.', '', what)
280
what = re.sub(r'^bzrlib\.tests\.', '', what)
280
283
def startTest(self, test):
281
unittest.TestResult.startTest(self, test)
284
super(ExtendedTestResult, self).startTest(test)
282
285
if self.count == 0:
283
286
self.startTests()
284
287
self.report_test_start(test)
357
360
self.report_success(test)
358
361
self._cleanupLogFile(test)
359
unittest.TestResult.addSuccess(self, test)
362
super(ExtendedTestResult, self).addSuccess(test)
360
363
test._log_contents = ''
362
365
def addExpectedFailure(self, test, err):
550
553
return '%s%s' % (indent, err[1])
552
555
def report_error(self, test, err):
553
self.stream.writeln('ERROR %s\n%s'
556
self.stream.write('ERROR %s\n%s\n'
554
557
% (self._testTimeString(test),
555
558
self._error_summary(err)))
557
560
def report_failure(self, test, err):
558
self.stream.writeln(' FAIL %s\n%s'
561
self.stream.write(' FAIL %s\n%s\n'
559
562
% (self._testTimeString(test),
560
563
self._error_summary(err)))
562
565
def report_known_failure(self, test, err):
563
self.stream.writeln('XFAIL %s\n%s'
566
self.stream.write('XFAIL %s\n%s\n'
564
567
% (self._testTimeString(test),
565
568
self._error_summary(err)))
567
570
def report_success(self, test):
568
self.stream.writeln(' OK %s' % self._testTimeString(test))
571
self.stream.write(' OK %s\n' % self._testTimeString(test))
569
572
for bench_called, stats in getattr(test, '_benchcalls', []):
570
self.stream.writeln('LSProf output for %s(%s, %s)' % bench_called)
573
self.stream.write('LSProf output for %s(%s, %s)\n' % bench_called)
571
574
stats.pprint(file=self.stream)
572
575
# flush the stream so that we get smooth output. This verbose mode is
573
576
# used to show the output in PQM.
574
577
self.stream.flush()
576
579
def report_skip(self, test, reason):
577
self.stream.writeln(' SKIP %s\n%s'
580
self.stream.write(' SKIP %s\n%s\n'
578
581
% (self._testTimeString(test), reason))
580
583
def report_not_applicable(self, test, reason):
581
self.stream.writeln(' N/A %s\n %s'
584
self.stream.write(' N/A %s\n %s\n'
582
585
% (self._testTimeString(test), reason))
584
587
def report_unsupported(self, test, feature):
585
588
"""test cannot be run because feature is missing."""
586
self.stream.writeln("NODEP %s\n The feature '%s' is not available."
589
self.stream.write("NODEP %s\n The feature '%s' is not available.\n"
587
590
%(self._testTimeString(test), feature))
618
621
encode = codec.encode
619
622
stream = osutils.UnicodeOrBytesToBytesWriter(encode, stream)
620
623
stream.encoding = new_encoding
621
self.stream = unittest._WritelnDecorator(stream)
622
625
self.descriptions = descriptions
623
626
self.verbosity = verbosity
624
627
self._bench_history = bench_history
3197
3200
def partition_tests(suite, count):
3198
3201
"""Partition suite into count lists of tests."""
3200
tests = list(iter_suite_tests(suite))
3201
tests_per_process = int(math.ceil(float(len(tests)) / count))
3202
for block in range(count):
3203
low_test = block * tests_per_process
3204
high_test = low_test + tests_per_process
3205
process_tests = tests[low_test:high_test]
3206
result.append(process_tests)
3202
# This just assigns tests in a round-robin fashion. On one hand this
3203
# splits up blocks of related tests that might run faster if they shared
3204
# resources, but on the other it avoids assigning blocks of slow tests to
3205
# just one partition. So the slowest partition shouldn't be much slower
3207
partitions = [list() for i in range(count)]
3208
tests = iter_suite_tests(suite)
3209
for partition, test in itertools.izip(itertools.cycle(partitions), tests):
3210
partition.append(test)
3210
3214
def workaround_zealous_crypto_random():
3664
3669
'bzrlib.tests.per_workingtree',
3665
3670
'bzrlib.tests.test__annotator',
3666
3671
'bzrlib.tests.test__bencode',
3672
'bzrlib.tests.test__btree_serializer',
3667
3673
'bzrlib.tests.test__chk_map',
3668
3674
'bzrlib.tests.test__dirstate_helpers',
3669
3675
'bzrlib.tests.test__groupcompress',
3813
3819
'bzrlib.tests.test_transport_log',
3814
3820
'bzrlib.tests.test_tree',
3815
3821
'bzrlib.tests.test_treebuilder',
3822
'bzrlib.tests.test_treeshape',
3816
3823
'bzrlib.tests.test_tsort',
3817
3824
'bzrlib.tests.test_tuned_gzip',
3818
3825
'bzrlib.tests.test_ui',
3822
3829
'bzrlib.tests.test_urlutils',
3823
3830
'bzrlib.tests.test_version',
3824
3831
'bzrlib.tests.test_version_info',
3832
'bzrlib.tests.test_versionedfile',
3825
3833
'bzrlib.tests.test_weave',
3826
3834
'bzrlib.tests.test_whitebox',
3827
3835
'bzrlib.tests.test_win32utils',