Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 # Copyright 2016 the V8 project authors. All rights reserved. | |
| 2 # Use of this source code is governed by a BSD-style license that can be | |
| 3 # found in the LICENSE file. | |
| 4 | |
| 5 import itertools | |
| 6 import os | |
| 7 import re | |
| 8 | |
| 9 from testrunner.local import testsuite | |
| 10 from testrunner.local import utils | |
| 11 from testrunner.objects import testcase | |
| 12 | |
| 13 FLAGS_PATTERN = re.compile(r"//\s+Flags:(.*)") | |
| 14 PROTOCOL_TEST_JS = "protocol-test.js" | |
| 15 EXPECTED_SUFFIX = "-expected.txt" | |
| 16 | |
| 17 class InspectorProtocolTestSuite(testsuite.TestSuite): | |
| 18 | |
| 19 def __init__(self, name, root): | |
| 20 super(InspectorProtocolTestSuite, self).__init__(name, root) | |
| 21 | |
| 22 def ListTests(self, context): | |
| 23 tests = [] | |
| 24 for dirname, dirs, files in os.walk(os.path.join(self.root), followlinks=Tru e): | |
| 25 for dotted in [x for x in dirs if x.startswith('.')]: | |
| 26 dirs.remove(dotted) | |
| 27 dirs.sort() | |
| 28 files.sort() | |
| 29 for filename in files: | |
| 30 if filename.endswith(".js") and filename != PROTOCOL_TEST_JS: | |
| 31 fullpath = os.path.join(dirname, filename) | |
| 32 relpath = fullpath[len(self.root) + 1 : -3] | |
| 33 testname = relpath.replace(os.path.sep, "/") | |
| 34 test = testcase.TestCase(self, testname) | |
| 35 tests.append(test) | |
| 36 return tests | |
| 37 | |
| 38 def GetFlagsForTestCase(self, testcase, context): | |
| 39 source = self.GetSourceForTest(testcase) | |
| 40 flags_match = re.findall(FLAGS_PATTERN, source) | |
| 41 flags = [] | |
| 42 for match in flags_match: | |
| 43 flags += match.strip().split() | |
| 44 testname = testcase.path.split(os.path.sep)[-1] | |
| 45 testfilename = os.path.join(self.root, testcase.path + self.suffix()) | |
| 46 protocoltestfilename = os.path.join(self.root, PROTOCOL_TEST_JS) | |
| 47 return [ protocoltestfilename, testfilename ] + flags | |
| 48 | |
| 49 def GetSourceForTest(self, testcase): | |
| 50 filename = os.path.join(self.root, testcase.path + self.suffix()) | |
| 51 with open(filename) as f: | |
| 52 return f.read() | |
| 53 | |
| 54 def shell(self): | |
| 55 return "inspector-protocol" | |
| 56 | |
| 57 def IsFailureOutput(self, testcase): | |
|
Michael Achenbach
2016/09/28 10:27:01
Also have a look here:
https://cs.chromium.org/chr
kozy
2016/09/29 00:06:45
Reused from test/webkit.
| |
| 58 expected_path = os.path.join(self.root, testcase.path + EXPECTED_SUFFIX) | |
| 59 expected_lines = utils.ReadLinesFrom(expected_path) | |
| 60 actual_lines = [ s.strip() for s in testcase.output.stdout.splitlines() if s .strip() ] | |
| 61 for (expected, actual) in itertools.izip_longest( | |
| 62 expected_lines, actual_lines, fillvalue=''): | |
| 63 if expected != actual: | |
| 64 return True | |
| 65 return False | |
| 66 | |
| 67 def GetSuite(name, root): | |
| 68 return InspectorProtocolTestSuite(name, root) | |
| OLD | NEW |