~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/__init__.py

  • Committer: John Arbash Meinel
  • Date: 2007-07-18 20:42:38 UTC
  • mfrom: (2625 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2643.
  • Revision ID: john@arbash-meinel.com-20070718204238-5gi11fx04q7zt72d
[merge] bzr.dev 2625

Show diffs side-by-side

added added

removed removed

Lines of Context:
165
165
    def __init__(self, stream, descriptions, verbosity,
166
166
                 bench_history=None,
167
167
                 num_tests=None,
168
 
                 use_numbered_dirs=False,
169
168
                 ):
170
169
        """Construct new TestResult.
171
170
 
196
195
        self.skip_count = 0
197
196
        self.unsupported = {}
198
197
        self.count = 0
199
 
        self.use_numbered_dirs = use_numbered_dirs
200
198
        self._overall_start_time = time.time()
201
199
    
202
200
    def extractBenchmarkTime(self, testCase):
303
301
        for test, err in errors:
304
302
            self.stream.writeln(self.separator1)
305
303
            self.stream.write("%s: " % flavour)
306
 
            if self.use_numbered_dirs:
307
 
                self.stream.write('#%d ' % test.number)
308
304
            self.stream.writeln(self.getDescription(test))
309
305
            if getattr(test, '_get_log', None) is not None:
310
306
                print >>self.stream
333
329
                 bench_history=None,
334
330
                 num_tests=None,
335
331
                 pb=None,
336
 
                 use_numbered_dirs=False,
337
332
                 ):
338
333
        ExtendedTestResult.__init__(self, stream, descriptions, verbosity,
339
 
            bench_history, num_tests, use_numbered_dirs)
 
334
            bench_history, num_tests)
340
335
        if pb is None:
341
336
            self.pb = self.ui.nested_progress_bar()
342
337
            self._supplied_pb = False
378
373
                + self._shortened_test_description(test))
379
374
 
380
375
    def _test_description(self, test):
381
 
        if self.use_numbered_dirs:
382
 
            return '#%d %s' % (self.count,
383
 
                               self._shortened_test_description(test))
384
 
        else:
385
 
            return self._shortened_test_description(test)
 
376
        return self._shortened_test_description(test)
386
377
 
387
378
    def report_error(self, test, err):
388
379
        self.pb.note('ERROR: %s\n    %s\n', 
447
438
        # width needs space for 6 char status, plus 1 for slash, plus 2 10-char
448
439
        # numbers, plus a trailing blank
449
440
        # when NUMBERED_DIRS: plus 5 chars on test number, plus 1 char on space
450
 
        if self.use_numbered_dirs:
451
 
            self.stream.write('%5d ' % self.count)
452
 
            self.stream.write(self._ellipsize_to_right(name,
453
 
                                osutils.terminal_width()-36))
454
 
        else:
455
 
            self.stream.write(self._ellipsize_to_right(name,
456
 
                                osutils.terminal_width()-30))
 
441
        self.stream.write(self._ellipsize_to_right(name,
 
442
                          osutils.terminal_width()-30))
457
443
        self.stream.flush()
458
444
 
459
445
    def _error_summary(self, err):
460
446
        indent = ' ' * 4
461
 
        if self.use_numbered_dirs:
462
 
            indent += ' ' * 6
463
447
        return '%s%s' % (indent, err[1])
464
448
 
465
449
    def report_error(self, test, err):
507
491
                 descriptions=0,
508
492
                 verbosity=1,
509
493
                 bench_history=None,
510
 
                 use_numbered_dirs=False,
511
494
                 list_only=False
512
495
                 ):
513
496
        self.stream = unittest._WritelnDecorator(stream)
514
497
        self.descriptions = descriptions
515
498
        self.verbosity = verbosity
516
499
        self._bench_history = bench_history
517
 
        self.use_numbered_dirs = use_numbered_dirs
518
500
        self.list_only = list_only
519
501
 
520
502
    def run(self, test):
529
511
                              self.verbosity,
530
512
                              bench_history=self._bench_history,
531
513
                              num_tests=test.countTestCases(),
532
 
                              use_numbered_dirs=self.use_numbered_dirs,
533
514
                              )
534
515
        result.stop_early = self.stop_on_failure
535
516
        result.report_starting()
1902
1883
    """
1903
1884
 
1904
1885
    OVERRIDE_PYTHON = 'python'
1905
 
    use_numbered_dirs = False
1906
1886
 
1907
1887
    def check_file_contents(self, filename, expect):
1908
1888
        self.log("check contents of file %s" % filename)
2181
2161
              stop_on_failure=False,
2182
2162
              transport=None, lsprof_timed=None, bench_history=None,
2183
2163
              matching_tests_first=None,
2184
 
              numbered_dirs=None,
2185
2164
              list_only=False,
2186
2165
              random_seed=None,
2187
2166
              exclude_pattern=None,
2188
2167
              ):
