[test] Prepare test262 sources during init.

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 <majeski@google.com>
Reviewed-by: Sergiy Byelozyorov <sergiyb@chromium.org>
Reviewed-by: Michael Achenbach <machenbach@chromium.org>
Cr-Commit-Position: refs/heads/master@{#50024}
This commit is contained in:
Michal Majewski 2017-12-12 12:08:27 +01:00 committed by Commit Bot
parent 8f35755775
commit ccd15eaf2c
3 changed files with 34 additions and 46 deletions

View File

@ -131,6 +131,37 @@ class Test262TestSuite(testsuite.TestSuite):
self.harness += [os.path.join(self.root, "harness-adapt.js")] self.harness += [os.path.join(self.root, "harness-adapt.js")]
self.localtestroot = os.path.join(self.root, *TEST_262_LOCAL_TESTS_PATH) self.localtestroot = os.path.join(self.root, *TEST_262_LOCAL_TESTS_PATH)
self.ParseTestRecord = None 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): def ListTests(self, context):
testnames = set() testnames = set()
@ -180,27 +211,10 @@ class Test262TestSuite(testsuite.TestSuite):
def _VariantGeneratorFactory(self): def _VariantGeneratorFactory(self):
return Test262VariantGenerator 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): def GetTestRecord(self, testcase):
if not hasattr(testcase, "test_record"): if not hasattr(testcase, "test_record"):
ParseTestRecord = self.LoadParseTestRecord() testcase.test_record = self._parse_test_record(
testcase.test_record = ParseTestRecord(self.GetSourceForTest(testcase), self.GetSourceForTest(testcase), testcase.path)
testcase.path)
return testcase.test_record return testcase.test_record
def BasePath(self, filename): def BasePath(self, filename):
@ -251,21 +265,6 @@ class Test262TestSuite(testsuite.TestSuite):
return [statusfile.FAIL] return [statusfile.FAIL]
return super(Test262TestSuite, self).GetExpectedOutcomes(testcase) 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): def GetSuite(name, root):
return Test262TestSuite(name, root) return Test262TestSuite(name, root)

View File

@ -69,7 +69,7 @@ class VariantGenerator(object):
class TestSuite(object): class TestSuite(object):
@staticmethod @staticmethod
def LoadTestSuite(root, global_init=True): def LoadTestSuite(root):
name = root.split(os.path.sep)[-1] name = root.split(os.path.sep)[-1]
f = None f = None
try: try:
@ -121,14 +121,6 @@ class TestSuite(object):
""" """
return self._VariantGeneratorFactory()(self, set(variants)) 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): def ReadStatusFile(self, variables):
with open(self.status_file()) as f: with open(self.status_file()) as f:
self.rules, self.prefix_rules = ( self.rules, self.prefix_rules = (

View File

@ -123,9 +123,6 @@ class StandardTestRunner(base_runner.BaseTestRunner):
if suite: if suite:
suites.append(suite) suites.append(suite)
for s in suites:
s.PrepareSources()
try: try:
return self._execute(args, options, suites) return self._execute(args, options, suites)
except KeyboardInterrupt: except KeyboardInterrupt: