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

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

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