OLD | NEW |
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 Loading... |
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 |
35 from testrunner.local import testsuite | 36 from testrunner.local import testsuite |
36 from testrunner.local import utils | 37 from testrunner.local import utils |
37 from testrunner.objects import testcase | 38 from testrunner.objects import testcase |
38 | 39 |
| 40 TEST_262_ARCHIVE_REVISION = "595a36b" # This is the 2014-Aug-10 revision. |
| 41 TEST_262_ARCHIVE_MD5 = "89dfc8458f474cdb7e8e178f3215dd06" |
| 42 TEST_262_URL = "https://github.com/tc39/test262/tarball/%s" |
| 43 TEST_262_HARNESS_FILES = ["sta.js"] |
39 | 44 |
40 TEST_262_ARCHIVE_REVISION = "fbba29f" # This is the r365 revision. | 45 TEST_262_SUITE_PATH = ["data", "test", "suite"] |
41 TEST_262_ARCHIVE_MD5 = "e1ff0db438cc12de8fb6da80621b4ef6" | 46 TEST_262_HARNESS_PATH = ["data", "test", "harness"] |
42 TEST_262_URL = "https://github.com/tc39/test262/tarball/%s" | 47 TEST_262_TOOLS_PATH = ["data", "tools", "packaging"] |
43 TEST_262_HARNESS = ["sta.js", "testBuiltInObject.js", "testIntl.js"] | |
44 | |
45 | 48 |
46 class Test262TestSuite(testsuite.TestSuite): | 49 class Test262TestSuite(testsuite.TestSuite): |
47 | 50 |
48 def __init__(self, name, root): | 51 def __init__(self, name, root): |
49 super(Test262TestSuite, self).__init__(name, root) | 52 super(Test262TestSuite, self).__init__(name, root) |
50 self.testroot = os.path.join(root, "data", "test", "suite") | 53 self.testroot = os.path.join(self.root, *TEST_262_SUITE_PATH) |
51 self.harness = [os.path.join(self.root, "data", "test", "harness", f) | 54 self.harnesspath = os.path.join(self.root, *TEST_262_HARNESS_PATH) |
52 for f in TEST_262_HARNESS] | 55 self.harness = [os.path.join(self.harnesspath, f) |
| 56 for f in TEST_262_HARNESS_FILES] |
53 self.harness += [os.path.join(self.root, "harness-adapt.js")] | 57 self.harness += [os.path.join(self.root, "harness-adapt.js")] |
| 58 self.ParseTestRecord = None |
54 | 59 |
55 def CommonTestName(self, testcase): | 60 def CommonTestName(self, testcase): |
56 return testcase.path.split(os.path.sep)[-1] | 61 return testcase.path.split(os.path.sep)[-1] |
57 | 62 |
58 def ListTests(self, context): | 63 def ListTests(self, context): |
59 tests = [] | 64 tests = [] |
60 for dirname, dirs, files in os.walk(self.testroot): | 65 for dirname, dirs, files in os.walk(self.testroot): |
61 for dotted in [x for x in dirs if x.startswith(".")]: | 66 for dotted in [x for x in dirs if x.startswith(".")]: |
62 dirs.remove(dotted) | 67 dirs.remove(dotted) |
63 if context.noi18n and "intl402" in dirs: | 68 if context.noi18n and "intl402" in dirs: |
64 dirs.remove("intl402") | 69 dirs.remove("intl402") |
65 dirs.sort() | 70 dirs.sort() |
66 files.sort() | 71 files.sort() |
67 for filename in files: | 72 for filename in files: |
68 if filename.endswith(".js"): | 73 if filename.endswith(".js"): |
69 testname = os.path.join(dirname[len(self.testroot) + 1:], | 74 testname = os.path.join(dirname[len(self.testroot) + 1:], |
70 filename[:-3]) | 75 filename[:-3]) |
71 case = testcase.TestCase(self, testname) | 76 case = testcase.TestCase(self, testname) |
72 tests.append(case) | 77 tests.append(case) |
73 return tests | 78 return tests |
74 | 79 |
75 def GetFlagsForTestCase(self, testcase, context): | 80 def GetFlagsForTestCase(self, testcase, context): |
76 return (testcase.flags + context.mode_flags + self.harness + | 81 return (testcase.flags + context.mode_flags + self.harness + |
| 82 self.GetIncludesForTest(testcase) + |
77 [os.path.join(self.testroot, testcase.path + ".js")]) | 83 [os.path.join(self.testroot, testcase.path + ".js")]) |
78 | 84 |
| 85 def LoadParseTestRecord(self): |
| 86 if not self.ParseTestRecord: |
| 87 root = os.path.join(self.root, *TEST_262_TOOLS_PATH) |
| 88 f = None |
| 89 try: |
| 90 (f, pathname, description) = imp.find_module("parseTestRecord", [root]) |
| 91 module = imp.load_module("parseTestRecord", f, pathname, description) |
| 92 self.ParseTestRecord = module.parseTestRecord |
| 93 except: |
| 94 raise ImportError("Cannot load parseTestRecord; you may need to " |
| 95 "--download-data for test262") |
| 96 finally: |
| 97 if f: |
| 98 f.close() |
| 99 return self.ParseTestRecord |
| 100 |
| 101 def GetTestRecord(self, testcase): |
| 102 if not hasattr(testcase, "test_record"): |
| 103 ParseTestRecord = self.LoadParseTestRecord() |
| 104 testcase.test_record = ParseTestRecord(self.GetSourceForTest(testcase), |
| 105 testcase.path) |
| 106 return testcase.test_record |
| 107 |
| 108 def GetIncludesForTest(self, testcase): |
| 109 test_record = self.GetTestRecord(testcase) |
| 110 if "includes" in test_record: |
| 111 includes = [os.path.join(self.harnesspath, f) |
| 112 for f in test_record["includes"]] |
| 113 else: |
| 114 includes = [] |
| 115 return includes |
| 116 |
79 def GetSourceForTest(self, testcase): | 117 def GetSourceForTest(self, testcase): |
80 filename = os.path.join(self.testroot, testcase.path + ".js") | 118 filename = os.path.join(self.testroot, testcase.path + ".js") |
81 with open(filename) as f: | 119 with open(filename) as f: |
82 return f.read() | 120 return f.read() |
83 | 121 |
84 def IsNegativeTest(self, testcase): | 122 def IsNegativeTest(self, testcase): |
85 return "@negative" in self.GetSourceForTest(testcase) | 123 test_record = self.GetTestRecord(testcase) |
| 124 return "negative" in test_record |
86 | 125 |
87 def IsFailureOutput(self, output, testpath): | 126 def IsFailureOutput(self, output, testpath): |
88 if output.exit_code != 0: | 127 if output.exit_code != 0: |
89 return True | 128 return True |
90 return "FAILED!" in output.stdout | 129 return "FAILED!" in output.stdout |
91 | 130 |
92 def DownloadData(self): | 131 def DownloadData(self): |
93 revision = TEST_262_ARCHIVE_REVISION | 132 revision = TEST_262_ARCHIVE_REVISION |
94 archive_url = TEST_262_URL % revision | 133 archive_url = TEST_262_URL % revision |
95 archive_name = os.path.join(self.root, "tc39-test262-%s.tar.gz" % revision) | 134 archive_name = os.path.join(self.root, "tc39-test262-%s.tar.gz" % revision) |
(...skipping 20 matching lines...) Expand all Loading... |
116 # Magic incantation to allow longer path names on Windows. | 155 # Magic incantation to allow longer path names on Windows. |
117 archive.extractall(u"\\\\?\\%s" % self.root) | 156 archive.extractall(u"\\\\?\\%s" % self.root) |
118 else: | 157 else: |
119 archive.extractall(self.root) | 158 archive.extractall(self.root) |
120 os.rename(os.path.join(self.root, "tc39-test262-%s" % revision), | 159 os.rename(os.path.join(self.root, "tc39-test262-%s" % revision), |
121 directory_name) | 160 directory_name) |
122 | 161 |
123 | 162 |
124 def GetSuite(name, root): | 163 def GetSuite(name, root): |
125 return Test262TestSuite(name, root) | 164 return Test262TestSuite(name, root) |
OLD | NEW |