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 collections | |
29 import hashlib | 30 import hashlib |
30 import os | 31 import os |
31 import shutil | 32 import shutil |
32 import sys | 33 import sys |
33 import tarfile | 34 import tarfile |
34 import imp | 35 import imp |
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 |
39 from testrunner.local.testsuite import FilterVariants | |
38 from testrunner.local import utils | 40 from testrunner.local import utils |
39 from testrunner.objects import testcase | 41 from testrunner.objects import testcase |
40 | 42 |
41 # The revision hash needs to be 7 characters? | 43 # The revision hash needs to be 7 characters? |
42 TEST_262_ARCHIVE_REVISION = "c6ac390" # This is the 2015-07-06 revision. | 44 TEST_262_ARCHIVE_REVISION = "c6ac390" # This is the 2015-07-06 revision. |
43 TEST_262_ARCHIVE_MD5 = "e1393ef330f38e9cb1bfa4e3eada5ba8" | 45 TEST_262_ARCHIVE_MD5 = "e1393ef330f38e9cb1bfa4e3eada5ba8" |
44 TEST_262_URL = "https://github.com/tc39/test262/tarball/%s" | 46 TEST_262_URL = "https://github.com/tc39/test262/tarball/%s" |
45 TEST_262_HARNESS_FILES = ["sta.js", "assert.js"] | 47 TEST_262_HARNESS_FILES = ["sta.js", "assert.js"] |
46 | 48 |
47 TEST_262_SUITE_PATH = ["data", "test"] | 49 TEST_262_SUITE_PATH = ["data", "test"] |
48 TEST_262_HARNESS_PATH = ["data", "harness"] | 50 TEST_262_HARNESS_PATH = ["data", "harness"] |
49 TEST_262_TOOLS_PATH = ["data", "tools", "packaging"] | 51 TEST_262_TOOLS_PATH = ["data", "tools", "packaging"] |
50 | 52 |
53 STRICT_VARIANTS = [ | |
54 (v, flags + ["--use-strict"]) | |
55 for (v, flags) in testsuite.ALL_VARIANTS | |
56 ] | |
57 | |
58 STRICT_FAST_VARIANTS = [ | |
59 (v, flags + ["--use-strict"]) | |
60 for (v, flags) in testsuite.FAST_VARIANTS | |
61 ] | |
62 | |
63 STRICT_DEFAULT_VARIANT = [ | |
64 (v, flags + ["--use-strict"]) | |
65 for (v, flags) in testsuite.DEFAULT_VARIANT | |
66 ] | |
67 | |
68 class Test262VariantFlagsBuilder(testsuite.VariantFlagsBuilder): | |
69 def __init__(self, suite, variant_filter): | |
70 super(Test262VariantFlagsBuilder, self).__init__(suite, variant_filter) | |
71 all_strict = FilterVariants(STRICT_VARIANTS, variant_filter) | |
72 fast_strict = FilterVariants(STRICT_FAST_VARIANTS, variant_filter) | |
73 default_strict = FilterVariants(STRICT_DEFAULT_VARIANT, variant_filter) | |
74 | |
Michael Achenbach
2015/07/27 12:37:46
This precomputes the variants, so that on iteratio
| |
75 Variants = collections.namedtuple( | |
76 'Variants', ['nostrict', 'strict', 'both']) | |
77 self.default = Variants( | |
78 self.default_variant, | |
79 default_strict, | |
80 self.default_variant + default_strict, | |
81 ) | |
82 self.fast = Variants( | |
83 self.fast_variants, | |
84 fast_strict, | |
85 self.fast_variants + fast_strict, | |
86 ) | |
87 self.all = Variants( | |
88 self.all_variants, | |
89 all_strict, | |
90 self.all_variants + all_strict, | |
91 ) | |
92 | |
93 def _Variant(self, testcase, variants): | |
94 test_record = self.suite.GetTestRecord(testcase) | |
95 if "noStrict" in test_record: | |
96 return variants.nostrict | |
97 if "onlyStrict" in test_record: | |
98 return variants.strict | |
99 return variants.both | |
Michael Achenbach
2015/07/27 12:37:45
Minor drawback: In the both-case, also after this
| |
100 | |
101 def DefaultVariant(self, testcase): | |
102 return self._Variant(testcase, self.default) | |
103 | |
104 def FastVariants(self, testcase): | |
105 return self._Variant(testcase, self.fast) | |
106 | |
107 def AllVariants(self, testcase): | |
108 return self._Variant(testcase, self.all) | |
109 | |
110 | |
51 class Test262TestSuite(testsuite.TestSuite): | 111 class Test262TestSuite(testsuite.TestSuite): |
52 | 112 |
53 def __init__(self, name, root): | 113 def __init__(self, name, root): |
54 super(Test262TestSuite, self).__init__(name, root) | 114 super(Test262TestSuite, self).__init__(name, root) |
55 self.testroot = os.path.join(self.root, *TEST_262_SUITE_PATH) | 115 self.testroot = os.path.join(self.root, *TEST_262_SUITE_PATH) |
56 self.harnesspath = os.path.join(self.root, *TEST_262_HARNESS_PATH) | 116 self.harnesspath = os.path.join(self.root, *TEST_262_HARNESS_PATH) |
57 self.harness = [os.path.join(self.harnesspath, f) | 117 self.harness = [os.path.join(self.harnesspath, f) |
58 for f in TEST_262_HARNESS_FILES] | 118 for f in TEST_262_HARNESS_FILES] |
59 self.harness += [os.path.join(self.root, "harness-adapt.js")] | 119 self.harness += [os.path.join(self.root, "harness-adapt.js")] |
60 self.ParseTestRecord = None | 120 self.ParseTestRecord = None |
(...skipping 13 matching lines...) Expand all Loading... | |
74 filename[:-3]) | 134 filename[:-3]) |
75 case = testcase.TestCase(self, testname) | 135 case = testcase.TestCase(self, testname) |
76 tests.append(case) | 136 tests.append(case) |
77 return tests | 137 return tests |
78 | 138 |
79 def GetFlagsForTestCase(self, testcase, context): | 139 def GetFlagsForTestCase(self, testcase, context): |
80 return (testcase.flags + context.mode_flags + self.harness + | 140 return (testcase.flags + context.mode_flags + self.harness + |
81 self.GetIncludesForTest(testcase) + ["--harmony"] + | 141 self.GetIncludesForTest(testcase) + ["--harmony"] + |
82 [os.path.join(self.testroot, testcase.path + ".js")]) | 142 [os.path.join(self.testroot, testcase.path + ".js")]) |
83 | 143 |
84 def VariantFlags(self, testcase, default_flags): | 144 def VariantFlagsBuilder(self): |
85 flags = super(Test262TestSuite, self).VariantFlags(testcase, default_flags) | 145 return Test262VariantFlagsBuilder |
86 test_record = self.GetTestRecord(testcase) | |
87 if "noStrict" in test_record: | |
88 return flags | |
89 strict_flags = [f + ["--use-strict"] for f in flags] | |
90 if "onlyStrict" in test_record: | |
91 return strict_flags | |
92 return flags + strict_flags | |
93 | 146 |
94 def LoadParseTestRecord(self): | 147 def LoadParseTestRecord(self): |
95 if not self.ParseTestRecord: | 148 if not self.ParseTestRecord: |
96 root = os.path.join(self.root, *TEST_262_TOOLS_PATH) | 149 root = os.path.join(self.root, *TEST_262_TOOLS_PATH) |
97 f = None | 150 f = None |
98 try: | 151 try: |
99 (f, pathname, description) = imp.find_module("parseTestRecord", [root]) | 152 (f, pathname, description) = imp.find_module("parseTestRecord", [root]) |
100 module = imp.load_module("parseTestRecord", f, pathname, description) | 153 module = imp.load_module("parseTestRecord", f, pathname, description) |
101 self.ParseTestRecord = module.parseTestRecord | 154 self.ParseTestRecord = module.parseTestRecord |
102 except: | 155 except: |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
184 # Magic incantation to allow longer path names on Windows. | 237 # Magic incantation to allow longer path names on Windows. |
185 archive.extractall(u"\\\\?\\%s" % self.root) | 238 archive.extractall(u"\\\\?\\%s" % self.root) |
186 else: | 239 else: |
187 archive.extractall(self.root) | 240 archive.extractall(self.root) |
188 os.rename(os.path.join(self.root, "tc39-test262-%s" % revision), | 241 os.rename(os.path.join(self.root, "tc39-test262-%s" % revision), |
189 directory_name) | 242 directory_name) |
190 | 243 |
191 | 244 |
192 def GetSuite(name, root): | 245 def GetSuite(name, root): |
193 return Test262TestSuite(name, root) | 246 return Test262TestSuite(name, root) |
OLD | NEW |