[test] Output processors for inspector and webkit
Bug: v8:6917 Change-Id: I81bff2190766b3ccbc5da43ff2f3105c6c95da67 Reviewed-on: https://chromium-review.googlesource.com/836557 Commit-Queue: Michał Majewski <majeski@google.com> Reviewed-by: Michael Achenbach <machenbach@chromium.org> Reviewed-by: Sergiy Byelozyorov <sergiyb@chromium.org> Cr-Commit-Position: refs/heads/master@{#50263}
This commit is contained in:
parent
ad7f6f9901
commit
b0db2dc6ae
@ -2,11 +2,11 @@
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
import itertools
|
||||
import os
|
||||
|
||||
from testrunner.local import testsuite
|
||||
from testrunner.local import utils
|
||||
from testrunner.objects import outproc
|
||||
from testrunner.objects import testcase
|
||||
|
||||
PROTOCOL_TEST_JS = "protocol-test.js"
|
||||
@ -36,66 +36,14 @@ class TestSuite(testsuite.TestSuite):
|
||||
def _test_class(self):
|
||||
return TestCase
|
||||
|
||||
def _IgnoreLine(self, string):
|
||||
"""Ignore empty lines, valgrind output and Android output."""
|
||||
if not string:
|
||||
return True
|
||||
return (string.startswith("==") or string.startswith("**") or
|
||||
string.startswith("ANDROID") or
|
||||
# FIXME(machenbach): The test driver shouldn't try to use slow
|
||||
# asserts if they weren't compiled. This fails in optdebug=2.
|
||||
string == "Warning: unknown flag --enable-slow-asserts." or
|
||||
string == "Try --help for options")
|
||||
|
||||
def IsFailureOutput(self, test, output):
|
||||
file_name = os.path.join(self.root, test.path) + EXPECTED_SUFFIX
|
||||
with file(file_name, "r") as expected:
|
||||
expected_lines = expected.readlines()
|
||||
|
||||
def ExpIterator():
|
||||
for line in expected_lines:
|
||||
if not line.strip():
|
||||
continue
|
||||
yield line.strip()
|
||||
|
||||
def ActIterator(lines):
|
||||
for line in lines:
|
||||
if self._IgnoreLine(line.strip()):
|
||||
continue
|
||||
yield line.strip()
|
||||
|
||||
def ActBlockIterator():
|
||||
"""Iterates over blocks of actual output lines."""
|
||||
lines = output.stdout.splitlines()
|
||||
start_index = 0
|
||||
found_eqeq = False
|
||||
for index, line in enumerate(lines):
|
||||
# If a stress test separator is found:
|
||||
if line.startswith("=="):
|
||||
# Iterate over all lines before a separator except the first.
|
||||
if not found_eqeq:
|
||||
found_eqeq = True
|
||||
else:
|
||||
yield ActIterator(lines[start_index:index])
|
||||
# The next block of output lines starts after the separator.
|
||||
start_index = index + 1
|
||||
# Iterate over complete output if no separator was found.
|
||||
if not found_eqeq:
|
||||
yield ActIterator(lines)
|
||||
|
||||
for act_iterator in ActBlockIterator():
|
||||
for (expected, actual) in itertools.izip_longest(
|
||||
ExpIterator(), act_iterator, fillvalue=''):
|
||||
if expected != actual:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
class TestCase(testcase.TestCase):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(TestCase, self).__init__(*args, **kwargs)
|
||||
|
||||
self._source_flags = self._parse_source_flags()
|
||||
self._outproc = outproc.ExpectedOutProc(
|
||||
os.path.join(self.suite.root, self.path) + EXPECTED_SUFFIX)
|
||||
|
||||
def _get_files_params(self, ctx):
|
||||
return [
|
||||
@ -112,6 +60,9 @@ class TestCase(testcase.TestCase):
|
||||
def get_shell(self):
|
||||
return 'inspector-test'
|
||||
|
||||
def get_output_proc(self):
|
||||
return self._outproc
|
||||
|
||||
|
||||
def GetSuite(name, root):
|
||||
return TestSuite(name, root)
|
||||
|
@ -25,11 +25,11 @@
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import itertools
|
||||
import os
|
||||
import re
|
||||
|
||||
from testrunner.local import testsuite
|
||||
from testrunner.objects import outproc
|
||||
from testrunner.objects import testcase
|
||||
|
||||
FILES_PATTERN = re.compile(r"//\s+Files:(.*)")
|
||||
@ -60,64 +60,6 @@ class TestSuite(testsuite.TestSuite):
|
||||
def _test_class(self):
|
||||
return TestCase
|
||||
|
||||
# TODO(machenbach): Share with test/message/testcfg.py
|
||||
def _IgnoreLine(self, string):
|
||||
"""Ignore empty lines, valgrind output, Android output and trace
|
||||
incremental marking output."""
|
||||
if not string:
|
||||
return True
|
||||
return (string.startswith("==") or string.startswith("**") or
|
||||
string.startswith("ANDROID") or "[IncrementalMarking]" in string or
|
||||
# FIXME(machenbach): The test driver shouldn't try to use slow
|
||||
# asserts if they weren't compiled. This fails in optdebug=2.
|
||||
string == "Warning: unknown flag --enable-slow-asserts." or
|
||||
string == "Try --help for options")
|
||||
|
||||
def IsFailureOutput(self, test, output):
|
||||
if super(TestSuite, self).IsFailureOutput(test, output):
|
||||
return True
|
||||
file_name = os.path.join(self.root, test.path) + "-expected.txt"
|
||||
with file(file_name, "r") as expected:
|
||||
expected_lines = expected.readlines()
|
||||
|
||||
def ExpIterator():
|
||||
for line in expected_lines:
|
||||
if line.startswith("#") or not line.strip():
|
||||
continue
|
||||
yield line.strip()
|
||||
|
||||
def ActIterator(lines):
|
||||
for line in lines:
|
||||
if self._IgnoreLine(line.strip()):
|
||||
continue
|
||||
yield line.strip()
|
||||
|
||||
def ActBlockIterator():
|
||||
"""Iterates over blocks of actual output lines."""
|
||||
lines = output.stdout.splitlines()
|
||||
start_index = 0
|
||||
found_eqeq = False
|
||||
for index, line in enumerate(lines):
|
||||
# If a stress test separator is found:
|
||||
if line.startswith("=="):
|
||||
# Iterate over all lines before a separator except the first.
|
||||
if not found_eqeq:
|
||||
found_eqeq = True
|
||||
else:
|
||||
yield ActIterator(lines[start_index:index])
|
||||
# The next block of output lines starts after the separator.
|
||||
start_index = index + 1
|
||||
# Iterate over complete output if no separator was found.
|
||||
if not found_eqeq:
|
||||
yield ActIterator(lines)
|
||||
|
||||
for act_iterator in ActBlockIterator():
|
||||
for (expected, actual) in itertools.izip_longest(
|
||||
ExpIterator(), act_iterator, fillvalue=''):
|
||||
if expected != actual:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
class TestCase(testcase.TestCase):
|
||||
def __init__(self, *args, **kwargs):
|
||||
@ -126,6 +68,8 @@ class TestCase(testcase.TestCase):
|
||||
source = self.get_source()
|
||||
self._source_files = self._parse_source_files(source)
|
||||
self._source_flags = self._parse_source_flags(source)
|
||||
self._outproc = OutProc(
|
||||
os.path.join(self.suite.root, self.path) + '-expected.txt')
|
||||
|
||||
def _parse_source_files(self, source):
|
||||
files_list = [] # List of file names to append to command arguments.
|
||||
@ -160,6 +104,22 @@ class TestCase(testcase.TestCase):
|
||||
def _get_source_path(self):
|
||||
return os.path.join(self.suite.root, self.path + self._get_suffix())
|
||||
|
||||
def get_output_proc(self):
|
||||
return self._outproc
|
||||
|
||||
|
||||
class OutProc(outproc.ExpectedOutProc):
|
||||
def _is_failure_output(self, output):
|
||||
if output.exit_code != 0:
|
||||
return True
|
||||
return super(OutProc, self)._is_failure_output(output)
|
||||
|
||||
def _ignore_expected_line(self, line):
|
||||
return (
|
||||
line.startswith('#') or
|
||||
super(OutProc, self)._ignore_expected_line(line)
|
||||
)
|
||||
|
||||
|
||||
def GetSuite(name, root):
|
||||
return TestSuite(name, root)
|
||||
|
@ -2,6 +2,8 @@
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
import itertools
|
||||
|
||||
from ..local import statusfile
|
||||
|
||||
|
||||
@ -33,3 +35,74 @@ class OutProc(object):
|
||||
def _is_negative(self):
|
||||
# TODO(majeski): Move implementation.
|
||||
return self._test.suite.IsNegativeTest(self._test)
|
||||
|
||||
|
||||
class ExpectedOutProc(OutProc):
|
||||
def __init__(self, expected_filename):
|
||||
self._expected_filename = expected_filename
|
||||
|
||||
def _is_failure_output(self, output):
|
||||
with open(self._expected_filename, 'r') as f:
|
||||
expected_lines = f.readlines()
|
||||
|
||||
for act_iterator in self._act_block_iterator(output):
|
||||
for expected, actual in itertools.izip_longest(
|
||||
self._expected_iterator(expected_lines),
|
||||
act_iterator,
|
||||
fillvalue=''
|
||||
):
|
||||
if expected != actual:
|
||||
return True
|
||||
return False
|
||||
|
||||
def _act_block_iterator(self, output):
|
||||
"""Iterates over blocks of actual output lines."""
|
||||
lines = output.stdout.splitlines()
|
||||
start_index = 0
|
||||
found_eqeq = False
|
||||
for index, line in enumerate(lines):
|
||||
# If a stress test separator is found:
|
||||
if line.startswith('=='):
|
||||
# Iterate over all lines before a separator except the first.
|
||||
if not found_eqeq:
|
||||
found_eqeq = True
|
||||
else:
|
||||
yield self._actual_iterator(lines[start_index:index])
|
||||
# The next block of output lines starts after the separator.
|
||||
start_index = index + 1
|
||||
# Iterate over complete output if no separator was found.
|
||||
if not found_eqeq:
|
||||
yield self._actual_iterator(lines)
|
||||
|
||||
def _actual_iterator(self, lines):
|
||||
return self._iterator(lines, self._ignore_actual_line)
|
||||
|
||||
def _expected_iterator(self, lines):
|
||||
return self._iterator(lines, self._ignore_expected_line)
|
||||
|
||||
def _ignore_actual_line(self, line):
|
||||
"""Ignore empty lines, valgrind output, Android output and trace
|
||||
incremental marking output.
|
||||
"""
|
||||
if not line:
|
||||
return True
|
||||
return (line.startswith('==') or
|
||||
line.startswith('**') or
|
||||
line.startswith('ANDROID') or
|
||||
'[IncrementalMarking]' in line or
|
||||
# FIXME(machenbach): The test driver shouldn't try to use slow
|
||||
# asserts if they weren't compiled. This fails in optdebug=2.
|
||||
line == 'Warning: unknown flag --enable-slow-asserts.' or
|
||||
line == 'Try --help for options')
|
||||
|
||||
def _ignore_expected_line(self, line):
|
||||
return not line
|
||||
|
||||
def _iterator(self, lines, ignore_predicate):
|
||||
for line in lines:
|
||||
line = line.strip()
|
||||
if not ignore_predicate(line):
|
||||
yield line
|
||||
|
||||
def _is_negative(self):
|
||||
return False
|
||||
|
Loading…
Reference in New Issue
Block a user