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

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

Issue 1365293002: [test] Copy test262-es6 into test262. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Review Created 5 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
« no previous file with comments | « test/test262/test262.status ('k') | no next file » | 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 hashlib 29 import hashlib
30 import imp
30 import os 31 import os
31 import shutil 32 import shutil
32 import sys 33 import sys
33 import tarfile 34 import tarfile
34 35
36
37 from testrunner.local import statusfile
35 from testrunner.local import testsuite 38 from testrunner.local import testsuite
36 from testrunner.local import utils 39 from testrunner.local import utils
37 from testrunner.objects import testcase 40 from testrunner.objects import testcase
38 41
42 # The revision hash needs to be 7 characters?
43 TEST_262_ARCHIVE_REVISION = "6137f75" # This is the 2015-08-25 revision.
44 TEST_262_ARCHIVE_MD5 = "c1eaf890d46e73d6c7e05ab21f76e668"
45 TEST_262_URL = "https://github.com/tc39/test262/tarball/%s"
46 TEST_262_HARNESS_FILES = ["sta.js", "assert.js"]
39 47
40 TEST_262_ARCHIVE_REVISION = "fbba29f" # This is the r365 revision. 48 TEST_262_SUITE_PATH = ["data", "test"]
41 TEST_262_ARCHIVE_MD5 = "e1ff0db438cc12de8fb6da80621b4ef6" 49 TEST_262_HARNESS_PATH = ["data", "harness"]
42 TEST_262_URL = "https://github.com/tc39/test262/tarball/%s" 50 TEST_262_TOOLS_PATH = ["data", "tools", "packaging"]
43 TEST_262_HARNESS = ["sta.js", "testBuiltInObject.js", "testIntl.js"] 51
52 ALL_VARIANT_FLAGS_STRICT = dict(
53 (v, [flags + ["--use-strict"] for flags in flag_sets])
54 for v, flag_sets in testsuite.ALL_VARIANT_FLAGS.iteritems()
55 )
56
57 FAST_VARIANT_FLAGS_STRICT = dict(
58 (v, [flags + ["--use-strict"] for flags in flag_sets])
59 for v, flag_sets in testsuite.FAST_VARIANT_FLAGS.iteritems()
60 )
61
62 ALL_VARIANT_FLAGS_BOTH = dict(
63 (v, [flags for flags in testsuite.ALL_VARIANT_FLAGS[v] +
64 ALL_VARIANT_FLAGS_STRICT[v]])
65 for v in testsuite.ALL_VARIANT_FLAGS
66 )
67
68 FAST_VARIANT_FLAGS_BOTH = dict(
69 (v, [flags for flags in testsuite.FAST_VARIANT_FLAGS[v] +
70 FAST_VARIANT_FLAGS_STRICT[v]])
71 for v in testsuite.FAST_VARIANT_FLAGS
72 )
73
74 ALL_VARIANTS = {
75 'nostrict': testsuite.ALL_VARIANT_FLAGS,
76 'strict': ALL_VARIANT_FLAGS_STRICT,
77 'both': ALL_VARIANT_FLAGS_BOTH,
78 }
79
80 FAST_VARIANTS = {
81 'nostrict': testsuite.FAST_VARIANT_FLAGS,
82 'strict': FAST_VARIANT_FLAGS_STRICT,
83 'both': FAST_VARIANT_FLAGS_BOTH,
84 }
85
86 class Test262VariantGenerator(testsuite.VariantGenerator):
87 def GetFlagSets(self, testcase, variant):
88 if testcase.outcomes and statusfile.OnlyFastVariants(testcase.outcomes):
89 variant_flags = FAST_VARIANTS
90 else:
91 variant_flags = ALL_VARIANTS
92
93 test_record = self.suite.GetTestRecord(testcase)
94 if "noStrict" in test_record:
95 return variant_flags["nostrict"][variant]
96 if "onlyStrict" in test_record:
97 return variant_flags["strict"][variant]
98 return variant_flags["both"][variant]
44 99
45 100
46 class Test262TestSuite(testsuite.TestSuite): 101 class Test262TestSuite(testsuite.TestSuite):
47 102
48 def __init__(self, name, root): 103 def __init__(self, name, root):
49 super(Test262TestSuite, self).__init__(name, root) 104 super(Test262TestSuite, self).__init__(name, root)
50 self.testroot = os.path.join(root, "data", "test", "suite") 105 self.testroot = os.path.join(self.root, *TEST_262_SUITE_PATH)
51 self.harness = [os.path.join(self.root, "data", "test", "harness", f) 106 self.harnesspath = os.path.join(self.root, *TEST_262_HARNESS_PATH)
52 for f in TEST_262_HARNESS] 107 self.harness = [os.path.join(self.harnesspath, f)
108 for f in TEST_262_HARNESS_FILES]
53 self.harness += [os.path.join(self.root, "harness-adapt.js")] 109 self.harness += [os.path.join(self.root, "harness-adapt.js")]
54 110 self.ParseTestRecord = None
55 def CommonTestName(self, testcase):
56 return testcase.path.split(os.path.sep)[-1]
57 111
58 def ListTests(self, context): 112 def ListTests(self, context):
59 tests = [] 113 tests = []
60 for dirname, dirs, files in os.walk(self.testroot): 114 for dirname, dirs, files in os.walk(self.testroot):
61 for dotted in [x for x in dirs if x.startswith(".")]: 115 for dotted in [x for x in dirs if x.startswith(".")]:
62 dirs.remove(dotted) 116 dirs.remove(dotted)
63 if context.noi18n and "intl402" in dirs: 117 if context.noi18n and "intl402" in dirs:
64 dirs.remove("intl402") 118 dirs.remove("intl402")
65 dirs.sort() 119 dirs.sort()
66 files.sort() 120 files.sort()
67 for filename in files: 121 for filename in files:
68 if filename.endswith(".js"): 122 if filename.endswith(".js"):
69 fullpath = os.path.join(dirname, filename) 123 fullpath = os.path.join(dirname, filename)
70 relpath = fullpath[len(self.testroot) + 1 : -3] 124 relpath = fullpath[len(self.testroot) + 1 : -3]
71 testname = relpath.replace(os.path.sep, "/") 125 testname = relpath.replace(os.path.sep, "/")
72 case = testcase.TestCase(self, testname) 126 case = testcase.TestCase(self, testname)
73 tests.append(case) 127 tests.append(case)
74 return tests 128 return tests
75 129
76 def GetFlagsForTestCase(self, testcase, context): 130 def GetFlagsForTestCase(self, testcase, context):
77 return (testcase.flags + context.mode_flags + self.harness + 131 return (testcase.flags + context.mode_flags + self.harness +
132 self.GetIncludesForTest(testcase) + ["--harmony"] +
78 [os.path.join(self.testroot, testcase.path + ".js")]) 133 [os.path.join(self.testroot, testcase.path + ".js")])
79 134
135 def _VariantGeneratorFactory(self):
136 return Test262VariantGenerator
137
138 def LoadParseTestRecord(self):
139 if not self.ParseTestRecord:
140 root = os.path.join(self.root, *TEST_262_TOOLS_PATH)
141 f = None
142 try:
143 (f, pathname, description) = imp.find_module("parseTestRecord", [root])
144 module = imp.load_module("parseTestRecord", f, pathname, description)
145 self.ParseTestRecord = module.parseTestRecord
146 except:
147 raise ImportError("Cannot load parseTestRecord; you may need to "
148 "--download-data for test262")
149 finally:
150 if f:
151 f.close()
152 return self.ParseTestRecord
153
154 def GetTestRecord(self, testcase):
155 if not hasattr(testcase, "test_record"):
156 ParseTestRecord = self.LoadParseTestRecord()
157 testcase.test_record = ParseTestRecord(self.GetSourceForTest(testcase),
158 testcase.path)
159 return testcase.test_record
160
161 def GetIncludesForTest(self, testcase):
162 test_record = self.GetTestRecord(testcase)
163 if "includes" in test_record:
164 includes = [os.path.join(self.harnesspath, f)
165 for f in test_record["includes"]]
166 else:
167 includes = []
168 return includes
169
80 def GetSourceForTest(self, testcase): 170 def GetSourceForTest(self, testcase):
81 filename = os.path.join(self.testroot, testcase.path + ".js") 171 filename = os.path.join(self.testroot, testcase.path + ".js")
82 with open(filename) as f: 172 with open(filename) as f:
83 return f.read() 173 return f.read()
84 174
85 def IsNegativeTest(self, testcase): 175 def IsNegativeTest(self, testcase):
86 return "@negative" in self.GetSourceForTest(testcase) 176 test_record = self.GetTestRecord(testcase)
177 return "negative" in test_record
87 178
88 def IsFailureOutput(self, output, testpath): 179 def IsFailureOutput(self, output, testpath):
89 if output.exit_code != 0: 180 if output.exit_code != 0:
90 return True 181 return True
91 return "FAILED!" in output.stdout 182 return "FAILED!" in output.stdout
92 183
184 def HasUnexpectedOutput(self, testcase):
185 outcome = self.GetOutcome(testcase)
186 if (statusfile.FAIL_SLOPPY in testcase.outcomes and
187 "--use-strict" not in testcase.flags):
188 return outcome != statusfile.FAIL
189 return not outcome in (testcase.outcomes or [statusfile.PASS])
190
93 def DownloadData(self): 191 def DownloadData(self):
94 revision = TEST_262_ARCHIVE_REVISION 192 revision = TEST_262_ARCHIVE_REVISION
95 archive_url = TEST_262_URL % revision 193 archive_url = TEST_262_URL % revision
96 archive_name = os.path.join(self.root, "tc39-test262-%s.tar.gz" % revision) 194 archive_name = os.path.join(self.root, "tc39-test262-%s.tar.gz" % revision)
97 directory_name = os.path.join(self.root, "data") 195 directory_name = os.path.join(self.root, "data")
98 directory_old_name = os.path.join(self.root, "data.old") 196 directory_old_name = os.path.join(self.root, "data.old")
99 197
100 # Clobber if the test is in an outdated state, i.e. if there are any other 198 # Clobber if the test is in an outdated state, i.e. if there are any other
101 # archive files present. 199 # archive files present.
102 archive_files = [f for f in os.listdir(self.root) 200 archive_files = [f for f in os.listdir(self.root)
(...skipping 14 matching lines...) Expand all
117 if not os.path.exists(directory_name): 215 if not os.path.exists(directory_name):
118 print "Extracting test262-%s.tar.gz ..." % revision 216 print "Extracting test262-%s.tar.gz ..." % revision
119 md5 = hashlib.md5() 217 md5 = hashlib.md5()
120 with open(archive_name, "rb") as f: 218 with open(archive_name, "rb") as f:
121 for chunk in iter(lambda: f.read(8192), ""): 219 for chunk in iter(lambda: f.read(8192), ""):
122 md5.update(chunk) 220 md5.update(chunk)
123 print "MD5 hash is %s" % md5.hexdigest() 221 print "MD5 hash is %s" % md5.hexdigest()
124 if md5.hexdigest() != TEST_262_ARCHIVE_MD5: 222 if md5.hexdigest() != TEST_262_ARCHIVE_MD5:
125 os.remove(archive_name) 223 os.remove(archive_name)
126 print "MD5 expected %s" % TEST_262_ARCHIVE_MD5 224 print "MD5 expected %s" % TEST_262_ARCHIVE_MD5
127 raise Exception("Hash mismatch of test data file") 225 raise Exception("MD5 hash mismatch of test data file")
128 archive = tarfile.open(archive_name, "r:gz") 226 archive = tarfile.open(archive_name, "r:gz")
129 if sys.platform in ("win32", "cygwin"): 227 if sys.platform in ("win32", "cygwin"):
130 # Magic incantation to allow longer path names on Windows. 228 # Magic incantation to allow longer path names on Windows.
131 archive.extractall(u"\\\\?\\%s" % self.root) 229 archive.extractall(u"\\\\?\\%s" % self.root)
132 else: 230 else:
133 archive.extractall(self.root) 231 archive.extractall(self.root)
134 os.rename(os.path.join(self.root, "tc39-test262-%s" % revision), 232 os.rename(os.path.join(self.root, "tc39-test262-%s" % revision),
135 directory_name) 233 directory_name)
136 234
137 235
138 def GetSuite(name, root): 236 def GetSuite(name, root):
139 return Test262TestSuite(name, root) 237 return Test262TestSuite(name, root)
OLDNEW
« no previous file with comments | « test/test262/test262.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698