Index: test/inspector-protocol/testcfg.py |
diff --git a/test/inspector-protocol/testcfg.py b/test/inspector-protocol/testcfg.py |
new file mode 100644 |
index 0000000000000000000000000000000000000000..f94aec2e9e6642407e2babd9838e5895299a43b4 |
--- /dev/null |
+++ b/test/inspector-protocol/testcfg.py |
@@ -0,0 +1,68 @@ |
+# Copyright 2016 the V8 project authors. All rights reserved. |
+# Use of this source code is governed by a BSD-style license that can be |
+# found in the LICENSE file. |
+ |
+import itertools |
+import os |
+import re |
+ |
+from testrunner.local import testsuite |
+from testrunner.local import utils |
+from testrunner.objects import testcase |
+ |
+FLAGS_PATTERN = re.compile(r"//\s+Flags:(.*)") |
+PROTOCOL_TEST_JS = "protocol-test.js" |
+EXPECTED_SUFFIX = "-expected.txt" |
+ |
+class InspectorProtocolTestSuite(testsuite.TestSuite): |
+ |
+ def __init__(self, name, root): |
+ super(InspectorProtocolTestSuite, self).__init__(name, root) |
+ |
+ def ListTests(self, context): |
+ tests = [] |
+ for dirname, dirs, files in os.walk(os.path.join(self.root), followlinks=True): |
+ for dotted in [x for x in dirs if x.startswith('.')]: |
+ dirs.remove(dotted) |
+ dirs.sort() |
+ files.sort() |
+ for filename in files: |
+ if filename.endswith(".js") and filename != PROTOCOL_TEST_JS: |
+ fullpath = os.path.join(dirname, filename) |
+ relpath = fullpath[len(self.root) + 1 : -3] |
+ testname = relpath.replace(os.path.sep, "/") |
+ test = testcase.TestCase(self, testname) |
+ tests.append(test) |
+ return tests |
+ |
+ def GetFlagsForTestCase(self, testcase, context): |
+ source = self.GetSourceForTest(testcase) |
+ flags_match = re.findall(FLAGS_PATTERN, source) |
+ flags = [] |
+ for match in flags_match: |
+ flags += match.strip().split() |
+ testname = testcase.path.split(os.path.sep)[-1] |
+ testfilename = os.path.join(self.root, testcase.path + self.suffix()) |
+ protocoltestfilename = os.path.join(self.root, PROTOCOL_TEST_JS) |
+ return [ protocoltestfilename, testfilename ] + flags |
+ |
+ def GetSourceForTest(self, testcase): |
+ filename = os.path.join(self.root, testcase.path + self.suffix()) |
+ with open(filename) as f: |
+ return f.read() |
+ |
+ def shell(self): |
+ return "inspector-protocol" |
+ |
+ 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.
|
+ expected_path = os.path.join(self.root, testcase.path + EXPECTED_SUFFIX) |
+ expected_lines = utils.ReadLinesFrom(expected_path) |
+ actual_lines = [ s.strip() for s in testcase.output.stdout.splitlines() if s.strip() ] |
+ for (expected, actual) in itertools.izip_longest( |
+ expected_lines, actual_lines, fillvalue=''): |
+ if expected != actual: |
+ return True |
+ return False |
+ |
+def GetSuite(name, root): |
+ return InspectorProtocolTestSuite(name, root) |