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

Side by Side Diff: test/preparser/testcfg.py

Issue 14348002: Remove SCons related files (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: fixed os.path.join occurrences that depended on old imports Created 7 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « test/mozilla/testcfg.py ('k') | test/test262/testcfg.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2011 the V8 project authors. All rights reserved. 1 # Copyright 2011 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 24 matching lines...) Expand all
35 35
36 36
37 class PreparserTestSuite(testsuite.TestSuite): 37 class PreparserTestSuite(testsuite.TestSuite):
38 def __init__(self, name, root): 38 def __init__(self, name, root):
39 super(PreparserTestSuite, self).__init__(name, root) 39 super(PreparserTestSuite, self).__init__(name, root)
40 40
41 def shell(self): 41 def shell(self):
42 return "preparser" 42 return "preparser"
43 43
44 def _GetExpectations(self): 44 def _GetExpectations(self):
45 expects_file = join(self.root, "preparser.expectation") 45 expects_file = os.path.join(self.root, "preparser.expectation")
46 expectations_map = {} 46 expectations_map = {}
47 if not os.path.exists(expects_file): return expectations_map 47 if not os.path.exists(expects_file): return expectations_map
48 rule_regex = re.compile("^([\w\-]+)(?::([\w\-]+))?(?::(\d+),(\d+))?$") 48 rule_regex = re.compile("^([\w\-]+)(?::([\w\-]+))?(?::(\d+),(\d+))?$")
49 for line in utils.ReadLinesFrom(expects_file): 49 for line in utils.ReadLinesFrom(expects_file):
50 rule_match = rule_regex.match(line) 50 rule_match = rule_regex.match(line)
51 if not rule_match: continue 51 if not rule_match: continue
52 expects = [] 52 expects = []
53 if (rule_match.group(2)): 53 if (rule_match.group(2)):
54 expects += [rule_match.group(2)] 54 expects += [rule_match.group(2)]
55 if (rule_match.group(3)): 55 if (rule_match.group(3)):
56 expects += [rule_match.group(3), rule_match.group(4)] 56 expects += [rule_match.group(3), rule_match.group(4)]
57 expectations_map[rule_match.group(1)] = " ".join(expects) 57 expectations_map[rule_match.group(1)] = " ".join(expects)
58 return expectations_map 58 return expectations_map
59 59
60 def _ParsePythonTestTemplates(self, result, filename): 60 def _ParsePythonTestTemplates(self, result, filename):
61 pathname = join(self.root, filename + ".pyt") 61 pathname = os.path.join(self.root, filename + ".pyt")
62 def Test(name, source, expectation): 62 def Test(name, source, expectation):
63 source = source.replace("\n", " ") 63 source = source.replace("\n", " ")
64 testname = os.path.join(filename, name) 64 testname = os.path.join(filename, name)
65 flags = ["-e", source] 65 flags = ["-e", source]
66 if expectation: 66 if expectation:
67 flags += ["throws", expectation] 67 flags += ["throws", expectation]
68 test = testcase.TestCase(self, testname, flags=flags) 68 test = testcase.TestCase(self, testname, flags=flags)
69 result.append(test) 69 result.append(test)
70 def Template(name, source): 70 def Template(name, source):
71 def MkTest(replacement, expectation): 71 def MkTest(replacement, expectation):
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 return testcase.flags[1] 111 return testcase.flags[1]
112 with open(testcase.flags[0]) as f: 112 with open(testcase.flags[0]) as f:
113 return f.read() 113 return f.read()
114 114
115 def VariantFlags(self): 115 def VariantFlags(self):
116 return [[]]; 116 return [[]];
117 117
118 118
119 def GetSuite(name, root): 119 def GetSuite(name, root):
120 return PreparserTestSuite(name, root) 120 return PreparserTestSuite(name, root)
121
122
123 # Deprecated definitions below.
124 # TODO(jkummerow): Remove when SCons is no longer supported.
125
126
127 from os.path import join, exists, isfile
128 import test
129
130
131 class PreparserTestCase(test.TestCase):
132
133 def __init__(self, root, path, executable, mode, throws, context, source):
134 super(PreparserTestCase, self).__init__(context, path, mode)
135 self.executable = executable
136 self.root = root
137 self.throws = throws
138 self.source = source
139
140 def GetLabel(self):
141 return "%s %s %s" % (self.mode, self.path[-2], self.path[-1])
142
143 def GetName(self):
144 return self.path[-1]
145
146 def HasSource(self):
147 return self.source is not None
148
149 def GetSource(self):
150 return self.source
151
152 def BuildCommand(self, path):
153 if (self.source is not None):
154 result = [self.executable, "-e", self.source]
155 else:
156 testfile = join(self.root, self.GetName()) + ".js"
157 result = [self.executable, testfile]
158 if (self.throws):
159 result += ['throws'] + self.throws
160 return result
161
162 def GetCommand(self):
163 return self.BuildCommand(self.path)
164
165 def Run(self):
166 return test.TestCase.Run(self)
167
168
169 class PreparserTestConfiguration(test.TestConfiguration):
170
171 def __init__(self, context, root):
172 super(PreparserTestConfiguration, self).__init__(context, root)
173
174 def GetBuildRequirements(self):
175 return ['preparser']
176
177 def GetExpectations(self):
178 expects_file = join(self.root, 'preparser.expectation')
179 map = {}
180 if exists(expects_file):
181 rule_regex = re.compile("^([\w\-]+)(?::([\w\-]+))?(?::(\d+),(\d+))?$")
182 for line in utils.ReadLinesFrom(expects_file):
183 if (line[0] == '#'): continue
184 rule_match = rule_regex.match(line)
185 if rule_match:
186 expects = []
187 if (rule_match.group(2)):
188 expects = expects + [rule_match.group(2)]
189 if (rule_match.group(3)):
190 expects = expects + [rule_match.group(3), rule_match.group(4)]
191 map[rule_match.group(1)] = expects
192 return map;
193
194 def ParsePythonTestTemplates(self, result, filename,
195 executable, current_path, mode):
196 pathname = join(self.root, filename + ".pyt")
197 def Test(name, source, expectation):
198 throws = None
199 if (expectation is not None):
200 throws = [expectation]
201 test = PreparserTestCase(self.root,
202 current_path + [filename, name],
203 executable,
204 mode, throws, self.context,
205 source.replace("\n", " "))
206 result.append(test)
207 def Template(name, source):
208 def MkTest(replacement, expectation):
209 testname = name
210 testsource = source
211 for key in replacement.keys():
212 testname = testname.replace("$"+key, replacement[key]);
213 testsource = testsource.replace("$"+key, replacement[key]);
214 Test(testname, testsource, expectation)
215 return MkTest
216 execfile(pathname, {"Test": Test, "Template": Template})
217
218 def ListTests(self, current_path, path, mode, variant_flags):
219 executable = 'preparser'
220 if utils.IsWindows():
221 executable += '.exe'
222 executable = join(self.context.buildspace, executable)
223 if not isfile(executable):
224 executable = join('obj', 'preparser', mode, 'preparser')
225 if utils.IsWindows():
226 executable += '.exe'
227 executable = join(self.context.buildspace, executable)
228 expectations = self.GetExpectations()
229 result = []
230 # Find all .js files in tests/preparser directory.
231 filenames = [f[:-3] for f in os.listdir(self.root) if f.endswith(".js")]
232 filenames.sort()
233 for file in filenames:
234 throws = None;
235 if (file in expectations):
236 throws = expectations[file]
237 result.append(PreparserTestCase(self.root,
238 current_path + [file], executable,
239 mode, throws, self.context, None))
240 # Find all .pyt files in test/preparser directory.
241 filenames = [f[:-4] for f in os.listdir(self.root) if f.endswith(".pyt")]
242 filenames.sort()
243 for file in filenames:
244 # Each file as a python source file to be executed in a specially
245 # created environment (defining the Template and Test functions)
246 self.ParsePythonTestTemplates(result, file,
247 executable, current_path, mode)
248 return result
249
250 def GetTestStatus(self, sections, defs):
251 status_file = join(self.root, 'preparser.status')
252 if exists(status_file):
253 test.ReadConfigurationInto(status_file, sections, defs)
254
255 def VariantFlags(self):
256 return [[]];
257
258
259 def GetConfiguration(context, root):
260 return PreparserTestConfiguration(context, root)
OLDNEW
« no previous file with comments | « test/mozilla/testcfg.py ('k') | test/test262/testcfg.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698