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

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