Commit 804cc9f3 authored by Michal Majewski's avatar Michal Majewski Committed by Commit Bot

[test] Remove context usage from test processors

Bug: v8:6917
Cq-Include-Trybots: luci.v8.try:v8_linux_noi18n_rel_ng
Change-Id: Id5a7b41502dfd4be43496b1edb958522a8eb0c31
Reviewed-on: https://chromium-review.googlesource.com/895588
Commit-Queue: Michał Majewski <majeski@google.com>
Reviewed-by: 's avatarSergiy Byelozyorov <sergiyb@chromium.org>
Reviewed-by: 's avatarMichael Achenbach <machenbach@chromium.org>
Cr-Commit-Position: refs/heads/master@{#51023}
parent d81938ff
...@@ -39,7 +39,7 @@ class TestSuite(testsuite.TestSuite): ...@@ -39,7 +39,7 @@ class TestSuite(testsuite.TestSuite):
super(TestSuite, self).__init__(*args, **kwargs) super(TestSuite, self).__init__(*args, **kwargs)
self.testroot = os.path.join(self.root, "data") self.testroot = os.path.join(self.root, "data")
def ListTests(self, context): def ListTests(self):
tests = map(self._create_test, [ tests = map(self._create_test, [
"kraken/ai-astar", "kraken/ai-astar",
"kraken/audio-beat-detection", "kraken/audio-beat-detection",
......
...@@ -37,7 +37,7 @@ SHELL = 'cctest' ...@@ -37,7 +37,7 @@ SHELL = 'cctest'
class TestSuite(testsuite.TestSuite): class TestSuite(testsuite.TestSuite):
def ListTests(self, context): def ListTests(self):
shell = os.path.abspath(os.path.join(self.test_config.shell_dir, SHELL)) shell = os.path.abspath(os.path.join(self.test_config.shell_dir, SHELL))
if utils.IsWindows(): if utils.IsWindows():
shell += ".exe" shell += ".exe"
......
...@@ -12,7 +12,7 @@ FILES_PATTERN = re.compile(r"//\s+Files:(.*)") ...@@ -12,7 +12,7 @@ FILES_PATTERN = re.compile(r"//\s+Files:(.*)")
MODULE_PATTERN = re.compile(r"^// MODULE$", flags=re.MULTILINE) MODULE_PATTERN = re.compile(r"^// MODULE$", flags=re.MULTILINE)
class TestSuite(testsuite.TestSuite): class TestSuite(testsuite.TestSuite):
def ListTests(self, context): def ListTests(self):
tests = [] tests = []
for dirname, dirs, files in os.walk(self.root): for dirname, dirs, files in os.walk(self.root):
for dotted in [x for x in dirs if x.startswith('.')]: for dotted in [x for x in dirs if x.startswith('.')]:
......
...@@ -20,7 +20,7 @@ class TestSuite(testsuite.TestSuite): ...@@ -20,7 +20,7 @@ class TestSuite(testsuite.TestSuite):
'wasm_globals_section', 'wasm_imports_section', 'wasm_memory_section', 'wasm_globals_section', 'wasm_imports_section', 'wasm_memory_section',
'wasm_names_section', 'wasm_types_section' ) 'wasm_names_section', 'wasm_types_section' )
def ListTests(self, context): def ListTests(self):
tests = [] tests = []
for subtest in TestSuite.SUB_TESTS: for subtest in TestSuite.SUB_TESTS:
for fname in os.listdir(os.path.join(self.root, subtest)): for fname in os.listdir(os.path.join(self.root, subtest)):
......
...@@ -14,7 +14,7 @@ EXPECTED_SUFFIX = "-expected.txt" ...@@ -14,7 +14,7 @@ EXPECTED_SUFFIX = "-expected.txt"
RESOURCES_FOLDER = "resources" RESOURCES_FOLDER = "resources"
class TestSuite(testsuite.TestSuite): class TestSuite(testsuite.TestSuite):
def ListTests(self, context): def ListTests(self):
tests = [] tests = []
for dirname, dirs, files in os.walk( for dirname, dirs, files in os.walk(
os.path.join(self.root), followlinks=True): os.path.join(self.root), followlinks=True):
......
...@@ -31,7 +31,7 @@ from testrunner.local import testsuite ...@@ -31,7 +31,7 @@ from testrunner.local import testsuite
from testrunner.objects import testcase from testrunner.objects import testcase
class TestSuite(testsuite.TestSuite): class TestSuite(testsuite.TestSuite):
def ListTests(self, context): def ListTests(self):
tests = [] tests = []
for dirname, dirs, files in os.walk(self.root): for dirname, dirs, files in os.walk(self.root):
for dotted in [x for x in dirs if x.startswith('.')]: for dotted in [x for x in dirs if x.startswith('.')]:
......
...@@ -39,7 +39,7 @@ MODULE_PATTERN = re.compile(r"^// MODULE$", flags=re.MULTILINE) ...@@ -39,7 +39,7 @@ MODULE_PATTERN = re.compile(r"^// MODULE$", flags=re.MULTILINE)
class TestSuite(testsuite.TestSuite): class TestSuite(testsuite.TestSuite):
def ListTests(self, context): def ListTests(self):
tests = [] tests = []
for dirname, dirs, files in os.walk(self.root): for dirname, dirs, files in os.walk(self.root):
for dotted in [x for x in dirs if x.startswith('.')]: for dotted in [x for x in dirs if x.startswith('.')]:
......
...@@ -41,7 +41,7 @@ NO_HARNESS_PATTERN = re.compile(r"^// NO HARNESS$", flags=re.MULTILINE) ...@@ -41,7 +41,7 @@ NO_HARNESS_PATTERN = re.compile(r"^// NO HARNESS$", flags=re.MULTILINE)
class TestSuite(testsuite.TestSuite): class TestSuite(testsuite.TestSuite):
def ListTests(self, context): def ListTests(self):
tests = [] tests = []
for dirname, dirs, files in os.walk(self.root, followlinks=True): for dirname, dirs, files in os.walk(self.root, followlinks=True):
for dotted in [x for x in dirs if x.startswith('.')]: for dotted in [x for x in dirs if x.startswith('.')]:
......
...@@ -18,7 +18,7 @@ class TestSuite(testsuite.TestSuite): ...@@ -18,7 +18,7 @@ class TestSuite(testsuite.TestSuite):
v8_path = os.path.dirname(os.path.dirname(os.path.abspath(self.root))) v8_path = os.path.dirname(os.path.dirname(os.path.abspath(self.root)))
self.expected_path = os.path.join(v8_path, 'tools', 'v8heapconst.py') self.expected_path = os.path.join(v8_path, 'tools', 'v8heapconst.py')
def ListTests(self, context): def ListTests(self):
test = self._create_test(SHELL) test = self._create_test(SHELL)
return [test] return [test]
......
...@@ -60,7 +60,7 @@ class TestSuite(testsuite.TestSuite): ...@@ -60,7 +60,7 @@ class TestSuite(testsuite.TestSuite):
super(TestSuite, self).__init__(*args, **kwargs) super(TestSuite, self).__init__(*args, **kwargs)
self.testroot = os.path.join(self.root, "data") self.testroot = os.path.join(self.root, "data")
def ListTests(self, context): def ListTests(self):
tests = [] tests = []
for testdir in TEST_DIRS: for testdir in TEST_DIRS:
current_root = os.path.join(self.testroot, testdir) current_root = os.path.join(self.testroot, testdir)
......
...@@ -60,7 +60,7 @@ class TestSuite(testsuite.TestSuite): ...@@ -60,7 +60,7 @@ class TestSuite(testsuite.TestSuite):
return MkTest return MkTest
execfile(pathname, {"Test": Test, "Template": Template}) execfile(pathname, {"Test": Test, "Template": Template})
def ListTests(self, context): def ListTests(self):
result = [] result = []
# Find all .pyt files in this directory. # Find all .pyt files in this directory.
......
...@@ -158,7 +158,7 @@ class TestSuite(testsuite.TestSuite): ...@@ -158,7 +158,7 @@ class TestSuite(testsuite.TestSuite):
if f: if f:
f.close() f.close()
def ListTests(self, context): def ListTests(self):
testnames = set() testnames = set()
for dirname, dirs, files in itertools.chain(os.walk(self.testroot), for dirname, dirs, files in itertools.chain(os.walk(self.testroot),
os.walk(self.localtestroot)): os.walk(self.localtestroot)):
......
...@@ -16,7 +16,7 @@ class VariantsGenerator(testsuite.VariantsGenerator): ...@@ -16,7 +16,7 @@ class VariantsGenerator(testsuite.VariantsGenerator):
class TestSuite(testsuite.TestSuite): class TestSuite(testsuite.TestSuite):
def ListTests(self, context): def ListTests(self):
shell = os.path.abspath(os.path.join(self.test_config.shell_dir, self.name)) shell = os.path.abspath(os.path.join(self.test_config.shell_dir, self.name))
if utils.IsWindows(): if utils.IsWindows():
shell += ".exe" shell += ".exe"
......
...@@ -8,7 +8,7 @@ from testrunner.local import testsuite ...@@ -8,7 +8,7 @@ from testrunner.local import testsuite
from testrunner.objects import testcase from testrunner.objects import testcase
class TestSuite(testsuite.TestSuite): class TestSuite(testsuite.TestSuite):
def ListTests(self, context): def ListTests(self):
tests = [] tests = []
for dirname, dirs, files in os.walk(self.root): for dirname, dirs, files in os.walk(self.root):
for dotted in [x for x in dirs if x.startswith('.')]: for dotted in [x for x in dirs if x.startswith('.')]:
......
...@@ -38,7 +38,7 @@ SELF_SCRIPT_PATTERN = re.compile(r"//\s+Env: TEST_FILE_NAME") ...@@ -38,7 +38,7 @@ SELF_SCRIPT_PATTERN = re.compile(r"//\s+Env: TEST_FILE_NAME")
# TODO (machenbach): Share commonalities with mjstest. # TODO (machenbach): Share commonalities with mjstest.
class TestSuite(testsuite.TestSuite): class TestSuite(testsuite.TestSuite):
def ListTests(self, context): def ListTests(self):
tests = [] tests = []
for dirname, dirs, files in os.walk(self.root): for dirname, dirs, files in os.walk(self.root):
for dotted in [x for x in dirs if x.startswith('.')]: for dotted in [x for x in dirs if x.startswith('.')]:
......
...@@ -130,7 +130,7 @@ class TestSuite(object): ...@@ -130,7 +130,7 @@ class TestSuite(object):
""" """
self.suppress_internals = True self.suppress_internals = True
def ListTests(self, context): def ListTests(self):
raise NotImplementedError raise NotImplementedError
def _LegacyVariantsGeneratorFactory(self): def _LegacyVariantsGeneratorFactory(self):
...@@ -171,8 +171,8 @@ class TestSuite(object): ...@@ -171,8 +171,8 @@ class TestSuite(object):
def ReadStatusFile(self, variables): def ReadStatusFile(self, variables):
self.statusfile = statusfile.StatusFile(self.status_file(), variables) self.statusfile = statusfile.StatusFile(self.status_file(), variables)
def ReadTestCases(self, context): def ReadTestCases(self):
self.tests = self.ListTests(context) self.tests = self.ListTests()
def FilterTestCasesByStatus(self, def FilterTestCasesByStatus(self,
......
...@@ -14,7 +14,6 @@ import base_runner ...@@ -14,7 +14,6 @@ import base_runner
from testrunner.local import progress from testrunner.local import progress
from testrunner.local import utils from testrunner.local import utils
from testrunner.objects import context
from testrunner.testproc import fuzzer from testrunner.testproc import fuzzer
from testrunner.testproc.base import TestProcProducer from testrunner.testproc.base import TestProcProducer
...@@ -129,9 +128,8 @@ class NumFuzzer(base_runner.BaseTestRunner): ...@@ -129,9 +128,8 @@ class NumFuzzer(base_runner.BaseTestRunner):
print(">>> Running tests for %s.%s" % (self.build_config.arch, print(">>> Running tests for %s.%s" % (self.build_config.arch,
self.mode_name)) self.mode_name))
ctx = self._create_context(options)
self._setup_suites(options, suites) self._setup_suites(options, suites)
tests = self._load_tests(options, suites, ctx) tests = self._load_tests(options, suites)
progress_indicator = progress.IndicatorNotifier() progress_indicator = progress.IndicatorNotifier()
progress_indicator.Register( progress_indicator.Register(
progress.PROGRESS_INDICATORS[options.progress]()) progress.PROGRESS_INDICATORS[options.progress]())
...@@ -146,7 +144,7 @@ class NumFuzzer(base_runner.BaseTestRunner): ...@@ -146,7 +144,7 @@ class NumFuzzer(base_runner.BaseTestRunner):
combiner = self._create_combiner(fuzzer_rng, options) combiner = self._create_combiner(fuzzer_rng, options)
results = ResultsTracker() results = ResultsTracker()
execproc = ExecutionProc(options.j, ctx) execproc = ExecutionProc(options.j)
indicators = progress_indicator.ToProgressIndicatorProcs() indicators = progress_indicator.ToProgressIndicatorProcs()
procs = [ procs = [
loader, loader,
...@@ -185,25 +183,6 @@ class NumFuzzer(base_runner.BaseTestRunner): ...@@ -185,25 +183,6 @@ class NumFuzzer(base_runner.BaseTestRunner):
return 2 return 2
return 0 return 0
def _create_context(self, options):
# Populate context object.
ctx = context.Context(self.build_config.arch,
self.mode_options.execution_mode,
self.outdir,
self.mode_options.flags, options.verbose,
options.timeout * self._timeout_scalefactor(options),
options.isolates,
options.command_prefix,
options.extra_flags,
False, # Keep i18n on by default.
True, # No sorting of test cases.
options.rerun_failures_count,
options.rerun_failures_max,
False, # No no_harness mode.
False, # Don't use perf data.
False) # Coverage not supported.
return ctx
def _setup_suites(self, options, suites): def _setup_suites(self, options, suites):
"""Sets additional configurations on test suites based on options.""" """Sets additional configurations on test suites based on options."""
if options.stress_interrupt_budget: if options.stress_interrupt_budget:
...@@ -211,7 +190,7 @@ class NumFuzzer(base_runner.BaseTestRunner): ...@@ -211,7 +190,7 @@ class NumFuzzer(base_runner.BaseTestRunner):
for suite in suites: for suite in suites:
suite.do_suppress_internals() suite.do_suppress_internals()
def _load_tests(self, options, suites, ctx): def _load_tests(self, options, suites):
if options.combine_tests: if options.combine_tests:
suites = [s for s in suites if s.test_combiner_available()] suites = [s for s in suites if s.test_combiner_available()]
...@@ -251,7 +230,7 @@ class NumFuzzer(base_runner.BaseTestRunner): ...@@ -251,7 +230,7 @@ class NumFuzzer(base_runner.BaseTestRunner):
tests = [] tests = []
for s in suites: for s in suites:
s.ReadStatusFile(variables) s.ReadStatusFile(variables)
s.ReadTestCases(ctx) s.ReadTestCases()
tests += s.tests tests += s.tests
return tests return tests
......
...@@ -399,16 +399,15 @@ class StandardTestRunner(base_runner.BaseTestRunner): ...@@ -399,16 +399,15 @@ class StandardTestRunner(base_runner.BaseTestRunner):
if options.infra_staging: if options.infra_staging:
for s in suites: for s in suites:
s.ReadStatusFile(variables) s.ReadStatusFile(variables)
s.ReadTestCases(ctx) s.ReadTestCases()
return self._run_test_procs(suites, args, options, progress_indicator, return self._run_test_procs(suites, args, options, progress_indicator)
ctx)
all_tests = [] all_tests = []
num_tests = 0 num_tests = 0
for s in suites: for s in suites:
s.ReadStatusFile(variables) s.ReadStatusFile(variables)
s.ReadTestCases(ctx) s.ReadTestCases()
if len(args) > 0: if len(args) > 0:
s.FilterTestCasesByArgs(args) s.FilterTestCasesByArgs(args)
all_tests += s.tests all_tests += s.tests
...@@ -515,8 +514,7 @@ class StandardTestRunner(base_runner.BaseTestRunner): ...@@ -515,8 +514,7 @@ class StandardTestRunner(base_runner.BaseTestRunner):
count += 1 count += 1
return shard return shard
def _run_test_procs(self, suites, args, options, progress_indicator, def _run_test_procs(self, suites, args, options, progress_indicator):
context):
jobs = options.j jobs = options.j
print '>>> Running with test processors' print '>>> Running with test processors'
...@@ -528,7 +526,7 @@ class StandardTestRunner(base_runner.BaseTestRunner): ...@@ -528,7 +526,7 @@ class StandardTestRunner(base_runner.BaseTestRunner):
outproc_factory = None outproc_factory = None
if self.build_config.predictable: if self.build_config.predictable:
outproc_factory = predictable.get_outproc outproc_factory = predictable.get_outproc
execproc = ExecutionProc(jobs, context, outproc_factory) execproc = ExecutionProc(jobs, outproc_factory)
procs = [ procs = [
loader, loader,
......
...@@ -43,10 +43,9 @@ class ExecutionProc(base.TestProc): ...@@ -43,10 +43,9 @@ class ExecutionProc(base.TestProc):
sends results to the previous processor. sends results to the previous processor.
""" """
def __init__(self, jobs, context, outproc_factory=None): def __init__(self, jobs, outproc_factory=None):
super(ExecutionProc, self).__init__() super(ExecutionProc, self).__init__()
self._pool = pool.Pool(jobs) self._pool = pool.Pool(jobs)
self._context = context
self._outproc_factory = outproc_factory or (lambda t: t.output_proc) self._outproc_factory = outproc_factory or (lambda t: t.output_proc)
self._tests = {} self._tests = {}
......
...@@ -10,7 +10,7 @@ from testrunner.local import testsuite ...@@ -10,7 +10,7 @@ from testrunner.local import testsuite
from testrunner.objects import testcase from testrunner.objects import testcase
class TestSuite(testsuite.TestSuite): class TestSuite(testsuite.TestSuite):
def ListTests(self, context): def ListTests(self):
return map( return map(
self._create_test, self._create_test,
['bananas', 'apples', 'cherries', 'strawberries', 'raspberries'], ['bananas', 'apples', 'cherries', 'strawberries', 'raspberries'],
......
...@@ -10,7 +10,7 @@ from testrunner.local import testsuite ...@@ -10,7 +10,7 @@ from testrunner.local import testsuite
from testrunner.objects import testcase from testrunner.objects import testcase
class TestSuite(testsuite.TestSuite): class TestSuite(testsuite.TestSuite):
def ListTests(self, context): def ListTests(self):
return map( return map(
self._create_test, self._create_test,
['bananaflakes'], ['bananaflakes'],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment