Commit f907b393 authored by mlamouri@chromium.org's avatar mlamouri@chromium.org

Accept spaces before/after testharness.js output and CONSOLE output.

Some tests trigger CONSOLE output of various kind (LOG, ERROR,
etc.) for legitimate reasons so we shouldn't break those tests.

Furthermore, we are a little too pedantic with regards to whitespaces
around testharness output. Given how we get that output (ie. using
element.innerText), we should be less restrictive.

BUG=379442

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

git-svn-id: svn://svn.chromium.org/blink/trunk@175272 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 6f774e2e
...@@ -264,6 +264,7 @@ class SingleTestRunner(object): ...@@ -264,6 +264,7 @@ class SingleTestRunner(object):
found_a_pass = False found_a_pass = False
text = driver_output.text or '' text = driver_output.text or ''
lines = text.strip().splitlines() lines = text.strip().splitlines()
lines = [line.strip() for line in lines]
header = 'This is a testharness.js-based test.' header = 'This is a testharness.js-based test.'
footer = 'Harness: the test ran to completion.' footer = 'Harness: the test ran to completion.'
if not lines or not header in lines: if not lines or not header in lines:
...@@ -272,12 +273,17 @@ class SingleTestRunner(object): ...@@ -272,12 +273,17 @@ class SingleTestRunner(object):
return True, [test_failures.FailureTestHarnessAssertion()] return True, [test_failures.FailureTestHarnessAssertion()]
for line in lines: for line in lines:
if line == header or line == footer or line.startswith('PASS'):
continue
# CONSOLE output can happen during tests and shouldn't break them.
if line.startswith('CONSOLE'):
continue
if line.startswith('FAIL') or line.startswith('TIMEOUT'): if line.startswith('FAIL') or line.startswith('TIMEOUT'):
return True, [test_failures.FailureTestHarnessAssertion()] return True, [test_failures.FailureTestHarnessAssertion()]
# Fail the test if there is any unrecognized output. # Fail the test if there is any unrecognized output.
if line != header and line != footer and not line.startswith('PASS'): return True, [test_failures.FailureTestHarnessAssertion()]
return True, [test_failures.FailureTestHarnessAssertion()]
return True, [] return True, []
def _is_render_tree(self, text): def _is_render_tree(self, text):
......
...@@ -150,7 +150,7 @@ def unit_test_list(): ...@@ -150,7 +150,7 @@ def unit_test_list():
actual_image=None, expected_image=None, actual_image=None, expected_image=None,
actual_checksum=None) actual_checksum=None)
tests.add('failures/expected/testharness.html', tests.add('failures/expected/testharness.html',
actual_text='CONSOLE LOG: error.\nThis is a testharness.js-based test.\nPASS: things are fine.\n.Harness: the test ran to completion.\n\n', expected_text=None, actual_text='RANDOM TEXT.\nThis is a testharness.js-based test.\nPASS: things are fine.\n.Harness: the test ran to completion.\n\n', expected_text=None,
actual_image=None, expected_image=None, actual_image=None, expected_image=None,
actual_checksum=None) actual_checksum=None)
tests.add('failures/expected/text.html', actual_text='text_fail-png') tests.add('failures/expected/text.html', actual_text='text_fail-png')
...@@ -203,6 +203,18 @@ layer at (0,0) size 800x34 ...@@ -203,6 +203,18 @@ layer at (0,0) size 800x34
tests.add('passes/checksum_in_image.html', tests.add('passes/checksum_in_image.html',
expected_image='tEXtchecksum\x00checksum_in_image-checksum') expected_image='tEXtchecksum\x00checksum_in_image-checksum')
tests.add('passes/skipped/skip.html') tests.add('passes/skipped/skip.html')
tests.add('passes/testharness.html',
actual_text='CONSOLE LOG: error.\nThis is a testharness.js-based test.\nPASS: things are fine.\n.Harness: the test ran to completion.\n\n', expected_text=None,
actual_image=None, expected_image=None,
actual_checksum=None)
tests.add('passes/testharness.html',
actual_text='CONSOLE ERROR: error.\nThis is a testharness.js-based test.\nPASS: things are fine.\n.Harness: the test ran to completion.\n\n', expected_text=None,
actual_image=None, expected_image=None,
actual_checksum=None)
tests.add('passes/testharness.html',
actual_text=' This is a testharness.js-based test.\nPASS: assert is fine\nHarness: the test ran to completion.\n\n', expected_text=None,
actual_image=None, expected_image=None,
actual_checksum=None)
tests.add('passes/testharness.html', tests.add('passes/testharness.html',
actual_text='This is a testharness.js-based test.\nPASS: assert is fine\nHarness: the test ran to completion.\n\n', expected_text=None, actual_text='This is a testharness.js-based test.\nPASS: assert is fine\nHarness: the test ran to completion.\n\n', expected_text=None,
actual_image=None, expected_image=None, actual_image=None, expected_image=None,
......
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