diff options
Diffstat (limited to 'deps/v8/test/message/testcfg.py')
-rw-r--r-- | deps/v8/test/message/testcfg.py | 112 |
1 files changed, 46 insertions, 66 deletions
diff --git a/deps/v8/test/message/testcfg.py b/deps/v8/test/message/testcfg.py index 28a1e641f6..cd1495f390 100644 --- a/deps/v8/test/message/testcfg.py +++ b/deps/v8/test/message/testcfg.py @@ -25,24 +25,20 @@ # (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.local import utils from testrunner.objects import testcase +from testrunner.outproc import message -FLAGS_PATTERN = re.compile(r"//\s+Flags:(.*)") INVALID_FLAGS = ["--enable-slow-asserts"] MODULE_PATTERN = re.compile(r"^// MODULE$", flags=re.MULTILINE) -class MessageTestSuite(testsuite.TestSuite): - def __init__(self, name, root): - super(MessageTestSuite, self).__init__(name, root) - +class TestSuite(testsuite.TestSuite): def ListTests(self, context): tests = [] for dirname, dirs, files in os.walk(self.root): @@ -55,80 +51,64 @@ class MessageTestSuite(testsuite.TestSuite): fullpath = os.path.join(dirname, filename) relpath = fullpath[len(self.root) + 1 : -3] testname = relpath.replace(os.path.sep, "/") - test = testcase.TestCase(self, testname) + test = self._create_test(testname) tests.append(test) return tests - def CreateVariantGenerator(self, variants): - return super(MessageTestSuite, self).CreateVariantGenerator( + def _test_class(self): + return TestCase + + def CreateLegacyVariantsGenerator(self, variants): + return super(TestSuite, self).CreateLegacyVariantsGenerator( variants + ["preparser"]) - def GetParametersForTestCase(self, testcase, context): - source = self.GetSourceForTest(testcase) + def create_variant_proc(self, variants): + return super(TestSuite, self).create_variant_proc(variants + ['preparser']) + + +class TestCase(testcase.TestCase): + def __init__(self, *args, **kwargs): + super(TestCase, self).__init__(*args, **kwargs) + + source = self.get_source() + self._source_files = self._parse_source_files(source) + self._source_flags = self._parse_source_flags(source) + + def _parse_source_files(self, source): files = [] if MODULE_PATTERN.search(source): files.append("--module") - files.append(os.path.join(self.root, testcase.path + ".js")) - flags = testcase.flags + context.mode_flags - flags_match = re.findall(FLAGS_PATTERN, source) - for match in flags_match: - flags += match.strip().split() - flags = [x for x in flags if x not in INVALID_FLAGS] - return files, flags, {} - - def GetSourceForTest(self, testcase): - filename = os.path.join(self.root, testcase.path + self.suffix()) - with open(filename) as f: - return f.read() - - def _IgnoreLine(self, string): - """Ignore empty lines, valgrind output, Android output.""" - if not string: return True - if not string.strip(): return True - return (string.startswith("==") or string.startswith("**") or - string.startswith("ANDROID")) - - def _GetExpectedFail(self, testcase): - path = testcase.path + files.append(os.path.join(self.suite.root, self.path + ".js")) + return files + + def _expected_fail(self): + path = self.path while path: - (head, tail) = os.path.split(path) - if tail == "fail": + head, tail = os.path.split(path) + if tail == 'fail': return True path = head return False - def IsFailureOutput(self, testcase): - output = testcase.output - testpath = testcase.path - expected_fail = self._GetExpectedFail(testcase) - fail = testcase.output.exit_code != 0 - if expected_fail != fail: - return True - expected_path = os.path.join(self.root, testpath + ".out") - expected_lines = [] - # Can't use utils.ReadLinesFrom() here because it strips whitespace. - with open(expected_path) as f: - for line in f: - if line.startswith("#") or not line.strip(): continue - expected_lines.append(line) - raw_lines = output.stdout.splitlines() - actual_lines = [ s for s in raw_lines if not self._IgnoreLine(s) ] - env = { "basename": os.path.basename(testpath + ".js") } - if len(expected_lines) != len(actual_lines): - return True - for (expected, actual) in itertools.izip_longest( - expected_lines, actual_lines, fillvalue=''): - pattern = re.escape(expected.rstrip() % env) - pattern = pattern.replace("\\*", ".*") - pattern = pattern.replace("\\{NUMBER\\}", "\d+(?:\.\d*)?") - pattern = "^%s$" % pattern - if not re.match(pattern, actual): - return True - return False + def _get_cmd_params(self, ctx): + params = super(TestCase, self)._get_cmd_params(ctx) + return [p for p in params if p not in INVALID_FLAGS] + + def _get_files_params(self, ctx): + return self._source_files + + def _get_source_flags(self): + return self._source_flags + + def _get_source_path(self): + return os.path.join(self.suite.root, self.path + self._get_suffix()) - def StripOutputForTransmit(self, testcase): - pass + @property + def output_proc(self): + return message.OutProc(self.expected_outcomes, + os.path.join(self.suite.root, self.path), + self._expected_fail()) def GetSuite(name, root): - return MessageTestSuite(name, root) + return TestSuite(name, root) |