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 15 matching lines...) Expand all Loading... | |
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 imp | 30 import imp |
31 import os | 31 import os |
32 import shutil | 32 import shutil |
33 import sys | 33 import sys |
34 import tarfile | 34 import tarfile |
35 | 35 |
36 # add parent dir to search path | |
37 sys.path.append(os.path.dirname(os.path.abspath(__file__))) | |
38 | |
39 try: | |
40 from harness import parseTestRecord | |
41 except: | |
42 raise ImportError("Cannot load parseTestRecord; you may need to " | |
adamk
2016/06/22 21:54:07
Not sure this is worthwhile. If I patch in this ch
Dan Ehrenberg
2016/06/22 21:56:38
Good point; removed this.
| |
43 "gclient sync for test262") | |
36 | 44 |
37 from testrunner.local import statusfile | 45 from testrunner.local import statusfile |
38 from testrunner.local import testsuite | 46 from testrunner.local import testsuite |
39 from testrunner.local import utils | 47 from testrunner.local import utils |
40 from testrunner.objects import testcase | 48 from testrunner.objects import testcase |
41 | 49 |
42 DATA = os.path.join(os.path.dirname(os.path.abspath(__file__)), "data") | 50 DATA = os.path.join(os.path.dirname(os.path.abspath(__file__)), "data") |
43 ARCHIVE = DATA + ".tar" | 51 ARCHIVE = DATA + ".tar" |
44 | 52 |
45 TEST_262_HARNESS_FILES = ["sta.js", "assert.js"] | 53 TEST_262_HARNESS_FILES = ["sta.js", "assert.js"] |
46 TEST_262_NATIVE_FILES = ["detachArrayBuffer.js"] | 54 TEST_262_NATIVE_FILES = ["detachArrayBuffer.js"] |
47 | 55 |
48 TEST_262_SUITE_PATH = ["data", "test"] | 56 TEST_262_SUITE_PATH = ["data", "test"] |
49 TEST_262_HARNESS_PATH = ["data", "harness"] | 57 TEST_262_INCLUDES_PATH = ["data", "harness"] |
50 TEST_262_TOOLS_PATH = ["data", "tools", "packaging"] | |
51 | 58 |
52 ALL_VARIANT_FLAGS_STRICT = dict( | 59 ALL_VARIANT_FLAGS_STRICT = dict( |
53 (v, [flags + ["--use-strict"] for flags in flag_sets]) | 60 (v, [flags + ["--use-strict"] for flags in flag_sets]) |
54 for v, flag_sets in testsuite.ALL_VARIANT_FLAGS.iteritems() | 61 for v, flag_sets in testsuite.ALL_VARIANT_FLAGS.iteritems() |
55 ) | 62 ) |
56 | 63 |
57 FAST_VARIANT_FLAGS_STRICT = dict( | 64 FAST_VARIANT_FLAGS_STRICT = dict( |
58 (v, [flags + ["--use-strict"] for flags in flag_sets]) | 65 (v, [flags + ["--use-strict"] for flags in flag_sets]) |
59 for v, flag_sets in testsuite.FAST_VARIANT_FLAGS.iteritems() | 66 for v, flag_sets in testsuite.FAST_VARIANT_FLAGS.iteritems() |
60 ) | 67 ) |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
96 if "onlyStrict" in test_record: | 103 if "onlyStrict" in test_record: |
97 return variant_flags["strict"][variant] | 104 return variant_flags["strict"][variant] |
98 return variant_flags["both"][variant] | 105 return variant_flags["both"][variant] |
99 | 106 |
100 | 107 |
101 class Test262TestSuite(testsuite.TestSuite): | 108 class Test262TestSuite(testsuite.TestSuite): |
102 | 109 |
103 def __init__(self, name, root): | 110 def __init__(self, name, root): |
104 super(Test262TestSuite, self).__init__(name, root) | 111 super(Test262TestSuite, self).__init__(name, root) |
105 self.testroot = os.path.join(self.root, *TEST_262_SUITE_PATH) | 112 self.testroot = os.path.join(self.root, *TEST_262_SUITE_PATH) |
106 self.harnesspath = os.path.join(self.root, *TEST_262_HARNESS_PATH) | 113 self.harnesspath = os.path.join(self.root, *TEST_262_INCLUDES_PATH) |
107 self.harness = [os.path.join(self.harnesspath, f) | 114 self.harness = [os.path.join(self.harnesspath, f) |
108 for f in TEST_262_HARNESS_FILES] | 115 for f in TEST_262_HARNESS_FILES] |
109 self.harness += [os.path.join(self.root, "harness-adapt.js")] | 116 self.harness += [os.path.join(self.root, "harness-adapt.js")] |
110 self.ParseTestRecord = None | |
111 | 117 |
112 def ListTests(self, context): | 118 def ListTests(self, context): |
113 tests = [] | 119 tests = [] |
114 for dirname, dirs, files in os.walk(self.testroot): | 120 for dirname, dirs, files in os.walk(self.testroot): |
115 for dotted in [x for x in dirs if x.startswith(".")]: | 121 for dotted in [x for x in dirs if x.startswith(".")]: |
116 dirs.remove(dotted) | 122 dirs.remove(dotted) |
117 if context.noi18n and "intl402" in dirs: | 123 if context.noi18n and "intl402" in dirs: |
118 dirs.remove("intl402") | 124 dirs.remove("intl402") |
119 dirs.sort() | 125 dirs.sort() |
120 files.sort() | 126 files.sort() |
121 for filename in files: | 127 for filename in files: |
122 if filename.endswith(".js"): | 128 # _FIXTURE files are just to be imported by modules, not direct tests |
129 if filename.endswith(".js") and not filename.endswith("_FIXTURE.js"): | |
123 fullpath = os.path.join(dirname, filename) | 130 fullpath = os.path.join(dirname, filename) |
124 relpath = fullpath[len(self.testroot) + 1 : -3] | 131 relpath = fullpath[len(self.testroot) + 1 : -3] |
125 testname = relpath.replace(os.path.sep, "/") | 132 testname = relpath.replace(os.path.sep, "/") |
126 case = testcase.TestCase(self, testname) | 133 case = testcase.TestCase(self, testname) |
127 tests.append(case) | 134 tests.append(case) |
128 return tests | 135 return tests |
129 | 136 |
130 def GetFlagsForTestCase(self, testcase, context): | 137 def GetFlagsForTestCase(self, testcase, context): |
131 return (testcase.flags + context.mode_flags + self.harness + | 138 return (testcase.flags + context.mode_flags + self.harness + |
132 self.GetIncludesForTest(testcase) + ["--harmony"] + | 139 self.GetIncludesForTest(testcase) + ["--harmony"] + |
133 (["--module"] if "module" in self.GetTestRecord(testcase) else []) + | 140 (["--module"] if "module" in self.GetTestRecord(testcase) else []) + |
134 [os.path.join(self.testroot, testcase.path + ".js")] + | 141 [os.path.join(self.testroot, testcase.path + ".js")] + |
135 (["--throws"] if "negative" in self.GetTestRecord(testcase) | 142 (["--throws"] if "negative" in self.GetTestRecord(testcase) |
136 else []) + | 143 else []) + |
137 (["--allow-natives-syntax"] | 144 (["--allow-natives-syntax"] |
138 if "detachArrayBuffer.js" in | 145 if "detachArrayBuffer.js" in |
139 self.GetTestRecord(testcase).get("includes", []) | 146 self.GetTestRecord(testcase).get("includes", []) |
140 else [])) | 147 else [])) |
141 | 148 |
142 def _VariantGeneratorFactory(self): | 149 def _VariantGeneratorFactory(self): |
143 return Test262VariantGenerator | 150 return Test262VariantGenerator |
144 | 151 |
145 def LoadParseTestRecord(self): | |
146 if not self.ParseTestRecord: | |
147 root = os.path.join(self.root, *TEST_262_TOOLS_PATH) | |
148 f = None | |
149 try: | |
150 (f, pathname, description) = imp.find_module("parseTestRecord", [root]) | |
151 module = imp.load_module("parseTestRecord", f, pathname, description) | |
152 self.ParseTestRecord = module.parseTestRecord | |
153 except: | |
154 raise ImportError("Cannot load parseTestRecord; you may need to " | |
155 "gclient sync for test262") | |
156 finally: | |
157 if f: | |
158 f.close() | |
159 return self.ParseTestRecord | |
160 | 152 |
161 def GetTestRecord(self, testcase): | 153 def GetTestRecord(self, testcase): |
162 if not hasattr(testcase, "test_record"): | 154 if not hasattr(testcase, "test_record"): |
163 ParseTestRecord = self.LoadParseTestRecord() | 155 testcase.test_record = parseTestRecord(self.GetSourceForTest(testcase), |
164 testcase.test_record = ParseTestRecord(self.GetSourceForTest(testcase), | |
165 testcase.path) | 156 testcase.path) |
166 return testcase.test_record | 157 return testcase.test_record |
167 | 158 |
168 def BasePath(self, filename): | 159 def BasePath(self, filename): |
169 return self.root if filename in TEST_262_NATIVE_FILES else self.harnesspath | 160 return self.root if filename in TEST_262_NATIVE_FILES else self.harnesspath |
170 | 161 |
171 def GetIncludesForTest(self, testcase): | 162 def GetIncludesForTest(self, testcase): |
172 test_record = self.GetTestRecord(testcase) | 163 test_record = self.GetTestRecord(testcase) |
173 if "includes" in test_record: | 164 if "includes" in test_record: |
174 return [os.path.join(self.BasePath(filename), filename) | 165 return [os.path.join(self.BasePath(filename), filename) |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
224 # data folder. | 215 # data folder. |
225 if os.path.exists(ARCHIVE) and not os.path.exists(DATA): | 216 if os.path.exists(ARCHIVE) and not os.path.exists(DATA): |
226 print "Extracting archive..." | 217 print "Extracting archive..." |
227 tar = tarfile.open(ARCHIVE) | 218 tar = tarfile.open(ARCHIVE) |
228 tar.extractall(path=os.path.dirname(ARCHIVE)) | 219 tar.extractall(path=os.path.dirname(ARCHIVE)) |
229 tar.close() | 220 tar.close() |
230 | 221 |
231 | 222 |
232 def GetSuite(name, root): | 223 def GetSuite(name, root): |
233 return Test262TestSuite(name, root) | 224 return Test262TestSuite(name, root) |
OLD | NEW |