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