From ccd15eaf2c7178d6952e010fffe7c5619c1c8ef6 Mon Sep 17 00:00:00 2001 From: Michal Majewski Date: Tue, 12 Dec 2017 12:08:27 +0100 Subject: [PATCH] [test] Prepare test262 sources during init. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: v8:6917 Cq-Include-Trybots: master.tryserver.v8:v8_linux_noi18n_rel_ng Change-Id: Iad6b429cfd855c435528468396c880f7733776d9 Reviewed-on: https://chromium-review.googlesource.com/819551 Commit-Queue: MichaƂ Majewski Reviewed-by: Sergiy Byelozyorov Reviewed-by: Michael Achenbach Cr-Commit-Position: refs/heads/master@{#50024} --- test/test262/testcfg.py | 67 ++++++++++++++--------------- tools/testrunner/local/testsuite.py | 10 +---- tools/testrunner/standard_runner.py | 3 -- 3 files changed, 34 insertions(+), 46 deletions(-) diff --git a/test/test262/testcfg.py b/test/test262/testcfg.py index 958a94c1b5..f65fc3b2fd 100644 --- a/test/test262/testcfg.py +++ b/test/test262/testcfg.py @@ -131,6 +131,37 @@ class Test262TestSuite(testsuite.TestSuite): self.harness += [os.path.join(self.root, "harness-adapt.js")] self.localtestroot = os.path.join(self.root, *TEST_262_LOCAL_TESTS_PATH) self.ParseTestRecord = None + self._extract_sources() + self._parse_test_record = self._load_parse_test_record() + + def _extract_sources(self): + # The archive is created only on swarming. Local checkouts have the + # data folder. + if (os.path.exists(ARCHIVE) and + # Check for a JS file from the archive if we need to unpack. Some other + # files from the archive unfortunately exist due to a bug in the + # isolate_processor. + # TODO(machenbach): Migrate this to GN to avoid using the faulty + # isolate_processor: http://crbug.com/669910 + not os.path.exists(os.path.join(DATA, 'test', 'harness', 'error.js'))): + print "Extracting archive..." + tar = tarfile.open(ARCHIVE) + tar.extractall(path=os.path.dirname(ARCHIVE)) + tar.close() + + def _load_parse_test_record(self): + 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) + return module.parseTestRecord + except: + raise ImportError("Cannot load parseTestRecord; you may need to " + "gclient sync for test262") + finally: + if f: + f.close() def ListTests(self, context): testnames = set() @@ -180,27 +211,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") - 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.path) + testcase.test_record = self._parse_test_record( + self.GetSourceForTest(testcase), testcase.path) return testcase.test_record def BasePath(self, filename): @@ -251,21 +265,6 @@ class Test262TestSuite(testsuite.TestSuite): return [statusfile.FAIL] return super(Test262TestSuite, self).GetExpectedOutcomes(testcase) - def PrepareSources(self): - # The archive is created only on swarming. Local checkouts have the - # data folder. - if (os.path.exists(ARCHIVE) and - # Check for a JS file from the archive if we need to unpack. Some other - # files from the archive unfortunately exist due to a bug in the - # isolate_processor. - # TODO(machenbach): Migrate this to GN to avoid using the faulty - # isolate_processor: http://crbug.com/669910 - not os.path.exists(os.path.join(DATA, 'test', 'harness', 'error.js'))): - print "Extracting archive..." - tar = tarfile.open(ARCHIVE) - tar.extractall(path=os.path.dirname(ARCHIVE)) - tar.close() - def GetSuite(name, root): return Test262TestSuite(name, root) diff --git a/tools/testrunner/local/testsuite.py b/tools/testrunner/local/testsuite.py index f01a39292b..7662beeae5 100644 --- a/tools/testrunner/local/testsuite.py +++ b/tools/testrunner/local/testsuite.py @@ -69,7 +69,7 @@ class VariantGenerator(object): class TestSuite(object): @staticmethod - def LoadTestSuite(root, global_init=True): + def LoadTestSuite(root): name = root.split(os.path.sep)[-1] f = None try: @@ -121,14 +121,6 @@ class TestSuite(object): """ return self._VariantGeneratorFactory()(self, set(variants)) - def PrepareSources(self): - """Called once before multiprocessing for doing file-system operations. - - This should not access the network. For network access use the method - below. - """ - pass - def ReadStatusFile(self, variables): with open(self.status_file()) as f: self.rules, self.prefix_rules = ( diff --git a/tools/testrunner/standard_runner.py b/tools/testrunner/standard_runner.py index 0904f10330..bd151c82aa 100755 --- a/tools/testrunner/standard_runner.py +++ b/tools/testrunner/standard_runner.py @@ -123,9 +123,6 @@ class StandardTestRunner(base_runner.BaseTestRunner): if suite: suites.append(suite) - for s in suites: - s.PrepareSources() - try: return self._execute(args, options, suites) except KeyboardInterrupt: