~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/__init__.py

  • Committer: Robert J. Tanner
  • Date: 2009-06-10 03:56:49 UTC
  • mfrom: (4423 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4425.
  • Revision ID: tanner@real-time.com-20090610035649-7rfx4cls4550zc3c
Merge 1.15.1 back to trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
728
728
    def finished(self):
729
729
        """See progress.ProgressBar.finished()."""
730
730
 
731
 
    def note(self, fmt_string, *args, **kwargs):
 
731
    def note(self, fmt_string, *args):
732
732
        """See progress.ProgressBar.note()."""
733
 
        self.stdout.write((fmt_string + "\n") % args)
 
733
        if args:
 
734
            fmt_string = fmt_string % args
 
735
        self.stdout.write(fmt_string + "\n")
734
736
 
735
737
    def progress_bar(self):
736
738
        return self
2753
2755
 
2754
2756
 
2755
2757
def fork_decorator(suite):
2756
 
    concurrency = local_concurrency()
 
2758
    concurrency = osutils.local_concurrency()
2757
2759
    if concurrency == 1:
2758
2760
        return suite
2759
2761
    from testtools import ConcurrentTestSuite
2762
2764
 
2763
2765
 
2764
2766
def subprocess_decorator(suite):
2765
 
    concurrency = local_concurrency()
 
2767
    concurrency = osutils.local_concurrency()
2766
2768
    if concurrency == 1:
2767
2769
        return suite
2768
2770
    from testtools import ConcurrentTestSuite
2954
2956
    :return: An iterable of TestCase-like objects which can each have
2955
2957
        run(result) called on them to feed tests to result.
2956
2958
    """
2957
 
    concurrency = local_concurrency()
 
2959
    concurrency = osutils.local_concurrency()
2958
2960
    result = []
2959
2961
    from subunit import TestProtocolClient, ProtocolTestCase
2960
2962
    class TestInOtherProcess(ProtocolTestCase):
3003
3005
    :return: An iterable of TestCase-like objects which can each have
3004
3006
        run(result) called on them to feed tests to result.
3005
3007
    """
3006
 
    concurrency = local_concurrency()
 
3008
    concurrency = osutils.local_concurrency()
3007
3009
    result = []
3008
3010
    from subunit import TestProtocolClient, ProtocolTestCase
3009
3011
    class TestInSubprocess(ProtocolTestCase):
3049
3051
    return result
3050
3052
 
3051
3053
 
3052
 
def cpucount(content):
3053
 
    lines = content.splitlines()
3054
 
    prefix = 'processor'
3055
 
    for line in lines:
3056
 
        if line.startswith(prefix):
3057
 
            concurrency = int(line[line.find(':')+1:]) + 1
3058
 
    return concurrency
3059
 
 
3060
 
 
3061
 
def local_concurrency():
3062
 
    try:
3063
 
        content = file('/proc/cpuinfo', 'rb').read()
3064
 
        concurrency = cpucount(content)
3065
 
    except Exception, e:
3066
 
        concurrency = 1
3067
 
    return concurrency
3068
 
 
3069
 
 
3070
3054
class BZRTransformingResult(unittest.TestResult):
3071
3055
 
3072
3056
    def __init__(self, target):
3363
3347
                   'bzrlib.tests.test__chk_map',
3364
3348
                   'bzrlib.tests.test__dirstate_helpers',
3365
3349
                   'bzrlib.tests.test__groupcompress',
 
3350
                   'bzrlib.tests.test__rio',
3366
3351
                   'bzrlib.tests.test__walkdirs_win32',
3367
3352
                   'bzrlib.tests.test_ancestry',
3368
3353
                   'bzrlib.tests.test_annotate',
3369
3354
                   'bzrlib.tests.test_api',
3370
3355
                   'bzrlib.tests.test_atomicfile',
3371
3356
                   'bzrlib.tests.test_bad_files',
 
3357
                   'bzrlib.tests.test_bencode',
3372
3358
                   'bzrlib.tests.test_bisect_multi',
3373
3359
                   'bzrlib.tests.test_branch',
3374
3360
                   'bzrlib.tests.test_branchbuilder',
3379
3365
                   'bzrlib.tests.test__chunks_to_lines',
3380
3366
                   'bzrlib.tests.test_cache_utf8',
3381
3367
                   'bzrlib.tests.test_chk_map',
 
3368
                   'bzrlib.tests.test_chk_serializer',
3382
3369
                   'bzrlib.tests.test_chunk_writer',
3383
3370
                   'bzrlib.tests.test_clean_tree',
3384
3371
                   'bzrlib.tests.test_commands',
3516
3503
                   'bzrlib.tests.test_xml',
3517
3504
                   'bzrlib.tests.tree_implementations',
3518
3505
                   'bzrlib.tests.workingtree_implementations',
3519
 
                   'bzrlib.util.tests.test_bencode',
3520
3506
                   ]
3521
3507
 
3522
3508
    loader = TestUtil.TestLoader()