2189
 
    use_numbered_dirs = bool(numbered_dirs)
2190
 
 
2191
2168
    TestCase._gather_lsprof_in_benchmarks = lsprof_timed
2192
 
    if numbered_dirs is not None:
2193
 
        TestCaseInTempDir.use_numbered_dirs = use_numbered_dirs
2194
2169
    if verbose:
2195
2170
        verbosity = 2
2196
2171
    else:
2199
2174
                            descriptions=0,
2200
2175
                            verbosity=verbosity,
2201
2176
                            bench_history=bench_history,
2202
 
                            use_numbered_dirs=use_numbered_dirs,
2203
2177
                            list_only=list_only,
2204
2178
                            )
2205
2179
    runner.stop_on_failure=stop_on_failure
2237
2211
             lsprof_timed=None,
2238
2212
             bench_history=None,
2239
2213
             matching_tests_first=None,
2240
 
             numbered_dirs=None,
2241
2214
             list_only=False,
2242
2215
             random_seed=None,
2243
2216
             exclude_pattern=None):
2264
2237
                     lsprof_timed=lsprof_timed,
2265
2238
                     bench_history=bench_history,
2266
2239
                     matching_tests_first=matching_tests_first,
2267
 
                     numbered_dirs=numbered_dirs,
2268
2240
                     list_only=list_only,
2269
2241
                     random_seed=random_seed,
2270
2242
                     exclude_pattern=exclude_pattern)
2279
2251
    suite on a global basis, but it is not encouraged.
2280
2252
    """
2281
2253
    testmod_names = [
 
2254
                   'bzrlib.util.tests.test_bencode',
2282
2255
                   'bzrlib.tests.test__dirstate_helpers',
2283
2256
                   'bzrlib.tests.test_ancestry',
2284
2257
                   'bzrlib.tests.test_annotate',
2321
2294
                   'bzrlib.tests.test_https_ca_bundle',
2322
2295
                   'bzrlib.tests.test_identitymap',
2323
2296
                   'bzrlib.tests.test_ignores',
 
2297
                   'bzrlib.tests.test_index',
2324
2298
                   'bzrlib.tests.test_info',
2325
2299
                   'bzrlib.tests.test_inv',
2326
2300
                   'bzrlib.tests.test_knit',
2464
2438
            raise
2465
2439
 
2466
2440
 
2467
 
def clean_selftest_output(root=None, quiet=False):
2468
 
    """Remove all selftest output directories from root directory.
2469
 
 
2470
 
    :param  root:   root directory for clean
2471
 
                    (if ommitted or None then clean current directory).
2472
 
    :param  quiet:  suppress report about deleting directories
2473
 
    """
2474
 
    import re
2475
 
    re_dir = re.compile(r'''test\d\d\d\d\.tmp''')
2476
 
    if root is None:
2477
 
        root = u'.'
2478
 
    for i in os.listdir(root):
2479
 
        if os.path.isdir(i) and re_dir.match(i):
2480
 
            if not quiet:
2481
 
                print 'delete directory:', i
2482
 
            _rmtree_temp_dir(i)
2483
 
 
2484
 
 
2485
2441
class Feature(object):
2486
2442
    """An operating system Feature."""
2487
2443