OLD | NEW |
1 # Copyright 2008 the V8 project authors. All rights reserved. | 1 # Copyright 2008 the V8 project authors. All rights reserved. |
2 # Redistribution and use in source and binary forms, with or without | 2 # Redistribution and use in source and binary forms, with or without |
3 # modification, are permitted provided that the following conditions are | 3 # modification, are permitted provided that the following conditions are |
4 # met: | 4 # met: |
5 # | 5 # |
6 # * Redistributions of source code must retain the above copyright | 6 # * Redistributions of source code must retain the above copyright |
7 # notice, this list of conditions and the following disclaimer. | 7 # notice, this list of conditions and the following disclaimer. |
8 # * Redistributions in binary form must reproduce the above | 8 # * Redistributions in binary form must reproduce the above |
9 # copyright notice, this list of conditions and the following | 9 # copyright notice, this list of conditions and the following |
10 # disclaimer in the documentation and/or other materials provided | 10 # disclaimer in the documentation and/or other materials provided |
(...skipping 14 matching lines...) Expand all Loading... |
25 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 import test | 28 import test |
29 import os | 29 import os |
30 from os.path import join, dirname, exists | 30 from os.path import join, dirname, exists |
31 import re | 31 import re |
32 | 32 |
33 | 33 |
34 FLAGS_PATTERN = re.compile(r"//\s+Flags:(.*)") | 34 FLAGS_PATTERN = re.compile(r"//\s+Flags:(.*)") |
| 35 FILES_PATTERN = re.compile(r"//\s+Files:(.*)") |
35 | 36 |
36 | 37 |
37 class MjsunitTestCase(test.TestCase): | 38 class MjsunitTestCase(test.TestCase): |
38 | 39 |
39 def __init__(self, path, file, mode, context, config): | 40 def __init__(self, path, file, mode, context, config): |
40 super(MjsunitTestCase, self).__init__(context, path) | 41 super(MjsunitTestCase, self).__init__(context, path) |
41 self.file = file | 42 self.file = file |
42 self.config = config | 43 self.config = config |
43 self.mode = mode | 44 self.mode = mode |
44 | 45 |
45 def GetLabel(self): | 46 def GetLabel(self): |
46 return "%s %s" % (self.mode, self.GetName()) | 47 return "%s %s" % (self.mode, self.GetName()) |
47 | 48 |
48 def GetName(self): | 49 def GetName(self): |
49 return self.path[-1] | 50 return self.path[-1] |
50 | 51 |
51 def GetCommand(self): | 52 def GetCommand(self): |
52 result = [self.config.context.GetVm(self.mode)] | 53 result = [self.config.context.GetVm(self.mode)] |
53 source = open(self.file).read() | 54 source = open(self.file).read() |
54 flags_match = FLAGS_PATTERN.search(source) | 55 flags_match = FLAGS_PATTERN.search(source) |
55 if flags_match: | 56 if flags_match: |
56 result += flags_match.group(1).strip().split() | 57 result += flags_match.group(1).strip().split() |
| 58 files_match = FILES_PATTERN.search(source); |
| 59 additional_files = [] |
| 60 if files_match: |
| 61 additional_files += files_match.group(1).strip().split() |
| 62 for a_file in additional_files: |
| 63 result.append(join(dirname(self.config.root), '..', a_file)) |
57 framework = join(dirname(self.config.root), 'mjsunit', 'mjsunit.js') | 64 framework = join(dirname(self.config.root), 'mjsunit', 'mjsunit.js') |
58 result += [framework, self.file] | 65 result += [framework, self.file] |
59 return result | 66 return result |
60 | 67 |
61 def GetSource(self): | 68 def GetSource(self): |
62 return open(self.file).read() | 69 return open(self.file).read() |
63 | 70 |
64 | 71 |
65 class MjsunitTestConfiguration(test.TestConfiguration): | 72 class MjsunitTestConfiguration(test.TestConfiguration): |
66 | 73 |
67 def __init__(self, context, root): | 74 def __init__(self, context, root): |
68 super(MjsunitTestConfiguration, self).__init__(context, root) | 75 super(MjsunitTestConfiguration, self).__init__(context, root) |
69 | 76 |
70 def Ls(self, path): | 77 def Ls(self, path): |
71 def SelectTest(name): | 78 def SelectTest(name): |
72 return name.endswith('.js') and name != 'mjsunit.js' | 79 return name.endswith('.js') and name != 'mjsunit.js' |
73 return [f[:-3] for f in os.listdir(path) if SelectTest(f)] | 80 return [f[:-3] for f in os.listdir(path) if SelectTest(f)] |
74 | 81 |
75 def ListTests(self, current_path, path, mode): | 82 def ListTests(self, current_path, path, mode): |
76 mjsunit = [current_path + [t] for t in self.Ls(self.root)] | 83 mjsunit = [current_path + [t] for t in self.Ls(self.root)] |
77 regress = [current_path + ['regress', t] for t in self.Ls(join(self.root, 'r
egress'))] | 84 regress = [current_path + ['regress', t] for t in self.Ls(join(self.root, 'r
egress'))] |
78 bugs = [current_path + ['bugs', t] for t in self.Ls(join(self.root, 'bugs'))
] | 85 bugs = [current_path + ['bugs', t] for t in self.Ls(join(self.root, 'bugs'))
] |
79 all_tests = mjsunit + regress + bugs | 86 tools = [current_path + ['tools', t] for t in self.Ls(join(self.root, 'tools
'))] |
| 87 all_tests = mjsunit + regress + bugs + tools |
80 result = [] | 88 result = [] |
81 for test in all_tests: | 89 for test in all_tests: |
82 if self.Contains(path, test): | 90 if self.Contains(path, test): |
83 file_path = join(self.root, reduce(join, test[1:], "") + ".js") | 91 file_path = join(self.root, reduce(join, test[1:], "") + ".js") |
84 result.append(MjsunitTestCase(test, file_path, mode, self.context, self)
) | 92 result.append(MjsunitTestCase(test, file_path, mode, self.context, self)
) |
85 return result | 93 return result |
86 | 94 |
87 def GetBuildRequirements(self): | 95 def GetBuildRequirements(self): |
88 return ['sample', 'sample=shell'] | 96 return ['sample', 'sample=shell'] |
89 | 97 |
90 def GetTestStatus(self, sections, defs): | 98 def GetTestStatus(self, sections, defs): |
91 status_file = join(self.root, 'mjsunit.status') | 99 status_file = join(self.root, 'mjsunit.status') |
92 if exists(status_file): | 100 if exists(status_file): |
93 test.ReadConfigurationInto(status_file, sections, defs) | 101 test.ReadConfigurationInto(status_file, sections, defs) |
94 | 102 |
95 | 103 |
96 | 104 |
97 def GetConfiguration(context, root): | 105 def GetConfiguration(context, root): |
98 return MjsunitTestConfiguration(context, root) | 106 return MjsunitTestConfiguration(context, root) |
OLD | NEW |