Chromium Code Reviews| Index: test/test262/testcfg.py |
| diff --git a/test/test262/testcfg.py b/test/test262/testcfg.py |
| index b62e9b0d6b4ffbe99ccb95de871713db440c3e30..87467aee801c5f59833a9f7d282ed32a3c703e45 100644 |
| --- a/test/test262/testcfg.py |
| +++ b/test/test262/testcfg.py |
| @@ -33,21 +33,28 @@ import shutil |
| import sys |
| import tarfile |
| - |
| from testrunner.local import statusfile |
| from testrunner.local import testsuite |
| from testrunner.local import utils |
| from testrunner.objects import testcase |
| DATA = os.path.join(os.path.dirname(os.path.abspath(__file__)), "data") |
| -ARCHIVE = DATA + ".tar" |
| +HARNESS = os.path.join(os.path.dirname(os.path.abspath(__file__)), "harness") |
| + |
| +# add parent dir to search path to get the harness files |
| +sys.path.append(os.path.dirname(os.path.abspath(__file__))) |
| +# In --donwload-data mode, HARNESS may be added later; import if present |
| +if os.path.exists(HARNESS): |
| + from harness import parseTestRecord |
|
tandrii(chromium)
2016/07/20 10:42:01
IMO, the previous version of lazy import is much b
|
| + |
| +DATA_ARCHIVE = DATA + ".tar" |
| +HARNESS_ARCHIVE = HARNESS + ".tar" |
| TEST_262_HARNESS_FILES = ["sta.js", "assert.js"] |
| TEST_262_NATIVE_FILES = ["detachArrayBuffer.js"] |
| TEST_262_SUITE_PATH = ["data", "test"] |
| -TEST_262_HARNESS_PATH = ["data", "harness"] |
| -TEST_262_TOOLS_PATH = ["data", "tools", "packaging"] |
| +TEST_262_INCLUDES_PATH = ["data", "harness"] |
| ALL_VARIANT_FLAGS_STRICT = dict( |
| (v, [flags + ["--use-strict"] for flags in flag_sets]) |
| @@ -103,11 +110,10 @@ class Test262TestSuite(testsuite.TestSuite): |
| def __init__(self, name, root): |
| super(Test262TestSuite, self).__init__(name, root) |
| self.testroot = os.path.join(self.root, *TEST_262_SUITE_PATH) |
| - self.harnesspath = os.path.join(self.root, *TEST_262_HARNESS_PATH) |
| + self.harnesspath = os.path.join(self.root, *TEST_262_INCLUDES_PATH) |
| self.harness = [os.path.join(self.harnesspath, f) |
| for f in TEST_262_HARNESS_FILES] |
| self.harness += [os.path.join(self.root, "harness-adapt.js")] |
| - self.ParseTestRecord = None |
| def ListTests(self, context): |
| tests = [] |
| @@ -142,26 +148,10 @@ class Test262TestSuite(testsuite.TestSuite): |
| def _VariantGeneratorFactory(self): |
| return Test262VariantGenerator |
| - def LoadParseTestRecord(self): |
| - if not self.ParseTestRecord: |
| - root = os.path.join(self.root, *TEST_262_TOOLS_PATH) |
| - f = None |
| - try: |
| - (f, pathname, description) = imp.find_module("parseTestRecord", [root]) |
| - module = imp.load_module("parseTestRecord", f, pathname, description) |
| - self.ParseTestRecord = module.parseTestRecord |
| - except: |
| - raise ImportError("Cannot load parseTestRecord; you may need to " |
| - "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
|
| - finally: |
| - if f: |
| - f.close() |
| - return self.ParseTestRecord |
| def GetTestRecord(self, testcase): |
| if not hasattr(testcase, "test_record"): |
| - ParseTestRecord = self.LoadParseTestRecord() |
| - testcase.test_record = ParseTestRecord(self.GetSourceForTest(testcase), |
| + testcase.test_record = parseTestRecord(self.GetSourceForTest(testcase), |
| testcase.path) |
| return testcase.test_record |
| @@ -222,12 +212,21 @@ class Test262TestSuite(testsuite.TestSuite): |
| # The archive is created only on swarming. Local checkouts have the |
| # data folder. |
| - if os.path.exists(ARCHIVE) and not os.path.exists(DATA): |
| + if os.path.exists(DATA_ARCHIVE) and not os.path.exists(DATA): |
| print "Extracting archive..." |
| - tar = tarfile.open(ARCHIVE) |
| - tar.extractall(path=os.path.dirname(ARCHIVE)) |
| + tar = tarfile.open(DATA_ARCHIVE) |
| + tar.extractall(path=os.path.dirname(DATA_ARCHIVE)) |
| tar.close() |
| + if os.path.exists(HARNESS_ARCHIVE) and not os.path.exists(HARNESS): |
| + print "Extracting harness..." |
| + tar = tarfile.open(HARNESS_ARCHIVE) |
| + tar.extractall(path=os.path.dirname(HARNESS_ARCHIVE)) |
| + tar.close() |
| + |
| + global parseTestRecord |
| + from harness import parseTestRecord |
| + |
| def GetSuite(name, root): |
| return Test262TestSuite(name, root) |