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

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

Issue 11035053: Rollback trunk to bleeding_edge revision 12525 (Closed) Base URL: https://v8.googlecode.com/svn/trunk
Patch Set: Created 8 years, 2 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/sputnik/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
11 # with the distribution. 11 # with the distribution.
12 # * Neither the name of Google Inc. nor the names of its 12 # * Neither the name of Google Inc. nor the names of its
13 # contributors may be used to endorse or promote products derived 13 # contributors may be used to endorse or promote products derived
14 # from this software without specific prior written permission. 14 # from this software without specific prior written permission.
15 # 15 #
16 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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 28 import test
29 import os 29 import os
30 from os.path import join, dirname, exists, isfile
31 import platform
32 import utils
30 import re 33 import re
31 34
32 from testrunner.local import testsuite
33 from testrunner.local import utils
34 from testrunner.objects import testcase
35
36
37 class PreparserTestSuite(testsuite.TestSuite):
38 def __init__(self, name, root):
39 super(PreparserTestSuite, self).__init__(name, root)
40
41 def shell(self):
42 return "preparser"
43
44 def _GetExpectations(self):
45 expects_file = join(self.root, "preparser.expectation")
46 expectations_map = {}
47 if not os.path.exists(expects_file): return expectations_map
48 rule_regex = re.compile("^([\w\-]+)(?::([\w\-]+))?(?::(\d+),(\d+))?$")
49 for line in utils.ReadLinesFrom(expects_file):
50 rule_match = rule_regex.match(line)
51 if not rule_match: continue
52 expects = []
53 if (rule_match.group(2)):
54 expects += [rule_match.group(2)]
55 if (rule_match.group(3)):
56 expects += [rule_match.group(3), rule_match.group(4)]
57 expectations_map[rule_match.group(1)] = " ".join(expects)
58 return expectations_map
59
60 def _ParsePythonTestTemplates(self, result, filename):
61 pathname = join(self.root, filename + ".pyt")
62 def Test(name, source, expectation):
63 source = source.replace("\n", " ")
64 testname = os.path.join(filename, name)
65 flags = ["-e", source]
66 if expectation:
67 flags += ["throws", expectation]
68 test = testcase.TestCase(self, testname, flags=flags)
69 result.append(test)
70 def Template(name, source):
71 def MkTest(replacement, expectation):
72 testname = name
73 testsource = source
74 for key in replacement.keys():
75 testname = testname.replace("$" + key, replacement[key]);
76 testsource = testsource.replace("$" + key, replacement[key]);
77 Test(testname, testsource, expectation)
78 return MkTest
79 execfile(pathname, {"Test": Test, "Template": Template})
80
81 def ListTests(self, context):
82 expectations = self._GetExpectations()
83 result = []
84
85 # Find all .js files in this directory.
86 filenames = [f[:-3] for f in os.listdir(self.root) if f.endswith(".js")]
87 filenames.sort()
88 for f in filenames:
89 throws = expectations.get(f, None)
90 flags = [f + ".js"]
91 if throws:
92 flags += ["throws", throws]
93 test = testcase.TestCase(self, f, flags=flags)
94 result.append(test)
95
96 # Find all .pyt files in this directory.
97 filenames = [f[:-4] for f in os.listdir(self.root) if f.endswith(".pyt")]
98 filenames.sort()
99 for f in filenames:
100 self._ParsePythonTestTemplates(result, f)
101 return result
102
103 def GetFlagsForTestCase(self, testcase, context):
104 first = testcase.flags[0]
105 if first != "-e":
106 testcase.flags[0] = os.path.join(self.root, first)
107 return testcase.flags
108
109 def GetSourceForTest(self, testcase):
110 if testcase.flags[0] == "-e":
111 return testcase.flags[1]
112 with open(testcase.flags[0]) as f:
113 return f.read()
114
115 def VariantFlags(self):
116 return [[]];
117
118
119 def GetSuite(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): 35 class PreparserTestCase(test.TestCase):
132 36
133 def __init__(self, root, path, executable, mode, throws, context, source): 37 def __init__(self, root, path, executable, mode, throws, context, source):
134 super(PreparserTestCase, self).__init__(context, path, mode) 38 super(PreparserTestCase, self).__init__(context, path, mode)
135 self.executable = executable 39 self.executable = executable
136 self.root = root 40 self.root = root
137 self.throws = throws 41 self.throws = throws
138 self.source = source 42 self.source = source
139 43
140 def GetLabel(self): 44 def GetLabel(self):
141 return "%s %s %s" % (self.mode, self.path[-2], self.path[-1]) 45 return "%s %s %s" % (self.mode, self.path[-2], self.path[-1])
142 46
143 def GetName(self): 47 def GetName(self):
144 return self.path[-1] 48 return self.path[-1]
145 49
146 def HasSource(self): 50 def HasSource(self):
147 return self.source is not None 51 return self.source is not None
148 52
149 def GetSource(self): 53 def GetSource():
150 return self.source 54 return self.source
151 55
152 def BuildCommand(self, path): 56 def BuildCommand(self, path):
153 if (self.source is not None): 57 if (self.source is not None):
154 result = [self.executable, "-e", self.source] 58 result = [self.executable, "-e", self.source]
155 else: 59 else:
156 testfile = join(self.root, self.GetName()) + ".js" 60 testfile = join(self.root, self.GetName()) + ".js"
157 result = [self.executable, testfile] 61 result = [self.executable, testfile]
158 if (self.throws): 62 if (self.throws):
159 result += ['throws'] + self.throws 63 result += ['throws'] + self.throws
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 status_file = join(self.root, 'preparser.status') 155 status_file = join(self.root, 'preparser.status')
252 if exists(status_file): 156 if exists(status_file):
253 test.ReadConfigurationInto(status_file, sections, defs) 157 test.ReadConfigurationInto(status_file, sections, defs)
254 158
255 def VariantFlags(self): 159 def VariantFlags(self):
256 return [[]]; 160 return [[]];
257 161
258 162
259 def GetConfiguration(context, root): 163 def GetConfiguration(context, root):
260 return PreparserTestConfiguration(context, root) 164 return PreparserTestConfiguration(context, root)
OLDNEW
« no previous file with comments | « test/mozilla/testcfg.py ('k') | test/sputnik/testcfg.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698