Commit f41a81b8 authored by machenbach's avatar machenbach Committed by Commit bot

[test] Refactoring - Let runner handle test IDs.

This prepares for properly rerunning tests. Currently when
tests are rerun, the same test object is reused. This
will be changed in a follow up.

Review URL: https://codereview.chromium.org/1168303007

Cr-Commit-Position: refs/heads/master@{#28864}
parent 0046ad79
...@@ -584,7 +584,6 @@ def Execute(arch, mode, args, options, suites, workspace): ...@@ -584,7 +584,6 @@ def Execute(arch, mode, args, options, suites, workspace):
} }
all_tests = [] all_tests = []
num_tests = 0 num_tests = 0
test_id = 0
for s in suites: for s in suites:
s.ReadStatusFile(variables) s.ReadStatusFile(variables)
s.ReadTestCases(ctx) s.ReadTestCases(ctx)
...@@ -602,9 +601,6 @@ def Execute(arch, mode, args, options, suites, workspace): ...@@ -602,9 +601,6 @@ def Execute(arch, mode, args, options, suites, workspace):
for v in s.VariantFlags(t, variant_flags) ] for v in s.VariantFlags(t, variant_flags) ]
s.tests = ShardTests(s.tests, options.shard_count, options.shard_run) s.tests = ShardTests(s.tests, options.shard_count, options.shard_run)
num_tests += len(s.tests) num_tests += len(s.tests)
for t in s.tests:
t.id = test_id
test_id += 1
if options.cat: if options.cat:
return 0 # We're done here. return 0 # We're done here.
......
...@@ -73,15 +73,19 @@ class Runner(object): ...@@ -73,15 +73,19 @@ class Runner(object):
for t in self.tests: for t in self.tests:
t.duration = self.perfdata.FetchPerfData(t) or 1.0 t.duration = self.perfdata.FetchPerfData(t) or 1.0
self.tests.sort(key=lambda t: t.duration, reverse=True) self.tests.sort(key=lambda t: t.duration, reverse=True)
self._CommonInit(len(self.tests), progress_indicator, context) self._CommonInit(suites, progress_indicator, context)
def _CommonInit(self, num_tests, progress_indicator, context): def _CommonInit(self, suites, progress_indicator, context):
self.total = 0
for s in suites:
for t in s.tests:
t.id = self.total
self.total += 1
self.indicator = progress_indicator self.indicator = progress_indicator
progress_indicator.runner = self progress_indicator.runner = self
self.context = context self.context = context
self.succeeded = 0 self.succeeded = 0
self.total = num_tests self.remaining = self.total
self.remaining = num_tests
self.failed = [] self.failed = []
self.crashed = 0 self.crashed = 0
self.reran_tests = 0 self.reran_tests = 0
...@@ -132,6 +136,7 @@ class Runner(object): ...@@ -132,6 +136,7 @@ class Runner(object):
test.run += 1 test.run += 1
pool.add([self._GetJob(test)]) pool.add([self._GetJob(test)])
self.remaining += 1 self.remaining += 1
self.total += 1
def _ProcessTestNormal(self, test, result, pool): def _ProcessTestNormal(self, test, result, pool):
self.indicator.AboutToRun(test) self.indicator.AboutToRun(test)
......
...@@ -52,7 +52,6 @@ def GetPeers(): ...@@ -52,7 +52,6 @@ def GetPeers():
class NetworkedRunner(execution.Runner): class NetworkedRunner(execution.Runner):
def __init__(self, suites, progress_indicator, context, peers, workspace): def __init__(self, suites, progress_indicator, context, peers, workspace):
self.suites = suites self.suites = suites
num_tests = 0
datapath = os.path.join("out", "testrunner_data") datapath = os.path.join("out", "testrunner_data")
# TODO(machenbach): These fields should exist now in the superclass. # TODO(machenbach): These fields should exist now in the superclass.
# But there is no super constructor call. Check if this is a problem. # But there is no super constructor call. Check if this is a problem.
...@@ -61,8 +60,7 @@ class NetworkedRunner(execution.Runner): ...@@ -61,8 +60,7 @@ class NetworkedRunner(execution.Runner):
for s in suites: for s in suites:
for t in s.tests: for t in s.tests:
t.duration = self.perfdata.FetchPerfData(t) or 1.0 t.duration = self.perfdata.FetchPerfData(t) or 1.0
num_tests += len(s.tests) self._CommonInit(suites, progress_indicator, context)
self._CommonInit(num_tests, progress_indicator, context)
self.tests = [] # Only used if we need to fall back to local execution. self.tests = [] # Only used if we need to fall back to local execution.
self.tests_lock = threading.Lock() self.tests_lock = threading.Lock()
self.peers = peers self.peers = peers
......
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