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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 102 | 104 |
| 103 class Test262TestSuite(testsuite.TestSuite): | 105 class Test262TestSuite(testsuite.TestSuite): |
| 104 | 106 |
| 105 def __init__(self, name, root): | 107 def __init__(self, name, root): |
| 106 super(Test262TestSuite, self).__init__(name, root) | 108 super(Test262TestSuite, self).__init__(name, root) |
| 107 self.testroot = os.path.join(self.root, *TEST_262_SUITE_PATH) | 109 self.testroot = os.path.join(self.root, *TEST_262_SUITE_PATH) |
| 108 self.harnesspath = os.path.join(self.root, *TEST_262_HARNESS_PATH) | 110 self.harnesspath = os.path.join(self.root, *TEST_262_HARNESS_PATH) |
| 109 self.harness = [os.path.join(self.harnesspath, f) | 111 self.harness = [os.path.join(self.harnesspath, f) |
| 110 for f in TEST_262_HARNESS_FILES] | 112 for f in TEST_262_HARNESS_FILES] |
| 111 self.harness += [os.path.join(self.root, "harness-adapt.js")] | 113 self.harness += [os.path.join(self.root, "harness-adapt.js")] |
| 114 self.localtestroot = os.path.join(self.root, *TEST_262_LOCAL_TESTS_PATH) | |
| 112 self.ParseTestRecord = None | 115 self.ParseTestRecord = None |
| 113 | 116 |
| 114 def ListTests(self, context): | 117 def ListTests(self, context): |
| 115 tests = [] | 118 tests = [] |
| 116 for dirname, dirs, files in os.walk(self.testroot): | 119 for dirname, dirs, files in itertools.chain(os.walk(self.testroot), |
| 120 os.walk(self.localtestroot)): | |
| 117 for dotted in [x for x in dirs if x.startswith(".")]: | 121 for dotted in [x for x in dirs if x.startswith(".")]: |
| 118 dirs.remove(dotted) | 122 dirs.remove(dotted) |
| 119 if context.noi18n and "intl402" in dirs: | 123 if context.noi18n and "intl402" in dirs: |
| 120 dirs.remove("intl402") | 124 dirs.remove("intl402") |
| 121 dirs.sort() | 125 dirs.sort() |
| 122 files.sort() | 126 files.sort() |
| 123 for filename in files: | 127 for filename in files: |
| 124 if filename.endswith(".js") and not filename.endswith("_FIXTURE.js"): | 128 if not filename.endswith(".js"): |
| 125 fullpath = os.path.join(dirname, filename) | 129 continue |
| 126 relpath = fullpath[len(self.testroot) + 1 : -3] | 130 if filename.endswith("_FIXTURE.js"): |
| 127 testname = relpath.replace(os.path.sep, "/") | 131 continue |
| 128 case = testcase.TestCase(self, testname) | 132 fullpath = os.path.join(dirname, filename) |
| 129 tests.append(case) | 133 # Match the (...) in '/path/to/v8/test/test262/subdir/test/(...).js' |
|
Michael Achenbach
2017/01/05 14:06:32
Just to clarify: subdir is one of data,local-tests
Dan Ehrenberg
2017/01/05 16:24:16
Right, added this in a comment.
| |
| 134 relpath = re.match( | |
| 135 r'.*[\\/]test[\\/]test262[\\/][^\\/]+[\\/]test[\\/](.*)\.js', | |
|
Michael Achenbach
2017/01/05 14:06:32
Maybe keep the regexp in a toplevel constant for r
Dan Ehrenberg
2017/01/05 16:24:16
Done.
| |
| 136 fullpath).group(1) | |
| 137 # Defer to local-tests if there is a matching test of the same name | |
| 138 if dirname.startswith(self.testroot) and \ | |
|
Michael Achenbach
2017/01/05 14:06:32
nit: Rather use () around the whole condition inst
Dan Ehrenberg
2017/01/05 16:24:16
This code no longer exists.
| |
| 139 os.path.exists(os.path.join(self.localtestroot, relpath+'.js')): | |
|
Michael Achenbach
2017/01/05 14:06:32
nit: spaces around +
or how about adding the .js
Michael Achenbach
2017/01/05 14:06:32
Do these "exists" checks give a measurable slowdow
Dan Ehrenberg
2017/01/05 16:24:16
This doesn't either.
Dan Ehrenberg
2017/01/05 16:24:16
Turns out all we actually have to do is prune dupl
Michael Achenbach
2017/01/06 09:26:02
Yes, much nicer! The exists check is already encap
| |
| 140 continue | |
| 141 testname = relpath.replace(os.path.sep, "/") | |
| 142 case = testcase.TestCase(self, testname) | |
| 143 tests.append(case) | |
| 130 return tests | 144 return tests |
| 131 | 145 |
| 132 def GetFlagsForTestCase(self, testcase, context): | 146 def GetFlagsForTestCase(self, testcase, context): |
| 133 return (testcase.flags + context.mode_flags + self.harness + | 147 return (testcase.flags + context.mode_flags + self.harness + |
| 134 self.GetIncludesForTest(testcase) + ["--harmony"] + | 148 self.GetIncludesForTest(testcase) + ["--harmony"] + |
| 135 (["--module"] if "module" in self.GetTestRecord(testcase) else []) + | 149 (["--module"] if "module" in self.GetTestRecord(testcase) else []) + |
| 136 [os.path.join(self.testroot, testcase.path + ".js")] + | 150 [self.GetPathForTest(testcase)] + |
| 137 (["--throws"] if "negative" in self.GetTestRecord(testcase) | 151 (["--throws"] if "negative" in self.GetTestRecord(testcase) |
| 138 else []) + | 152 else []) + |
| 139 (["--allow-natives-syntax"] | 153 (["--allow-natives-syntax"] |
| 140 if "detachArrayBuffer.js" in | 154 if "detachArrayBuffer.js" in |
| 141 self.GetTestRecord(testcase).get("includes", []) | 155 self.GetTestRecord(testcase).get("includes", []) |
| 142 else [])) | 156 else [])) |
| 143 | 157 |
| 144 def _VariantGeneratorFactory(self): | 158 def _VariantGeneratorFactory(self): |
| 145 return Test262VariantGenerator | 159 return Test262VariantGenerator |
| 146 | 160 |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 172 | 186 |
| 173 def GetIncludesForTest(self, testcase): | 187 def GetIncludesForTest(self, testcase): |
| 174 test_record = self.GetTestRecord(testcase) | 188 test_record = self.GetTestRecord(testcase) |
| 175 if "includes" in test_record: | 189 if "includes" in test_record: |
| 176 return [os.path.join(self.BasePath(filename), filename) | 190 return [os.path.join(self.BasePath(filename), filename) |
| 177 for filename in test_record.get("includes", [])] | 191 for filename in test_record.get("includes", [])] |
| 178 else: | 192 else: |
| 179 includes = [] | 193 includes = [] |
| 180 return includes | 194 return includes |
| 181 | 195 |
| 196 def GetPathForTest(self, testcase): | |
| 197 filename = os.path.join(self.localtestroot, testcase.path + ".js") | |
| 198 if not os.path.exists(filename): | |
| 199 filename = os.path.join(self.testroot, testcase.path + ".js") | |
| 200 return filename | |
| 201 | |
| 182 def GetSourceForTest(self, testcase): | 202 def GetSourceForTest(self, testcase): |
| 183 filename = os.path.join(self.testroot, testcase.path + ".js") | 203 with open(self.GetPathForTest(testcase)) as f: |
|
Michael Achenbach
2017/01/05 14:06:32
This seemed to have worked because python seems to
Dan Ehrenberg
2017/01/05 16:24:16
I'll venture a guess that this is because Windows
| |
| 184 with open(filename) as f: | |
| 185 return f.read() | 204 return f.read() |
| 186 | 205 |
| 187 def _ParseException(self, str): | 206 def _ParseException(self, str): |
| 188 # somefile:somelinenumber: someerror[: sometext] | 207 # somefile:somelinenumber: someerror[: sometext] |
| 189 match = re.search('^[^: ]*:[0-9]+: ([^ ]+?)($|: )', str, re.MULTILINE) | 208 match = re.search('^[^: ]*:[0-9]+: ([^ ]+?)($|: )', str, re.MULTILINE) |
| 190 return match.group(1) | 209 return match.group(1) |
| 191 | 210 |
| 192 def IsFailureOutput(self, testcase): | 211 def IsFailureOutput(self, testcase): |
| 193 output = testcase.output | 212 output = testcase.output |
| 194 test_record = self.GetTestRecord(testcase) | 213 test_record = self.GetTestRecord(testcase) |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 212 # data folder. | 231 # data folder. |
| 213 if os.path.exists(ARCHIVE) and not os.path.exists(DATA): | 232 if os.path.exists(ARCHIVE) and not os.path.exists(DATA): |
| 214 print "Extracting archive..." | 233 print "Extracting archive..." |
| 215 tar = tarfile.open(ARCHIVE) | 234 tar = tarfile.open(ARCHIVE) |
| 216 tar.extractall(path=os.path.dirname(ARCHIVE)) | 235 tar.extractall(path=os.path.dirname(ARCHIVE)) |
| 217 tar.close() | 236 tar.close() |
| 218 | 237 |
| 219 | 238 |
| 220 def GetSuite(name, root): | 239 def GetSuite(name, root): |
| 221 return Test262TestSuite(name, root) | 240 return Test262TestSuite(name, root) |
| OLD | NEW |