Chromium Code Reviews| 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 |
| 11 # with the distribution. | 11 # with the distribution. |
| 12 # * Neither the name of Google Inc. nor the names of its | 12 # * Neither the name of Google Inc. nor the names of its |
| 13 # contributors may be used to endorse or promote products derived | 13 # contributors may be used to endorse or promote products derived |
| 14 # from this software without specific prior written permission. | 14 # from this software without specific prior written permission. |
| 15 # | 15 # |
| 16 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 16 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 17 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 18 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 19 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 20 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 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 imp | 29 import imp |
| 30 import itertools | |
| 30 import os | 31 import os |
| 31 import re | 32 import re |
| 32 import sys | 33 import sys |
| 33 import tarfile | 34 import tarfile |
| 34 | 35 |
| 35 | 36 |
| 36 from testrunner.local import statusfile | 37 from testrunner.local import statusfile |
| 37 from testrunner.local import testsuite | 38 from testrunner.local import testsuite |
| 38 from testrunner.local import utils | 39 from testrunner.local import utils |
| 39 from testrunner.objects import testcase | 40 from testrunner.objects import testcase |
| 40 | 41 |
| 41 DATA = os.path.join(os.path.dirname(os.path.abspath(__file__)), "data") | 42 DATA = os.path.join(os.path.dirname(os.path.abspath(__file__)), "data") |
| 42 ARCHIVE = DATA + ".tar" | 43 ARCHIVE = DATA + ".tar" |
| 43 | 44 |
| 44 TEST_262_HARNESS_FILES = ["sta.js", "assert.js"] | 45 TEST_262_HARNESS_FILES = ["sta.js", "assert.js"] |
| 45 TEST_262_NATIVE_FILES = ["detachArrayBuffer.js"] | 46 TEST_262_NATIVE_FILES = ["detachArrayBuffer.js"] |
| 46 | 47 |
| 47 TEST_262_SUITE_PATH = ["data", "test"] | 48 TEST_262_SUITE_PATH = ["data", "test"] |
| 48 TEST_262_HARNESS_PATH = ["data", "harness"] | 49 TEST_262_HARNESS_PATH = ["data", "harness"] |
| 49 TEST_262_TOOLS_PATH = ["harness", "src"] | 50 TEST_262_TOOLS_PATH = ["harness", "src"] |
| 51 TEST_262_LOCAL_TESTS_PATH = ["local-tests", "test"] | |
| 50 | 52 |
| 51 sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), | 53 sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), |
| 52 *TEST_262_TOOLS_PATH)) | 54 *TEST_262_TOOLS_PATH)) |
| 53 | 55 |
| 54 ALL_VARIANT_FLAGS_STRICT = dict( | 56 ALL_VARIANT_FLAGS_STRICT = dict( |
| 55 (v, [flags + ["--use-strict"] for flags in flag_sets]) | 57 (v, [flags + ["--use-strict"] for flags in flag_sets]) |
| 56 for v, flag_sets in testsuite.ALL_VARIANT_FLAGS.iteritems() | 58 for v, flag_sets in testsuite.ALL_VARIANT_FLAGS.iteritems() |
| 57 ) | 59 ) |
| 58 | 60 |
| 59 FAST_VARIANT_FLAGS_STRICT = dict( | 61 FAST_VARIANT_FLAGS_STRICT = dict( |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 94 | 96 |
| 95 test_record = self.suite.GetTestRecord(testcase) | 97 test_record = self.suite.GetTestRecord(testcase) |
| 96 if "noStrict" in test_record: | 98 if "noStrict" in test_record: |
| 97 return variant_flags["nostrict"][variant] | 99 return variant_flags["nostrict"][variant] |
| 98 if "onlyStrict" in test_record: | 100 if "onlyStrict" in test_record: |
| 99 return variant_flags["strict"][variant] | 101 return variant_flags["strict"][variant] |
| 100 return variant_flags["both"][variant] | 102 return variant_flags["both"][variant] |
| 101 | 103 |
| 102 | 104 |
| 103 class Test262TestSuite(testsuite.TestSuite): | 105 class Test262TestSuite(testsuite.TestSuite): |
| 106 # Match the (...) in '/path/to/v8/test/test262/subdir/test/(...).js' | |
| 107 # In practice, subdir is data or local-tests | |
| 108 RELPATH_REGEXP = re.compile( | |
|
Michael Achenbach
2017/01/06 09:26:02
nit: Maybe move it even more top-level, right next
Dan Ehrenberg
2017/01/06 09:58:10
Done.
| |
| 109 r'.*[\\/]test[\\/]test262[\\/][^\\/]+[\\/]test[\\/](.*)\.js') | |
| 104 | 110 |
| 105 def __init__(self, name, root): | 111 def __init__(self, name, root): |
| 106 super(Test262TestSuite, self).__init__(name, root) | 112 super(Test262TestSuite, self).__init__(name, root) |
| 107 self.testroot = os.path.join(self.root, *TEST_262_SUITE_PATH) | 113 self.testroot = os.path.join(self.root, *TEST_262_SUITE_PATH) |
| 108 self.harnesspath = os.path.join(self.root, *TEST_262_HARNESS_PATH) | 114 self.harnesspath = os.path.join(self.root, *TEST_262_HARNESS_PATH) |
| 109 self.harness = [os.path.join(self.harnesspath, f) | 115 self.harness = [os.path.join(self.harnesspath, f) |
| 110 for f in TEST_262_HARNESS_FILES] | 116 for f in TEST_262_HARNESS_FILES] |
| 111 self.harness += [os.path.join(self.root, "harness-adapt.js")] | 117 self.harness += [os.path.join(self.root, "harness-adapt.js")] |
| 118 self.localtestroot = os.path.join(self.root, *TEST_262_LOCAL_TESTS_PATH) | |
| 112 self.ParseTestRecord = None | 119 self.ParseTestRecord = None |
| 113 | 120 |
| 114 def ListTests(self, context): | 121 def ListTests(self, context): |
| 115 tests = [] | 122 tests = [] |
| 116 for dirname, dirs, files in os.walk(self.testroot): | 123 testnames = set() |
| 124 for dirname, dirs, files in itertools.chain(os.walk(self.testroot), | |
| 125 os.walk(self.localtestroot)): | |
| 117 for dotted in [x for x in dirs if x.startswith(".")]: | 126 for dotted in [x for x in dirs if x.startswith(".")]: |
| 118 dirs.remove(dotted) | 127 dirs.remove(dotted) |
| 119 if context.noi18n and "intl402" in dirs: | 128 if context.noi18n and "intl402" in dirs: |
| 120 dirs.remove("intl402") | 129 dirs.remove("intl402") |
| 121 dirs.sort() | 130 dirs.sort() |
| 122 files.sort() | 131 files.sort() |
| 123 for filename in files: | 132 for filename in files: |
| 124 if filename.endswith(".js") and not filename.endswith("_FIXTURE.js"): | 133 if not filename.endswith(".js"): |
| 125 fullpath = os.path.join(dirname, filename) | 134 continue |
| 126 relpath = fullpath[len(self.testroot) + 1 : -3] | 135 if filename.endswith("_FIXTURE.js"): |
| 127 testname = relpath.replace(os.path.sep, "/") | 136 continue |
| 128 case = testcase.TestCase(self, testname) | 137 fullpath = os.path.join(dirname, filename) |
| 129 tests.append(case) | 138 relpath = re.match(Test262TestSuite.RELPATH_REGEXP, fullpath).group(1) |
| 130 return tests | 139 testnames.add(relpath.replace(os.path.sep, "/")) |
| 140 return [testcase.TestCase(self, testname) for testname in testnames] | |
| 131 | 141 |
| 132 def GetFlagsForTestCase(self, testcase, context): | 142 def GetFlagsForTestCase(self, testcase, context): |
| 133 return (testcase.flags + context.mode_flags + self.harness + | 143 return (testcase.flags + context.mode_flags + self.harness + |
| 134 self.GetIncludesForTest(testcase) + ["--harmony"] + | 144 self.GetIncludesForTest(testcase) + ["--harmony"] + |
| 135 (["--module"] if "module" in self.GetTestRecord(testcase) else []) + | 145 (["--module"] if "module" in self.GetTestRecord(testcase) else []) + |
| 136 [os.path.join(self.testroot, testcase.path + ".js")] + | 146 [self.GetPathForTest(testcase)] + |
| 137 (["--throws"] if "negative" in self.GetTestRecord(testcase) | 147 (["--throws"] if "negative" in self.GetTestRecord(testcase) |
| 138 else []) + | 148 else []) + |
| 139 (["--allow-natives-syntax"] | 149 (["--allow-natives-syntax"] |
| 140 if "detachArrayBuffer.js" in | 150 if "detachArrayBuffer.js" in |
| 141 self.GetTestRecord(testcase).get("includes", []) | 151 self.GetTestRecord(testcase).get("includes", []) |
| 142 else [])) | 152 else [])) |
| 143 | 153 |
| 144 def _VariantGeneratorFactory(self): | 154 def _VariantGeneratorFactory(self): |
| 145 return Test262VariantGenerator | 155 return Test262VariantGenerator |
| 146 | 156 |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 172 | 182 |
| 173 def GetIncludesForTest(self, testcase): | 183 def GetIncludesForTest(self, testcase): |
| 174 test_record = self.GetTestRecord(testcase) | 184 test_record = self.GetTestRecord(testcase) |
| 175 if "includes" in test_record: | 185 if "includes" in test_record: |
| 176 return [os.path.join(self.BasePath(filename), filename) | 186 return [os.path.join(self.BasePath(filename), filename) |
| 177 for filename in test_record.get("includes", [])] | 187 for filename in test_record.get("includes", [])] |
| 178 else: | 188 else: |
| 179 includes = [] | 189 includes = [] |
| 180 return includes | 190 return includes |
| 181 | 191 |
| 192 def GetPathForTest(self, testcase): | |
| 193 filename = os.path.join(self.localtestroot, testcase.path + ".js") | |
| 194 if not os.path.exists(filename): | |
| 195 filename = os.path.join(self.testroot, testcase.path + ".js") | |
| 196 return filename | |
| 197 | |
| 182 def GetSourceForTest(self, testcase): | 198 def GetSourceForTest(self, testcase): |
| 183 filename = os.path.join(self.testroot, testcase.path + ".js") | 199 with open(self.GetPathForTest(testcase)) as f: |
| 184 with open(filename) as f: | |
| 185 return f.read() | 200 return f.read() |
| 186 | 201 |
| 187 def _ParseException(self, str): | 202 def _ParseException(self, str): |
| 188 # somefile:somelinenumber: someerror[: sometext] | 203 # somefile:somelinenumber: someerror[: sometext] |
| 189 match = re.search('^[^: ]*:[0-9]+: ([^ ]+?)($|: )', str, re.MULTILINE) | 204 match = re.search('^[^: ]*:[0-9]+: ([^ ]+?)($|: )', str, re.MULTILINE) |
| 190 return match.group(1) | 205 return match.group(1) |
| 191 | 206 |
| 192 def IsFailureOutput(self, testcase): | 207 def IsFailureOutput(self, testcase): |
| 193 output = testcase.output | 208 output = testcase.output |
| 194 test_record = self.GetTestRecord(testcase) | 209 test_record = self.GetTestRecord(testcase) |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 212 # data folder. | 227 # data folder. |
| 213 if os.path.exists(ARCHIVE) and not os.path.exists(DATA): | 228 if os.path.exists(ARCHIVE) and not os.path.exists(DATA): |
| 214 print "Extracting archive..." | 229 print "Extracting archive..." |
| 215 tar = tarfile.open(ARCHIVE) | 230 tar = tarfile.open(ARCHIVE) |
| 216 tar.extractall(path=os.path.dirname(ARCHIVE)) | 231 tar.extractall(path=os.path.dirname(ARCHIVE)) |
| 217 tar.close() | 232 tar.close() |
| 218 | 233 |
| 219 | 234 |
| 220 def GetSuite(name, root): | 235 def GetSuite(name, root): |
| 221 return Test262TestSuite(name, root) | 236 return Test262TestSuite(name, root) |
| OLD | NEW |