Commit 95aa6b1a authored by zmo's avatar zmo Committed by Commit bot

Makes sure telemetry test result report is one string (no interruption)

Otherwise there could be logging inserted between [ OK ] and the test name,
and the harness will fail to recognize the test is passing, raising false alarm.

BUG=409968
TEST=telemetry tests
R=bajones@chromium.org,tonyg@chromium.org
NOTRY=true

Review URL: https://codereview.chromium.org/530143002

Cr-Commit-Position: refs/heads/master@{#293031}
parent dd4bf8f4
...@@ -10,7 +10,15 @@ from telemetry.value import skip ...@@ -10,7 +10,15 @@ from telemetry.value import skip
class GTestProgressReporter(progress_reporter.ProgressReporter): class GTestProgressReporter(progress_reporter.ProgressReporter):
"""A progress reporter that outputs the progress report in gtest style.""" """A progress reporter that outputs the progress report in gtest style.
Be careful each print should only handle one string. Otherwise, the output
might be interrupted by Chrome logging, and the output interpretation might
be incorrect. For example:
print >> self._output_stream, "[ OK ]", testname
should be written as
print >> self._output_stream, "[ OK ] %s" % testname
"""
def __init__(self, output_stream, output_skipped_tests_summary=False): def __init__(self, output_stream, output_skipped_tests_summary=False):
super(GTestProgressReporter, self).__init__() super(GTestProgressReporter, self).__init__()
...@@ -38,7 +46,7 @@ class GTestProgressReporter(progress_reporter.ProgressReporter): ...@@ -38,7 +46,7 @@ class GTestProgressReporter(progress_reporter.ProgressReporter):
def WillRunPage(self, page_test_results): def WillRunPage(self, page_test_results):
super(GTestProgressReporter, self).WillRunPage(page_test_results) super(GTestProgressReporter, self).WillRunPage(page_test_results)
print >> self._output_stream, '[ RUN ]', ( print >> self._output_stream, '[ RUN ] %s' % (
page_test_results.current_page.display_name) page_test_results.current_page.display_name)
self._output_stream.flush() self._output_stream.flush()
self._timestamp = time.time() self._timestamp = time.time()
...@@ -47,11 +55,11 @@ class GTestProgressReporter(progress_reporter.ProgressReporter): ...@@ -47,11 +55,11 @@ class GTestProgressReporter(progress_reporter.ProgressReporter):
super(GTestProgressReporter, self).DidRunPage(page_test_results) super(GTestProgressReporter, self).DidRunPage(page_test_results)
page = page_test_results.current_page page = page_test_results.current_page
if page_test_results.current_page_run.failed: if page_test_results.current_page_run.failed:
print >> self._output_stream, '[ FAILED ]', page.display_name, ( print >> self._output_stream, '[ FAILED ] %s (%0.f ms)' % (
'(%0.f ms)' % self._GetMs()) page.display_name, self._GetMs())
else: else:
print >> self._output_stream, '[ OK ]', page.display_name, ( print >> self._output_stream, '[ OK ] %s (%0.f ms)' % (
'(%0.f ms)' % self._GetMs()) page.display_name, self._GetMs())
self._output_stream.flush() self._output_stream.flush()
def WillAttemptPageRun(self, page_test_results, attempt_count, max_attempts): def WillAttemptPageRun(self, page_test_results, attempt_count, max_attempts):
...@@ -77,14 +85,14 @@ class GTestProgressReporter(progress_reporter.ProgressReporter): ...@@ -77,14 +85,14 @@ class GTestProgressReporter(progress_reporter.ProgressReporter):
successful_runs.append(run) successful_runs.append(run)
unit = 'test' if len(successful_runs) == 1 else 'tests' unit = 'test' if len(successful_runs) == 1 else 'tests'
print >> self._output_stream, '[ PASSED ]', ( print >> self._output_stream, '[ PASSED ] %d %s.' % (
'%d %s.' % (len(successful_runs), unit)) (len(successful_runs), unit))
if len(failed_runs) > 0: if len(failed_runs) > 0:
unit = 'test' if len(failed_runs) == 1 else 'tests' unit = 'test' if len(failed_runs) == 1 else 'tests'
print >> self._output_stream, '[ FAILED ]', ( print >> self._output_stream, '[ FAILED ] %d %s, listed below:' % (
'%d %s, listed below:' % (len(page_test_results.failures), unit)) (len(page_test_results.failures), unit))
for failed_run in failed_runs: for failed_run in failed_runs:
print >> self._output_stream, '[ FAILED ] ', ( print >> self._output_stream, '[ FAILED ] %s' % (
failed_run.page.display_name) failed_run.page.display_name)
print >> self._output_stream print >> self._output_stream
count = len(failed_runs) count = len(failed_runs)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment