OLD | NEW |
1 # Copyright 2016 the V8 project authors. All rights reserved. | 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 | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import itertools | 5 import itertools |
6 import os | 6 import os |
7 import re | 7 import re |
8 import shlex | |
9 | 8 |
10 from testrunner.local import testsuite | 9 from testrunner.local import testsuite |
11 from testrunner.local import utils | 10 from testrunner.local import utils |
12 from testrunner.objects import testcase | 11 from testrunner.objects import testcase |
13 | 12 |
14 FLAGS_PATTERN = re.compile(r"//\s+Flags:(.*)") | 13 FLAGS_PATTERN = re.compile(r"//\s+Flags:(.*)") |
15 PROTOCOL_TEST_JS = "protocol-test.js" | 14 PROTOCOL_TEST_JS = "protocol-test.js" |
16 EXPECTED_SUFFIX = "-expected.txt" | 15 EXPECTED_SUFFIX = "-expected.txt" |
17 RESOURCES_FOLDER = "resources" | 16 RESOURCES_FOLDER = "resources" |
18 | 17 |
(...skipping 18 matching lines...) Expand all Loading... |
37 testname = relpath.replace(os.path.sep, "/") | 36 testname = relpath.replace(os.path.sep, "/") |
38 test = testcase.TestCase(self, testname) | 37 test = testcase.TestCase(self, testname) |
39 tests.append(test) | 38 tests.append(test) |
40 return tests | 39 return tests |
41 | 40 |
42 def GetFlagsForTestCase(self, testcase, context): | 41 def GetFlagsForTestCase(self, testcase, context): |
43 source = self.GetSourceForTest(testcase) | 42 source = self.GetSourceForTest(testcase) |
44 flags = [] + context.mode_flags | 43 flags = [] + context.mode_flags |
45 flags_match = re.findall(FLAGS_PATTERN, source) | 44 flags_match = re.findall(FLAGS_PATTERN, source) |
46 for match in flags_match: | 45 for match in flags_match: |
47 flags += shlex.split(match.strip()) | 46 flags += match.strip().split() |
48 testname = testcase.path.split(os.path.sep)[-1] | 47 testname = testcase.path.split(os.path.sep)[-1] |
49 testfilename = os.path.join(self.root, testcase.path + self.suffix()) | 48 testfilename = os.path.join(self.root, testcase.path + self.suffix()) |
50 protocoltestfilename = os.path.join(self.root, PROTOCOL_TEST_JS) | 49 protocoltestfilename = os.path.join(self.root, PROTOCOL_TEST_JS) |
51 return testcase.flags + flags + [ protocoltestfilename, testfilename ] | 50 return testcase.flags + flags + [ protocoltestfilename, testfilename ] |
52 | 51 |
53 def GetSourceForTest(self, testcase): | 52 def GetSourceForTest(self, testcase): |
54 filename = os.path.join(self.root, testcase.path + self.suffix()) | 53 filename = os.path.join(self.root, testcase.path + self.suffix()) |
55 with open(filename) as f: | 54 with open(filename) as f: |
56 return f.read() | 55 return f.read() |
57 | 56 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 | 103 |
105 for act_iterator in ActBlockIterator(): | 104 for act_iterator in ActBlockIterator(): |
106 for (expected, actual) in itertools.izip_longest( | 105 for (expected, actual) in itertools.izip_longest( |
107 ExpIterator(), act_iterator, fillvalue=''): | 106 ExpIterator(), act_iterator, fillvalue=''): |
108 if expected != actual: | 107 if expected != actual: |
109 return True | 108 return True |
110 return False | 109 return False |
111 | 110 |
112 def GetSuite(name, root): | 111 def GetSuite(name, root): |
113 return InspectorProtocolTestSuite(name, root) | 112 return InspectorProtocolTestSuite(name, root) |
OLD | NEW |