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_PYTHON_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_PYTHON_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 finally: | |
94 if f: | |
95 f.close() | |
96 if not self.ParseTestRecord: | |
97 raise Error("Cannot load parseTestRecord; you may need to --download-data for test262") | |
Jakob Kummerow
2014/08/19 11:32:55
The only way this can happen is when there was an
smikes
2014/08/19 15:22:54
Done.
| |
98 return self.ParseTestRecord | |
99 | |
100 def GetTestRecord(self, testcase): | |
101 ParseTestRecord = self.LoadParseTestRecord() | |
Jakob Kummerow
2014/08/19 11:32:55
Let's move this into the if-block where it's neede
smikes
2014/08/19 15:22:54
Done.
| |
102 if not hasattr(testcase, "test_record"): | |
103 testcase.test_record = ParseTestRecord(self.GetSourceForTest(testcase), | |
104 testcase.path) | |
105 return testcase.test_record | |
106 | |
107 def GetIncludesForTest(self, testcase): | |
108 test_record = self.GetTestRecord(testcase) | |
109 if "includes" in test_record: | |
110 includes = [os.path.join(self.harnesspath, f) | |
111 for f in test_record["includes"]] | |
Jakob Kummerow
2014/08/19 11:32:55
nit: please adjust indentation here
smikes
2014/08/19 15:22:54
Done.
| |
112 else: | |
113 includes = [] | |
114 return includes | |
115 | |
79 def GetSourceForTest(self, testcase): | 116 def GetSourceForTest(self, testcase): |
80 filename = os.path.join(self.testroot, testcase.path + ".js") | 117 filename = os.path.join(self.testroot, testcase.path + ".js") |
81 with open(filename) as f: | 118 with open(filename) as f: |
82 return f.read() | 119 return f.read() |
83 | 120 |
84 def IsNegativeTest(self, testcase): | 121 def IsNegativeTest(self, testcase): |
85 return "@negative" in self.GetSourceForTest(testcase) | 122 test_record = self.GetTestRecord(testcase) |
123 return "negative" in test_record | |
86 | 124 |
87 def IsFailureOutput(self, output, testpath): | 125 def IsFailureOutput(self, output, testpath): |
88 if output.exit_code != 0: | 126 if output.exit_code != 0: |
89 return True | 127 return True |
90 return "FAILED!" in output.stdout | 128 return "FAILED!" in output.stdout |
91 | 129 |
92 def DownloadData(self): | 130 def DownloadData(self): |
93 revision = TEST_262_ARCHIVE_REVISION | 131 revision = TEST_262_ARCHIVE_REVISION |
94 archive_url = TEST_262_URL % revision | 132 archive_url = TEST_262_URL % revision |
95 archive_name = os.path.join(self.root, "tc39-test262-%s.tar.gz" % revision) | 133 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. | 154 # Magic incantation to allow longer path names on Windows. |
117 archive.extractall(u"\\\\?\\%s" % self.root) | 155 archive.extractall(u"\\\\?\\%s" % self.root) |
118 else: | 156 else: |
119 archive.extractall(self.root) | 157 archive.extractall(self.root) |
120 os.rename(os.path.join(self.root, "tc39-test262-%s" % revision), | 158 os.rename(os.path.join(self.root, "tc39-test262-%s" % revision), |
121 directory_name) | 159 directory_name) |
122 | 160 |
123 | 161 |
124 def GetSuite(name, root): | 162 def GetSuite(name, root): |
125 return Test262TestSuite(name, root) | 163 return Test262TestSuite(name, root) |
OLD | NEW |