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 os | 5 import os |
6 import re | 6 import re |
7 | 7 |
8 from testrunner.local import testsuite | 8 from testrunner.local import testsuite |
9 from testrunner.objects import testcase | 9 from testrunner.objects import testcase |
10 | 10 |
| 11 FILES_PATTERN = re.compile(r"//\s+Files:(.*)") |
11 FLAGS_PATTERN = re.compile(r"//\s+Flags:(.*)") | 12 FLAGS_PATTERN = re.compile(r"//\s+Flags:(.*)") |
12 | 13 |
13 class DebuggerTestSuite(testsuite.TestSuite): | 14 class DebuggerTestSuite(testsuite.TestSuite): |
14 | 15 |
15 def __init__(self, name, root): | 16 def __init__(self, name, root): |
16 super(DebuggerTestSuite, self).__init__(name, root) | 17 super(DebuggerTestSuite, self).__init__(name, root) |
17 | 18 |
18 def ListTests(self, context): | 19 def ListTests(self, context): |
19 tests = [] | 20 tests = [] |
20 for dirname, dirs, files in os.walk(self.root): | 21 for dirname, dirs, files in os.walk(self.root): |
(...skipping 10 matching lines...) Expand all Loading... |
31 tests.append(test) | 32 tests.append(test) |
32 return tests | 33 return tests |
33 | 34 |
34 def GetFlagsForTestCase(self, testcase, context): | 35 def GetFlagsForTestCase(self, testcase, context): |
35 source = self.GetSourceForTest(testcase) | 36 source = self.GetSourceForTest(testcase) |
36 flags = ["--enable-inspector", "--allow-natives-syntax"] + context.mode_flag
s | 37 flags = ["--enable-inspector", "--allow-natives-syntax"] + context.mode_flag
s |
37 flags_match = re.findall(FLAGS_PATTERN, source) | 38 flags_match = re.findall(FLAGS_PATTERN, source) |
38 for match in flags_match: | 39 for match in flags_match: |
39 flags += match.strip().split() | 40 flags += match.strip().split() |
40 | 41 |
| 42 files_list = [] # List of file names to append to command arguments. |
| 43 files_match = FILES_PATTERN.search(source); |
| 44 # Accept several lines of 'Files:'. |
| 45 while True: |
| 46 if files_match: |
| 47 files_list += files_match.group(1).strip().split() |
| 48 files_match = FILES_PATTERN.search(source, files_match.end()) |
| 49 else: |
| 50 break |
| 51 |
41 files = [] | 52 files = [] |
42 files.append(os.path.normpath(os.path.join(self.root, "..", "mjsunit", "mjsu
nit.js"))) | 53 files.append(os.path.normpath(os.path.join(self.root, "..", "mjsunit", "mjsu
nit.js"))) |
43 files.append(os.path.join(self.root, "test-api.js")) | 54 files.append(os.path.join(self.root, "test-api.js")) |
| 55 files.extend([ os.path.normpath(os.path.join(self.root, '..', '..', f)) |
| 56 for f in files_list ]) |
44 files.append(os.path.join(self.root, testcase.path + self.suffix())) | 57 files.append(os.path.join(self.root, testcase.path + self.suffix())) |
45 | 58 |
46 flags += files | 59 flags += files |
47 if context.isolates: | 60 if context.isolates: |
48 flags.append("--isolate") | 61 flags.append("--isolate") |
49 flags += files | 62 flags += files |
50 | 63 |
51 return testcase.flags + flags | 64 return testcase.flags + flags |
52 | 65 |
53 def GetSourceForTest(self, testcase): | 66 def GetSourceForTest(self, testcase): |
54 filename = os.path.join(self.root, testcase.path + self.suffix()) | 67 filename = os.path.join(self.root, testcase.path + self.suffix()) |
55 with open(filename) as f: | 68 with open(filename) as f: |
56 return f.read() | 69 return f.read() |
57 | 70 |
58 def GetSuite(name, root): | 71 def GetSuite(name, root): |
59 return DebuggerTestSuite(name, root) | 72 return DebuggerTestSuite(name, root) |
OLD | NEW |