[test] Move command from test to the result
Bug: v8:6917 Change-Id: I54f908609fadd88bb23bf9fc566d1e2f3ff5e18e Cq-Include-Trybots: luci.v8.try:v8_linux64_fyi_rel_ng Reviewed-on: https://chromium-review.googlesource.com/870353 Commit-Queue: Michał Majewski <majeski@google.com> Reviewed-by: Michael Achenbach <machenbach@chromium.org> Cr-Commit-Position: refs/heads/master@{#50653}
This commit is contained in:
parent
4dc85663cc
commit
daed2eb723
@ -581,9 +581,6 @@ class StandardTestRunner(base_runner.BaseTestRunner):
|
||||
def _run_test_procs(self, suites, args, options, progress_indicator,
|
||||
context):
|
||||
jobs = options.j
|
||||
for s in suites:
|
||||
for t in s.tests:
|
||||
t.cmd = t.get_command(context)
|
||||
|
||||
print '>>> Running with test processors'
|
||||
loader = LoadProc()
|
||||
|
@ -68,7 +68,7 @@ class ExecutionProc(base.TestProc):
|
||||
job_result = pool_result.value
|
||||
test_id, result = job_result
|
||||
|
||||
test = self._tests[test_id]
|
||||
test, result.cmd = self._tests[test_id]
|
||||
del self._tests[test_id]
|
||||
self._send_result(test, result)
|
||||
except KeyboardInterrupt:
|
||||
@ -81,15 +81,12 @@ class ExecutionProc(base.TestProc):
|
||||
|
||||
def next_test(self, test):
|
||||
test_id = test.procid
|
||||
self._tests[test_id] = test
|
||||
|
||||
# TODO(majeski): Don't modify test. It's currently used in the progress
|
||||
# indicator.
|
||||
test.cmd = test.get_command(self._context)
|
||||
cmd = test.get_command(self._context)
|
||||
self._tests[test_id] = test, cmd
|
||||
|
||||
# TODO(majeski): Needs factory for outproc as in local/execution.py
|
||||
outproc = test.output_proc
|
||||
self._pool.add([Job(test_id, test.cmd, outproc, test.keep_output)])
|
||||
self._pool.add([Job(test_id, cmd, outproc, test.keep_output)])
|
||||
|
||||
def result_for(self, test, result):
|
||||
assert False, 'ExecutionProc cannot receive results'
|
||||
|
@ -69,25 +69,25 @@ class SimpleProgressIndicator(ProgressIndicator):
|
||||
def _on_result_for(self, test, result):
|
||||
# TODO(majeski): Support for dummy/grouped results
|
||||
if result.has_unexpected_output:
|
||||
self._failed.append((test, result.output))
|
||||
self._failed.append((test, result))
|
||||
|
||||
def finished(self):
|
||||
crashed = 0
|
||||
print
|
||||
for test, output in self._failed:
|
||||
for test, result in self._failed:
|
||||
print_failure_header(test)
|
||||
if output.stderr:
|
||||
if result.output.stderr:
|
||||
print "--- stderr ---"
|
||||
print output.stderr.strip()
|
||||
if output.stdout:
|
||||
print result.output.stderr.strip()
|
||||
if result.output.stdout:
|
||||
print "--- stdout ---"
|
||||
print output.stdout.strip()
|
||||
print "Command: %s" % test.cmd.to_string()
|
||||
if output.HasCrashed():
|
||||
print "exit code: %d" % output.exit_code
|
||||
print result.output.stdout.strip()
|
||||
print "Command: %s" % result.cmd.to_string()
|
||||
if result.output.HasCrashed():
|
||||
print "exit code: %d" % result.output.exit_code
|
||||
print "--- CRASHED ---"
|
||||
crashed += 1
|
||||
if output.HasTimedOut():
|
||||
if result.output.HasTimedOut():
|
||||
print "--- TIMEOUT ---"
|
||||
if len(self._failed) == 0:
|
||||
print "==="
|
||||
@ -181,7 +181,7 @@ class CompactProgressIndicator(ProgressIndicator):
|
||||
print self._templates['stdout'] % stdout
|
||||
if len(stderr):
|
||||
print self._templates['stderr'] % stderr
|
||||
print "Command: %s" % test.cmd
|
||||
print "Command: %s" % result.cmd
|
||||
if output.HasCrashed():
|
||||
print "exit code: %d" % output.exit_code
|
||||
print "--- CRASHED ---"
|
||||
@ -274,14 +274,14 @@ class JUnitTestProgressIndicator(ProgressIndicator):
|
||||
stderr = output.stderr.strip()
|
||||
if len(stderr):
|
||||
fail_text += "stderr:\n%s\n" % stderr
|
||||
fail_text += "Command: %s" % test.cmd.to_string()
|
||||
fail_text += "Command: %s" % result.cmd.to_string()
|
||||
if output.HasCrashed():
|
||||
fail_text += "exit code: %d\n--- CRASHED ---" % output.exit_code
|
||||
if output.HasTimedOut():
|
||||
fail_text += "--- TIMEOUT ---"
|
||||
self.outputter.HasRunTest(
|
||||
test_name=str(test),
|
||||
test_cmd=test.cmd.to_string(relative=True),
|
||||
test_cmd=result.cmd.to_string(relative=True),
|
||||
test_duration=output.duration,
|
||||
test_failure=fail_text)
|
||||
|
||||
@ -318,7 +318,8 @@ class JsonTestProgressIndicator(ProgressIndicator):
|
||||
# TODO(majeski): Support for dummy/grouped results
|
||||
output = result.output
|
||||
# Buffer all tests for sorting the durations in the end.
|
||||
self.tests.append((test, output.duration))
|
||||
# TODO(machenbach): Running average + buffer only slowest 20 tests.
|
||||
self.tests.append((test, output.duration, result.cmd))
|
||||
|
||||
# Omit tests that run as expected on the first try.
|
||||
# Everything that happens after the first run is included in the output
|
||||
@ -328,8 +329,8 @@ class JsonTestProgressIndicator(ProgressIndicator):
|
||||
|
||||
self.results.append({
|
||||
"name": str(test),
|
||||
"flags": test.cmd.args,
|
||||
"command": test.cmd.to_string(relative=True),
|
||||
"flags": result.cmd.args,
|
||||
"command": result.cmd.to_string(relative=True),
|
||||
"run": run + 1,
|
||||
"stdout": output.stdout,
|
||||
"stderr": output.stderr,
|
||||
@ -356,19 +357,19 @@ class JsonTestProgressIndicator(ProgressIndicator):
|
||||
if self.tests:
|
||||
# Get duration mean.
|
||||
duration_mean = (
|
||||
sum(duration for (_, duration) in self.tests) /
|
||||
sum(duration for (_, duration, cmd) in self.tests) /
|
||||
float(len(self.tests)))
|
||||
|
||||
# Sort tests by duration.
|
||||
self.tests.sort(key=lambda (_, duration): duration, reverse=True)
|
||||
self.tests.sort(key=lambda (_, duration, cmd): duration, reverse=True)
|
||||
slowest_tests = [
|
||||
{
|
||||
"name": str(test),
|
||||
"flags": test.cmd.args,
|
||||
"command": test.cmd.to_string(relative=True),
|
||||
"flags": cmd.args,
|
||||
"command": cmd.to_string(relative=True),
|
||||
"duration": duration,
|
||||
"marked_slow": test.is_slow,
|
||||
} for (test, duration) in self.tests[:20]
|
||||
} for (test, duration, cmd) in self.tests[:20]
|
||||
]
|
||||
|
||||
complete_results.append({
|
||||
|
@ -20,9 +20,10 @@ class ResultBase(object):
|
||||
class Result(ResultBase):
|
||||
"""Result created by the output processor."""
|
||||
|
||||
def __init__(self, has_unexpected_output, output):
|
||||
def __init__(self, has_unexpected_output, output, cmd=None):
|
||||
self.has_unexpected_output = has_unexpected_output
|
||||
self.output = output
|
||||
self.cmd = cmd
|
||||
|
||||
|
||||
class GroupedResult(ResultBase):
|
||||
@ -87,7 +88,8 @@ class RerunResult(Result):
|
||||
assert results
|
||||
|
||||
last = results[-1]
|
||||
super(RerunResult, self).__init__(last.has_unexpected_output, last.output)
|
||||
super(RerunResult, self).__init__(last.has_unexpected_output, last.output,
|
||||
last.cmd)
|
||||
self.results = results
|
||||
|
||||
@property
|
||||
|
Loading…
Reference in New Issue
Block a user