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:
Till Schneidereit 2017-01-27 00:50:43 +01:00
Родитель 3b7bb25ac6
Коммит a466bef944
2 изменённых файлов: 25 добавлений и 0 удалений

Просмотреть файл

@ -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