зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1213129 - Share worker count derivation code between jit and js test suites; r=sfink
This commit is contained in:
Родитель
a6ebc050de
Коммит
1e2222982c
|
@ -17,7 +17,8 @@ def add_libdir_to_path():
|
|||
add_libdir_to_path()
|
||||
|
||||
import jittests
|
||||
from tests import get_jitflags, get_environment_overlay, change_env
|
||||
from tests import get_jitflags, get_cpu_count, get_environment_overlay, \
|
||||
change_env
|
||||
|
||||
# Python 3.3 added shutil.which, but we can't use that yet.
|
||||
def which(name):
|
||||
|
@ -32,18 +33,8 @@ def which(name):
|
|||
return name
|
||||
|
||||
def main(argv):
|
||||
|
||||
# If no multiprocessing is available, fallback to serial test execution
|
||||
max_jobs_default = 1
|
||||
if jittests.HAVE_MULTIPROCESSING:
|
||||
try:
|
||||
max_jobs_default = jittests.cpu_count()
|
||||
except NotImplementedError:
|
||||
pass
|
||||
|
||||
# The [TESTS] optional arguments are paths of test files relative
|
||||
# to the jit-test/tests directory.
|
||||
|
||||
from optparse import OptionParser
|
||||
op = OptionParser(usage='%prog [options] JS_SHELL [TESTS]')
|
||||
op.add_option('-s', '--show-cmd', dest='show_cmd', action='store_true',
|
||||
|
@ -112,7 +103,7 @@ def main(argv):
|
|||
help='Run tests with all IonMonkey option combinations'
|
||||
' (ignores --jitflags)')
|
||||
op.add_option('-j', '--worker-count', dest='max_jobs', type=int,
|
||||
default=max_jobs_default,
|
||||
default=max(1, get_cpu_count()),
|
||||
help='Number of tests to run in parallel (default %default)')
|
||||
op.add_option('--remote', action='store_true',
|
||||
help='Run tests on a remote device')
|
||||
|
|
|
@ -13,8 +13,8 @@ from contextlib import contextmanager
|
|||
from copy import copy
|
||||
from subprocess import list2cmdline, call
|
||||
|
||||
from lib.tests import RefTestCase, get_jitflags, get_environment_overlay, \
|
||||
change_env
|
||||
from lib.tests import RefTestCase, get_jitflags, get_cpu_count, \
|
||||
get_environment_overlay, change_env
|
||||
from lib.results import ResultsSink
|
||||
from lib.progressbar import ProgressBar
|
||||
|
||||
|
@ -24,37 +24,6 @@ else:
|
|||
from lib.tasks_win import run_all_tests
|
||||
|
||||
|
||||
def get_cpu_count():
|
||||
"""
|
||||
Guess at a reasonable parallelism count to set as the default for the
|
||||
current machine and run.
|
||||
"""
|
||||
# Python 2.6+
|
||||
try:
|
||||
import multiprocessing
|
||||
return multiprocessing.cpu_count()
|
||||
except (ImportError, NotImplementedError):
|
||||
pass
|
||||
|
||||
# POSIX
|
||||
try:
|
||||
res = int(os.sysconf('SC_NPROCESSORS_ONLN'))
|
||||
if res > 0:
|
||||
return res
|
||||
except (AttributeError, ValueError):
|
||||
pass
|
||||
|
||||
# Windows
|
||||
try:
|
||||
res = int(os.environ['NUMBER_OF_PROCESSORS'])
|
||||
if res > 0:
|
||||
return res
|
||||
except (KeyError, ValueError):
|
||||
pass
|
||||
|
||||
return 1
|
||||
|
||||
|
||||
@contextmanager
|
||||
def changedir(dirname):
|
||||
pwd = os.getcwd()
|
||||
|
|
|
@ -94,6 +94,37 @@ def change_env(env_overlay):
|
|||
del os.environ[key]
|
||||
|
||||
|
||||
def get_cpu_count():
|
||||
"""
|
||||
Guess at a reasonable parallelism count to set as the default for the
|
||||
current machine and run.
|
||||
"""
|
||||
# Python 2.6+
|
||||
try:
|
||||
import multiprocessing
|
||||
return multiprocessing.cpu_count()
|
||||
except (ImportError, NotImplementedError):
|
||||
pass
|
||||
|
||||
# POSIX
|
||||
try:
|
||||
res = int(os.sysconf('SC_NPROCESSORS_ONLN'))
|
||||
if res > 0:
|
||||
return res
|
||||
except (AttributeError, ValueError):
|
||||
pass
|
||||
|
||||
# Windows
|
||||
try:
|
||||
res = int(os.environ['NUMBER_OF_PROCESSORS'])
|
||||
if res > 0:
|
||||
return res
|
||||
except (KeyError, ValueError):
|
||||
pass
|
||||
|
||||
return 1
|
||||
|
||||
|
||||
class RefTest(object):
|
||||
"""A runnable test."""
|
||||
def __init__(self, path):
|
||||
|
@ -117,6 +148,7 @@ class RefTest(object):
|
|||
+ RefTest.prefix_command(dirname) + ['-f', self.path]
|
||||
return cmd
|
||||
|
||||
|
||||
class RefTestCase(RefTest):
|
||||
"""A test case consisting of a test and an expected result."""
|
||||
def __init__(self, path):
|
||||
|
|
Загрузка…
Ссылка в новой задаче