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

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

Issue 2611793002: [test] Process to locally develop and upstream test262 tests (Closed)
Patch Set: Cleanup nit Created 3 years, 11 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
« no previous file with comments | « test/test262/test262.status ('k') | test/test262/upstream-local-tests.sh » ('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 2012 the V8 project authors. All rights reserved. 1 # Copyright 2012 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
29 import imp 29 import imp
30 import itertools
30 import os 31 import os
31 import re 32 import re
32 import sys 33 import sys
33 import tarfile 34 import tarfile
34 35
35 36
36 from testrunner.local import statusfile 37 from testrunner.local import statusfile
37 from testrunner.local import testsuite 38 from testrunner.local import testsuite
38 from testrunner.local import utils 39 from testrunner.local import utils
39 from testrunner.objects import testcase 40 from testrunner.objects import testcase
40 41
41 DATA = os.path.join(os.path.dirname(os.path.abspath(__file__)), "data") 42 DATA = os.path.join(os.path.dirname(os.path.abspath(__file__)), "data")
42 ARCHIVE = DATA + ".tar" 43 ARCHIVE = DATA + ".tar"
43 44
44 TEST_262_HARNESS_FILES = ["sta.js", "assert.js"] 45 TEST_262_HARNESS_FILES = ["sta.js", "assert.js"]
45 TEST_262_NATIVE_FILES = ["detachArrayBuffer.js"] 46 TEST_262_NATIVE_FILES = ["detachArrayBuffer.js"]
46 47
47 TEST_262_SUITE_PATH = ["data", "test"] 48 TEST_262_SUITE_PATH = ["data", "test"]
48 TEST_262_HARNESS_PATH = ["data", "harness"] 49 TEST_262_HARNESS_PATH = ["data", "harness"]
49 TEST_262_TOOLS_PATH = ["harness", "src"] 50 TEST_262_TOOLS_PATH = ["harness", "src"]
51 TEST_262_LOCAL_TESTS_PATH = ["local-tests", "test"]
52
53 TEST_262_RELPATH_REGEXP = re.compile(
54 r'.*[\\/]test[\\/]test262[\\/][^\\/]+[\\/]test[\\/](.*)\.js')
50 55
51 sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), 56 sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)),
52 *TEST_262_TOOLS_PATH)) 57 *TEST_262_TOOLS_PATH))
53 58
54 ALL_VARIANT_FLAGS_STRICT = dict( 59 ALL_VARIANT_FLAGS_STRICT = dict(
55 (v, [flags + ["--use-strict"] for flags in flag_sets]) 60 (v, [flags + ["--use-strict"] for flags in flag_sets])
56 for v, flag_sets in testsuite.ALL_VARIANT_FLAGS.iteritems() 61 for v, flag_sets in testsuite.ALL_VARIANT_FLAGS.iteritems()
57 ) 62 )
58 63
59 FAST_VARIANT_FLAGS_STRICT = dict( 64 FAST_VARIANT_FLAGS_STRICT = dict(
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 99
95 test_record = self.suite.GetTestRecord(testcase) 100 test_record = self.suite.GetTestRecord(testcase)
96 if "noStrict" in test_record: 101 if "noStrict" in test_record:
97 return variant_flags["nostrict"][variant] 102 return variant_flags["nostrict"][variant]
98 if "onlyStrict" in test_record: 103 if "onlyStrict" in test_record:
99 return variant_flags["strict"][variant] 104 return variant_flags["strict"][variant]
100 return variant_flags["both"][variant] 105 return variant_flags["both"][variant]
101 106
102 107
103 class Test262TestSuite(testsuite.TestSuite): 108 class Test262TestSuite(testsuite.TestSuite):
109 # Match the (...) in '/path/to/v8/test/test262/subdir/test/(...).js'
110 # In practice, subdir is data or local-tests
104 111
105 def __init__(self, name, root): 112 def __init__(self, name, root):
106 super(Test262TestSuite, self).__init__(name, root) 113 super(Test262TestSuite, self).__init__(name, root)
107 self.testroot = os.path.join(self.root, *TEST_262_SUITE_PATH) 114 self.testroot = os.path.join(self.root, *TEST_262_SUITE_PATH)
108 self.harnesspath = os.path.join(self.root, *TEST_262_HARNESS_PATH) 115 self.harnesspath = os.path.join(self.root, *TEST_262_HARNESS_PATH)
109 self.harness = [os.path.join(self.harnesspath, f) 116 self.harness = [os.path.join(self.harnesspath, f)
110 for f in TEST_262_HARNESS_FILES] 117 for f in TEST_262_HARNESS_FILES]
111 self.harness += [os.path.join(self.root, "harness-adapt.js")] 118 self.harness += [os.path.join(self.root, "harness-adapt.js")]
119 self.localtestroot = os.path.join(self.root, *TEST_262_LOCAL_TESTS_PATH)
112 self.ParseTestRecord = None 120 self.ParseTestRecord = None
113 121
114 def ListTests(self, context): 122 def ListTests(self, context):
115 tests = [] 123 tests = []
116 for dirname, dirs, files in os.walk(self.testroot): 124 testnames = set()
125 for dirname, dirs, files in itertools.chain(os.walk(self.testroot),
126 os.walk(self.localtestroot)):
117 for dotted in [x for x in dirs if x.startswith(".")]: 127 for dotted in [x for x in dirs if x.startswith(".")]:
118 dirs.remove(dotted) 128 dirs.remove(dotted)
119 if context.noi18n and "intl402" in dirs: 129 if context.noi18n and "intl402" in dirs:
120 dirs.remove("intl402") 130 dirs.remove("intl402")
121 dirs.sort() 131 dirs.sort()
122 files.sort() 132 files.sort()
123 for filename in files: 133 for filename in files:
124 if filename.endswith(".js") and not filename.endswith("_FIXTURE.js"): 134 if not filename.endswith(".js"):
125 fullpath = os.path.join(dirname, filename) 135 continue
126 relpath = fullpath[len(self.testroot) + 1 : -3] 136 if filename.endswith("_FIXTURE.js"):
127 testname = relpath.replace(os.path.sep, "/") 137 continue
128 case = testcase.TestCase(self, testname) 138 fullpath = os.path.join(dirname, filename)
129 tests.append(case) 139 relpath = re.match(TEST_262_RELPATH_REGEXP, fullpath).group(1)
130 return tests 140 testnames.add(relpath.replace(os.path.sep, "/"))
141 return [testcase.TestCase(self, testname) for testname in testnames]
131 142
132 def GetFlagsForTestCase(self, testcase, context): 143 def GetFlagsForTestCase(self, testcase, context):
133 return (testcase.flags + context.mode_flags + self.harness + 144 return (testcase.flags + context.mode_flags + self.harness +
134 self.GetIncludesForTest(testcase) + ["--harmony"] + 145 self.GetIncludesForTest(testcase) + ["--harmony"] +
135 (["--module"] if "module" in self.GetTestRecord(testcase) else []) + 146 (["--module"] if "module" in self.GetTestRecord(testcase) else []) +
136 [os.path.join(self.testroot, testcase.path + ".js")] + 147 [self.GetPathForTest(testcase)] +
137 (["--throws"] if "negative" in self.GetTestRecord(testcase) 148 (["--throws"] if "negative" in self.GetTestRecord(testcase)
138 else []) + 149 else []) +
139 (["--allow-natives-syntax"] 150 (["--allow-natives-syntax"]
140 if "detachArrayBuffer.js" in 151 if "detachArrayBuffer.js" in
141 self.GetTestRecord(testcase).get("includes", []) 152 self.GetTestRecord(testcase).get("includes", [])
142 else [])) 153 else []))
143 154
144 def _VariantGeneratorFactory(self): 155 def _VariantGeneratorFactory(self):
145 return Test262VariantGenerator 156 return Test262VariantGenerator
146 157
(...skipping 25 matching lines...) Expand all
172 183
173 def GetIncludesForTest(self, testcase): 184 def GetIncludesForTest(self, testcase):
174 test_record = self.GetTestRecord(testcase) 185 test_record = self.GetTestRecord(testcase)
175 if "includes" in test_record: 186 if "includes" in test_record:
176 return [os.path.join(self.BasePath(filename), filename) 187 return [os.path.join(self.BasePath(filename), filename)
177 for filename in test_record.get("includes", [])] 188 for filename in test_record.get("includes", [])]
178 else: 189 else:
179 includes = [] 190 includes = []
180 return includes 191 return includes
181 192
193 def GetPathForTest(self, testcase):
194 filename = os.path.join(self.localtestroot, testcase.path + ".js")
195 if not os.path.exists(filename):
196 filename = os.path.join(self.testroot, testcase.path + ".js")
197 return filename
198
182 def GetSourceForTest(self, testcase): 199 def GetSourceForTest(self, testcase):
183 filename = os.path.join(self.testroot, testcase.path + ".js") 200 with open(self.GetPathForTest(testcase)) as f:
184 with open(filename) as f:
185 return f.read() 201 return f.read()
186 202
187 def _ParseException(self, str): 203 def _ParseException(self, str):
188 # somefile:somelinenumber: someerror[: sometext] 204 # somefile:somelinenumber: someerror[: sometext]
189 match = re.search('^[^: ]*:[0-9]+: ([^ ]+?)($|: )', str, re.MULTILINE) 205 match = re.search('^[^: ]*:[0-9]+: ([^ ]+?)($|: )', str, re.MULTILINE)
190 return match.group(1) 206 return match.group(1)
191 207
192 def IsFailureOutput(self, testcase): 208 def IsFailureOutput(self, testcase):
193 output = testcase.output 209 output = testcase.output
194 test_record = self.GetTestRecord(testcase) 210 test_record = self.GetTestRecord(testcase)
(...skipping 17 matching lines...) Expand all
212 # data folder. 228 # data folder.
213 if os.path.exists(ARCHIVE) and not os.path.exists(DATA): 229 if os.path.exists(ARCHIVE) and not os.path.exists(DATA):
214 print "Extracting archive..." 230 print "Extracting archive..."
215 tar = tarfile.open(ARCHIVE) 231 tar = tarfile.open(ARCHIVE)
216 tar.extractall(path=os.path.dirname(ARCHIVE)) 232 tar.extractall(path=os.path.dirname(ARCHIVE))
217 tar.close() 233 tar.close()
218 234
219 235
220 def GetSuite(name, root): 236 def GetSuite(name, root):
221 return Test262TestSuite(name, root) 237 return Test262TestSuite(name, root)
OLDNEW
« no previous file with comments | « test/test262/test262.status ('k') | test/test262/upstream-local-tests.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698