Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2316)

Unified Diff: test/inspector-protocol/testcfg.py

Issue 2358943002: [inspector] added inspector protocol test runner (Closed)
Patch Set: a Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..c63ef9a9d8b333106fcf84371e50031f7d3c171a
--- /dev/null
+++ b/test/inspector-protocol/testcfg.py
@@ -0,0 +1,77 @@
+# 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"
+
+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")
dgozman 2016/09/22 17:44:49 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):
+ output = testcase.output
+ testpath = testcase.path
+ expected_path = os.path.join(self.root, testpath + "-expected.txt")
+ expected_lines = utils.ReadLinesFrom(expected_path)
+ raw_lines = output.stdout.splitlines()
+ actual_lines = [ s.strip() for s in raw_lines if s.strip() ]
+
+ for (expected, actual) in itertools.izip_longest(
+ expected_lines, actual_lines, fillvalue=''):
+ if expected != actual:
+ print [ expected, actual ]
+ return True
+ if len(expected_lines) != len(actual_lines):
+ print "-----"
+ print "\n".join(raw_lines)
+ print "-----"
+ return True
+ return False
+
+def GetSuite(name, root):
+ return InspectorProtocolTestSuite(name, root)

Powered by Google App Engine
This is Rietveld 408576698