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

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

Issue 1215303008: [test] Move test262-es6 into test262. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase 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
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 = "488c0a7" # This is the 2015-06-11 revision.
43 TEST_262_ARCHIVE_MD5 = "f7d4ec9be81f1e1f10fd8a61c71baead"
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"]
44
45 50
46 class Test262TestSuite(testsuite.TestSuite): 51 class Test262TestSuite(testsuite.TestSuite):
47 52
48 def __init__(self, name, root): 53 def __init__(self, name, root):
49 super(Test262TestSuite, self).__init__(name, root) 54 super(Test262TestSuite, self).__init__(name, root)
50 self.testroot = os.path.join(root, "data", "test", "suite") 55 self.testroot = os.path.join(self.root, *TEST_262_SUITE_PATH)
51 self.harness = [os.path.join(self.root, "data", "test", "harness", f) 56 self.harnesspath = os.path.join(self.root, *TEST_262_HARNESS_PATH)
52 for f in TEST_262_HARNESS] 57 self.harness = [os.path.join(self.harnesspath, f)
58 for f in TEST_262_HARNESS_FILES]
53 self.harness += [os.path.join(self.root, "harness-adapt.js")] 59 self.harness += [os.path.join(self.root, "harness-adapt.js")]
54 60 self.ParseTestRecord = None
55 def CommonTestName(self, testcase):
56 return testcase.path.split(os.path.sep)[-1]
57 61
58 def ListTests(self, context): 62 def ListTests(self, context):
59 tests = [] 63 tests = []
60 for dirname, dirs, files in os.walk(self.testroot): 64 for dirname, dirs, files in os.walk(self.testroot):
61 for dotted in [x for x in dirs if x.startswith(".")]: 65 for dotted in [x for x in dirs if x.startswith(".")]:
62 dirs.remove(dotted) 66 dirs.remove(dotted)
63 if context.noi18n and "intl402" in dirs: 67 if context.noi18n and "intl402" in dirs:
64 dirs.remove("intl402") 68 dirs.remove("intl402")
65 dirs.sort() 69 dirs.sort()
66 files.sort() 70 files.sort()
67 for filename in files: 71 for filename in files:
68 if filename.endswith(".js"): 72 if filename.endswith(".js"):
69 testname = os.path.join(dirname[len(self.testroot) + 1:], 73 testname = os.path.join(dirname[len(self.testroot) + 1:],
70 filename[:-3]) 74 filename[:-3])
71 case = testcase.TestCase(self, testname) 75 case = testcase.TestCase(self, testname)
72 tests.append(case) 76 tests.append(case)
73 return tests 77 return tests
74 78
75 def GetFlagsForTestCase(self, testcase, context): 79 def GetFlagsForTestCase(self, testcase, context):
76 return (testcase.flags + context.mode_flags + self.harness + 80 return (testcase.flags + context.mode_flags + self.harness +
81 self.GetIncludesForTest(testcase) + ["--harmony"] +
77 [os.path.join(self.testroot, testcase.path + ".js")]) 82 [os.path.join(self.testroot, testcase.path + ".js")])
78 83
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
79 def GetSourceForTest(self, testcase): 126 def GetSourceForTest(self, testcase):
80 filename = os.path.join(self.testroot, testcase.path + ".js") 127 filename = os.path.join(self.testroot, testcase.path + ".js")
81 with open(filename) as f: 128 with open(filename) as f:
82 return f.read() 129 return f.read()
83 130
84 def IsNegativeTest(self, testcase): 131 def IsNegativeTest(self, testcase):
85 return "@negative" in self.GetSourceForTest(testcase) 132 test_record = self.GetTestRecord(testcase)
133 return "negative" in test_record
86 134
87 def IsFailureOutput(self, output, testpath): 135 def IsFailureOutput(self, output, testpath):
88 if output.exit_code != 0: 136 if output.exit_code != 0:
89 return True 137 return True
90 return "FAILED!" in output.stdout 138 return "FAILED!" in output.stdout
91 139
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
92 def DownloadData(self): 147 def DownloadData(self):
93 revision = TEST_262_ARCHIVE_REVISION 148 revision = TEST_262_ARCHIVE_REVISION
94 archive_url = TEST_262_URL % revision 149 archive_url = TEST_262_URL % revision
95 archive_name = os.path.join(self.root, "tc39-test262-%s.tar.gz" % revision) 150 archive_name = os.path.join(self.root, "tc39-test262-%s.tar.gz" % revision)
96 directory_name = os.path.join(self.root, "data") 151 directory_name = os.path.join(self.root, "data")
97 directory_old_name = os.path.join(self.root, "data.old") 152 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
98 if not os.path.exists(archive_name): 164 if not os.path.exists(archive_name):
99 print "Downloading test data from %s ..." % archive_url 165 print "Downloading test data from %s ..." % archive_url
100 utils.URLRetrieve(archive_url, archive_name) 166 utils.URLRetrieve(archive_url, archive_name)
101 if os.path.exists(directory_name): 167 if os.path.exists(directory_name):
102 if os.path.exists(directory_old_name): 168 if os.path.exists(directory_old_name):
103 shutil.rmtree(directory_old_name) 169 shutil.rmtree(directory_old_name)
104 os.rename(directory_name, directory_old_name) 170 os.rename(directory_name, directory_old_name)
105 if not os.path.exists(directory_name): 171 if not os.path.exists(directory_name):
106 print "Extracting test262-%s.tar.gz ..." % revision 172 print "Extracting test262-%s.tar.gz ..." % revision
107 md5 = hashlib.md5() 173 md5 = hashlib.md5()
108 with open(archive_name, "rb") as f: 174 with open(archive_name, "rb") as f:
109 for chunk in iter(lambda: f.read(8192), ""): 175 for chunk in iter(lambda: f.read(8192), ""):
110 md5.update(chunk) 176 md5.update(chunk)
177 print "MD5 hash is %s" % md5.hexdigest()
111 if md5.hexdigest() != TEST_262_ARCHIVE_MD5: 178 if md5.hexdigest() != TEST_262_ARCHIVE_MD5:
112 os.remove(archive_name) 179 os.remove(archive_name)
113 raise Exception("Hash mismatch of test data file") 180 print "MD5 expected %s" % TEST_262_ARCHIVE_MD5
181 raise Exception("MD5 hash mismatch of test data file")
114 archive = tarfile.open(archive_name, "r:gz") 182 archive = tarfile.open(archive_name, "r:gz")
115 if sys.platform in ("win32", "cygwin"): 183 if sys.platform in ("win32", "cygwin"):
116 # Magic incantation to allow longer path names on Windows. 184 # Magic incantation to allow longer path names on Windows.
117 archive.extractall(u"\\\\?\\%s" % self.root) 185 archive.extractall(u"\\\\?\\%s" % self.root)
118 else: 186 else:
119 archive.extractall(self.root) 187 archive.extractall(self.root)
120 os.rename(os.path.join(self.root, "tc39-test262-%s" % revision), 188 os.rename(os.path.join(self.root, "tc39-test262-%s" % revision),
121 directory_name) 189 directory_name)
122 190
123 191
124 def GetSuite(name, root): 192 def GetSuite(name, root):
125 return Test262TestSuite(name, root) 193 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