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 |
| (...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 | |
| 37 from testrunner.local import statusfile | 36 from testrunner.local import statusfile |
| 38 from testrunner.local import testsuite | 37 from testrunner.local import testsuite |
| 39 from testrunner.local import utils | 38 from testrunner.local import utils |
| 40 from testrunner.objects import testcase | 39 from testrunner.objects import testcase |
| 41 | 40 |
| 42 DATA = os.path.join(os.path.dirname(os.path.abspath(__file__)), "data") | 41 DATA = os.path.join(os.path.dirname(os.path.abspath(__file__)), "data") |
| 43 ARCHIVE = DATA + ".tar" | 42 HARNESS = os.path.join(os.path.dirname(os.path.abspath(__file__)), "harness") |
| 43 | |
| 44 # add parent dir to search path to get the harness files | |
| 45 sys.path.append(os.path.dirname(os.path.abspath(__file__))) | |
| 46 # In --donwload-data mode, HARNESS may be added later; import if present | |
| 47 if os.path.exists(HARNESS): | |
| 48 from harness import parseTestRecord | |
|
tandrii(chromium)
2016/07/20 10:42:01
IMO, the previous version of lazy import is much b
| |
| 49 | |
| 50 DATA_ARCHIVE = DATA + ".tar" | |
| 51 HARNESS_ARCHIVE = HARNESS + ".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() |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 135 (["--throws"] if "negative" in self.GetTestRecord(testcase) | 141 (["--throws"] if "negative" in self.GetTestRecord(testcase) |
| 136 else []) + | 142 else []) + |
| 137 (["--allow-natives-syntax"] | 143 (["--allow-natives-syntax"] |
| 138 if "detachArrayBuffer.js" in | 144 if "detachArrayBuffer.js" in |
| 139 self.GetTestRecord(testcase).get("includes", []) | 145 self.GetTestRecord(testcase).get("includes", []) |
| 140 else [])) | 146 else [])) |
| 141 | 147 |
| 142 def _VariantGeneratorFactory(self): | 148 def _VariantGeneratorFactory(self): |
| 143 return Test262VariantGenerator | 149 return Test262VariantGenerator |
| 144 | 150 |
| 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") | |
|
tandrii(chromium)
2016/07/20 10:42:01
I would keep user friendly "ImportError", unless y
Michael Achenbach
2016/07/20 11:22:49
You could also just move this code to toplevel at
| |
| 156 finally: | |
| 157 if f: | |
| 158 f.close() | |
| 159 return self.ParseTestRecord | |
| 160 | 151 |
| 161 def GetTestRecord(self, testcase): | 152 def GetTestRecord(self, testcase): |
| 162 if not hasattr(testcase, "test_record"): | 153 if not hasattr(testcase, "test_record"): |
| 163 ParseTestRecord = self.LoadParseTestRecord() | 154 testcase.test_record = parseTestRecord(self.GetSourceForTest(testcase), |
| 164 testcase.test_record = ParseTestRecord(self.GetSourceForTest(testcase), | |
| 165 testcase.path) | 155 testcase.path) |
| 166 return testcase.test_record | 156 return testcase.test_record |
| 167 | 157 |
| 168 def BasePath(self, filename): | 158 def BasePath(self, filename): |
| 169 return self.root if filename in TEST_262_NATIVE_FILES else self.harnesspath | 159 return self.root if filename in TEST_262_NATIVE_FILES else self.harnesspath |
| 170 | 160 |
| 171 def GetIncludesForTest(self, testcase): | 161 def GetIncludesForTest(self, testcase): |
| 172 test_record = self.GetTestRecord(testcase) | 162 test_record = self.GetTestRecord(testcase) |
| 173 if "includes" in test_record: | 163 if "includes" in test_record: |
| 174 return [os.path.join(self.BasePath(filename), filename) | 164 return [os.path.join(self.BasePath(filename), filename) |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 215 | 205 |
| 216 archive_files = [f for f in os.listdir(self.root) | 206 archive_files = [f for f in os.listdir(self.root) |
| 217 if f.startswith("tc39-test262-")] | 207 if f.startswith("tc39-test262-")] |
| 218 if len(archive_files) > 0: | 208 if len(archive_files) > 0: |
| 219 print "Clobber outdated test archives ..." | 209 print "Clobber outdated test archives ..." |
| 220 for f in archive_files: | 210 for f in archive_files: |
| 221 os.remove(os.path.join(self.root, f)) | 211 os.remove(os.path.join(self.root, f)) |
| 222 | 212 |
| 223 # The archive is created only on swarming. Local checkouts have the | 213 # The archive is created only on swarming. Local checkouts have the |
| 224 # data folder. | 214 # data folder. |
| 225 if os.path.exists(ARCHIVE) and not os.path.exists(DATA): | 215 if os.path.exists(DATA_ARCHIVE) and not os.path.exists(DATA): |
| 226 print "Extracting archive..." | 216 print "Extracting archive..." |
| 227 tar = tarfile.open(ARCHIVE) | 217 tar = tarfile.open(DATA_ARCHIVE) |
| 228 tar.extractall(path=os.path.dirname(ARCHIVE)) | 218 tar.extractall(path=os.path.dirname(DATA_ARCHIVE)) |
| 229 tar.close() | 219 tar.close() |
| 230 | 220 |
| 221 if os.path.exists(HARNESS_ARCHIVE) and not os.path.exists(HARNESS): | |
| 222 print "Extracting harness..." | |
| 223 tar = tarfile.open(HARNESS_ARCHIVE) | |
| 224 tar.extractall(path=os.path.dirname(HARNESS_ARCHIVE)) | |
| 225 tar.close() | |
| 226 | |
| 227 global parseTestRecord | |
| 228 from harness import parseTestRecord | |
| 229 | |
| 231 | 230 |
| 232 def GetSuite(name, root): | 231 def GetSuite(name, root): |
| 233 return Test262TestSuite(name, root) | 232 return Test262TestSuite(name, root) |
| OLD | NEW |