~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/__init__.py

  • Committer: John Arbash Meinel
  • Date: 2009-06-05 19:57:15 UTC
  • mto: (4413.5.2 1.16-chk-direct)
  • mto: This revision was merged to the branch mainline in revision 4442.
  • Revision ID: john@arbash-meinel.com-20090605195715-q2gcpaypbixwk4wg
Move the boolean check to the first part of the if statement

Show diffs side-by-side

added added

removed removed

Lines of Context:
2753
2753
 
2754
2754
 
2755
2755
def fork_decorator(suite):
2756
 
    concurrency = local_concurrency()
 
2756
    concurrency = osutils.local_concurrency()
2757
2757
    if concurrency == 1:
2758
2758
        return suite
2759
2759
    from testtools import ConcurrentTestSuite
2762
2762
 
2763
2763
 
2764
2764
def subprocess_decorator(suite):
2765
 
    concurrency = local_concurrency()
 
2765
    concurrency = osutils.local_concurrency()
2766
2766
    if concurrency == 1:
2767
2767
        return suite
2768
2768
    from testtools import ConcurrentTestSuite
2954
2954
    :return: An iterable of TestCase-like objects which can each have
2955
2955
        run(result) called on them to feed tests to result.
2956
2956
    """
2957
 
    concurrency = local_concurrency()
 
2957
    concurrency = osutils.local_concurrency()
2958
2958
    result = []
2959
2959
    from subunit import TestProtocolClient, ProtocolTestCase
2960
2960
    class TestInOtherProcess(ProtocolTestCase):
3003
3003
    :return: An iterable of TestCase-like objects which can each have
3004
3004
        run(result) called on them to feed tests to result.
3005
3005
    """
3006
 
    concurrency = local_concurrency()
 
3006
    concurrency = osutils.local_concurrency()
3007
3007
    result = []
3008
3008
    from subunit import TestProtocolClient, ProtocolTestCase
3009
3009
    class TestInSubprocess(ProtocolTestCase):
3049
3049
    return result
3050
3050
 
3051
3051
 
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
3052
class BZRTransformingResult(unittest.TestResult):
3071
3053
 
3072
3054
    def __init__(self, target):
3370
3352
                   'bzrlib.tests.test_api',
3371
3353
                   'bzrlib.tests.test_atomicfile',
3372
3354
                   'bzrlib.tests.test_bad_files',
 
3355
                   'bzrlib.tests.test_bencode',
3373
3356
                   'bzrlib.tests.test_bisect_multi',
3374
3357
                   'bzrlib.tests.test_branch',
3375
3358
                   'bzrlib.tests.test_branchbuilder',
3380
3363
                   'bzrlib.tests.test__chunks_to_lines',
3381
3364
                   'bzrlib.tests.test_cache_utf8',
3382
3365
                   'bzrlib.tests.test_chk_map',
 
3366
                   'bzrlib.tests.test_chk_serializer',
3383
3367
                   'bzrlib.tests.test_chunk_writer',
3384
3368
                   'bzrlib.tests.test_clean_tree',
3385
3369
                   'bzrlib.tests.test_commands',
3517
3501
                   'bzrlib.tests.test_xml',
3518
3502
                   'bzrlib.tests.tree_implementations',
3519
3503
                   'bzrlib.tests.workingtree_implementations',
3520
 
                   'bzrlib.util.tests.test_bencode',
3521
3504
                   ]
3522
3505
 
3523
3506
    loader = TestUtil.TestLoader()