/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/__init__.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-06-05 08:10:39 UTC
  • mfrom: (4412.1.1 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20090605081039-abvojdsxjbg5i4ff
(vila) Add cpu # detection for windows and Solaris

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
 
        return concurrency
3066
 
    except IOError:
3067
 
        pass
3068
 
 
3069
 
    try:
3070
 
       output = Popen(['sysctl', '-n', 'hw.availcpu'],
3071
 
                      stdout=PIPE).communicate()[0]
3072
 
       concurrency = int(output)
3073
 
       return concurrency
3074
 
    except (OSError, IOError):
3075
 
        concurrency = 1
3076
 
 
3077
 
    return concurrency
3078
 
 
3079
 
 
3080
3052
class BZRTransformingResult(unittest.TestResult):
3081
3053
 
3082
3054
    def __init__(self, target):