Commit a130438e authored by Michal Majewski's avatar Michal Majewski Committed by Commit Bot

[test] Removed old output parsing functions.

All get outcome logic moved out from testsuite which makes output
processors serializable. Output processors that are not global
are stored inside testcase to share them with all test copies.

Bug: v8:6917
Cq-Include-Trybots: master.tryserver.v8:v8_linux_noi18n_rel_ng
Change-Id: I625466b2b00565d885556f96cab03d8d16fa7ff4
Reviewed-on: https://chromium-review.googlesource.com/837069
Commit-Queue: Michał Majewski <majeski@google.com>
Reviewed-by: 's avatarMichael Achenbach <machenbach@chromium.org>
Reviewed-by: 's avatarSergiy Byelozyorov <sergiyb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#50275}
parent 58c82bda
......@@ -60,7 +60,8 @@ class TestCase(testcase.TestCase):
def get_shell(self):
return 'inspector-test'
def get_output_proc(self):
@property
def output_proc(self):
return self._outproc
......
......@@ -71,8 +71,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._out_proc = OutProc(os.path.join(self.suite.root, self.path),
self._expected_fail())
self._outproc = OutProc(os.path.join(self.suite.root, self.path),
self._expected_fail())
def _parse_source_files(self, source):
files = []
......@@ -103,8 +103,9 @@ 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._out_proc
@property
def output_proc(self):
return self._outproc
class OutProc(outproc.OutProc):
......@@ -152,9 +153,6 @@ class OutProc(outproc.OutProc):
string.startswith("ANDROID")
)
def _is_negative(self):
return False
def GetSuite(name, root):
return TestSuite(name, root)
......@@ -41,7 +41,8 @@ class TestCase(testcase.TestCase):
def get_shell(self):
return SHELL
def get_output_proc(self):
@property
def output_proc(self):
return self.suite.out_proc
......@@ -67,9 +68,6 @@ class OutProc(outproc.OutProc):
return True
return False
def _is_negative(self):
return False
def GetSuite(name, root):
return TestSuite(name, root)
......@@ -106,16 +106,14 @@ class TestCase(testcase.TestCase):
def _get_source_path(self):
return os.path.join(self.suite.testroot, self.path + self._get_suffix())
def get_output_proc(self):
@property
def output_proc(self):
if self.path.endswith('-n'):
return OutProc.NEGATIVE
return OutProc.DEFAULT
return MOZILLA_NEGATIVE
return MOZILLA_DEFAULT
class OutProc(outproc.OutProc):
def __init__(self):
pass
def _is_failure_output(self, output):
return (
output.exit_code != 0 or
......@@ -123,18 +121,14 @@ class OutProc(outproc.OutProc):
)
class DefaultOutProc(OutProc):
def _is_negative(self):
return False
class NegativeOutProc(OutProc):
def _is_negative(self):
@property
def negative(self):
return True
OutProc.DEFAULT = DefaultOutProc()
OutProc.NEGATIVE = NegativeOutProc()
MOZILLA_DEFAULT = OutProc()
MOZILLA_NEGATIVE = NegativeOutProc()
def GetSuite(name, root):
......
......@@ -201,6 +201,16 @@ class TestCase(testcase.TestCase):
source = self.get_source()
self.test_record = self.suite.parse_test_record(source, self.path)
expected_exception = (
self.test_record
.get('negative', {})
.get('type', None)
)
if expected_exception is None:
self._outproc = NO_EXCEPTION
else:
self._outproc = OutProc(expected_exception)
def _get_files_params(self, ctx):
return (
list(self.suite.harness) +
......@@ -238,15 +248,9 @@ class TestCase(testcase.TestCase):
return path
return os.path.join(self.suite.testroot, filename)
def get_output_proc(self):
expected_exception = (
self.test_record
.get('negative', {})
.get('type', None)
)
if expected_exception is None:
return OutProc.NO_EXCEPTION
return OutProc(expected_exception)
@property
def output_proc(self):
return self._outproc
class OutProc(outproc.OutProc):
......@@ -271,11 +275,8 @@ class OutProc(outproc.OutProc):
else:
return None
def _is_negative(self):
return False
OutProc.NO_EXCEPTION = OutProc()
NO_EXCEPTION = OutProc()
def GetSuite(name, root):
......
......@@ -104,7 +104,8 @@ 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):
@property
def output_proc(self):
return self._outproc
......
......@@ -57,7 +57,7 @@ class ProgressIndicator(object):
pass
def PrintFailureHeader(self, test):
if test.suite.IsNegativeTest(test):
if test.output_proc.negative:
negative_marker = '[negative] '
else:
negative_marker = ''
......@@ -356,7 +356,7 @@ class JsonTestProgressIndicator(ProgressIndicator):
"stdout": output.stdout,
"stderr": output.stderr,
"exit_code": output.exit_code,
"result": test.get_output_proc().get_outcome(output),
"result": test.output_proc.get_outcome(output),
"expected": test.expected_outcomes,
"duration": output.duration,
......@@ -395,7 +395,7 @@ class FlakinessTestProgressIndicator(ProgressIndicator):
def HasRun(self, test, output, has_unexpected_output):
key = test.get_id()
outcome = test.get_output_proc().get_outcome(output)
outcome = test.output_proc.get_outcome(output)
assert outcome in ["PASS", "FAIL", "CRASH", "TIMEOUT"]
if test.run == 1:
# First run of this test.
......
......@@ -171,12 +171,6 @@ class TestSuite(object):
break
self.tests = filtered
def IsFailureOutput(self, testcase, output):
return output.exit_code != 0
def IsNegativeTest(self, testcase):
return False
def HasUnexpectedOutput(self, test, output, ctx=None):
if ctx and ctx.predictable:
# Only check the exit code of the predictable_wrapper in
......@@ -186,11 +180,10 @@ class TestSuite(object):
# the status file (e.g. known bugs).
return (
output.exit_code != 0 and
not self.IsNegativeTest(test) and
not test.output_proc.negative and
statusfile.FAIL not in test.expected_outcomes
)
return (
test.get_output_proc().get_outcome(output) not in test.expected_outcomes)
return test.output_proc.get_outcome(output) not in test.expected_outcomes
def _create_test(self, path, **kwargs):
test = self._test_class()(self, path, self._path_to_name(path), **kwargs)
......
......@@ -8,10 +8,6 @@ from ..local import statusfile
class OutProc(object):
def __init__(self, test):
# TODO(majeski): Get only necessary fields from the test.
self._test = test
def get_outcome(self, output):
if output.HasCrashed():
return statusfile.CRASH
......@@ -24,17 +20,19 @@ class OutProc(object):
def _has_failed(self, output):
execution_failed = self._is_failure_output(output)
if self._is_negative():
if self.negative:
return not execution_failed
return execution_failed
def _is_failure_output(self, output):
# TODO(majeski): Move implementation.
return self._test.suite.IsFailureOutput(self._test, output)
return output.exit_code != 0
@property
def negative(self):
return False
def _is_negative(self):
# TODO(majeski): Move implementation.
return self._test.suite.IsNegativeTest(self._test)
DEFAULT = OutProc()
class ExpectedOutProc(OutProc):
......@@ -103,6 +101,3 @@ class ExpectedOutProc(OutProc):
line = line.strip()
if not ignore_predicate(line):
yield line
def _is_negative(self):
return False
......@@ -237,11 +237,9 @@ class TestCase(object):
def _get_source_path(self):
return None
def get_output_proc(self):
return self._output_proc_class()(self)
def _output_proc_class(self):
return outproc.OutProc
@property
def output_proc(self):
return outproc.DEFAULT
def __cmp__(self, other):
# Make sure that test cases are sorted correctly if sorted without
......
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