зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1334323 - Add support for logging long-running tests to the jstests harness. r=sfink
Adds two new parameters to jstests.py: --show-slow and --slow-test-threshold (defaulting to 5s). MozReview-Commit-ID: AO6WAa4kLWy
This commit is contained in:
Родитель
3b7bb25ac6
Коммит
a466bef944
|
@ -66,6 +66,12 @@ def parse_args():
|
|||
harness_og.add_option('-t', '--timeout', type=float, default=150.0,
|
||||
help='Set maximum time a test is allows to run'
|
||||
' (in seconds).')
|
||||
harness_og.add_option('--show-slow', action='store_true',
|
||||
help='Show tests taking longer than a minimum time'
|
||||
' (in seconds).')
|
||||
harness_og.add_option('--slow-test-threshold', type=float, default=5.0,
|
||||
help='Time in seconds a test can take until it is'
|
||||
'considered slow (default %default).')
|
||||
harness_og.add_option('-a', '--args', dest='shell_args', default='',
|
||||
help='Extra args to pass to the JS shell.')
|
||||
harness_og.add_option('--jitflags', dest='jitflags', default='none',
|
||||
|
|
|
@ -94,6 +94,11 @@ class TestResult:
|
|||
|
||||
return cls(test, result, results)
|
||||
|
||||
class TestDuration:
|
||||
def __init__(self, test, duration):
|
||||
self.test = test
|
||||
self.duration = duration
|
||||
|
||||
class ResultsSink:
|
||||
def __init__(self, options, testcount):
|
||||
self.options = options
|
||||
|
@ -102,6 +107,7 @@ class ResultsSink:
|
|||
self.groups = {}
|
||||
self.output_dict = {}
|
||||
self.counts = {'PASS': 0, 'FAIL': 0, 'TIMEOUT': 0, 'SKIP': 0}
|
||||
self.slow_tests = []
|
||||
self.n = 0
|
||||
|
||||
if options.hide_progress:
|
||||
|
@ -116,6 +122,8 @@ class ResultsSink:
|
|||
self.pb = ProgressBar(testcount, fmt)
|
||||
|
||||
def push(self, output):
|
||||
if self.options.show_slow and output.dt >= self.options.slow_test_threshold:
|
||||
self.slow_tests.append(TestDuration(output.test, output.dt))
|
||||
if output.timed_out:
|
||||
self.counts['TIMEOUT'] += 1
|
||||
if isinstance(output, NullTestOutput):
|
||||
|
@ -257,6 +265,17 @@ class ResultsSink:
|
|||
else:
|
||||
print('FAIL' + suffix)
|
||||
|
||||
if self.options.show_slow:
|
||||
min_duration = self.options.slow_test_threshold
|
||||
print('Slow tests (duration > {}s)'.format(min_duration))
|
||||
slow_tests = sorted(self.slow_tests, key=lambda x: x.duration, reverse=True)
|
||||
any = False
|
||||
for test in slow_tests:
|
||||
print('{:>5} {}'.format(round(test.duration, 2), test.test))
|
||||
any = True
|
||||
if not any:
|
||||
print('None')
|
||||
|
||||
def all_passed(self):
|
||||
return 'REGRESSIONS' not in self.groups and 'TIMEOUTS' not in self.groups
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче