Commit 39e89cc0 authored by Kirill Smelkov's avatar Kirill Smelkov

log += test result summary

We started to print test result summary line for a testcase run since
0153635b (Teach nxdtest to run tests locally). However it is not present
in log when nxdtest is run under master. -> Include summary lines
everywhere for uniformity, with reason similar to bd1333bb (log += title
and argv for ran testcase).
parent 3016b6be
......@@ -220,17 +220,19 @@ def main():
tend = time()
# report result of test run back to master
test_result_line.stop(
command = t.command_str(),
duration = tend - tstart,
date = strftime("%Y/%m/%d %H:%M:%S", gmtime(tend)),
stdout = stdout,
stderr = stderr,
# print summary and report result of test run back to master
tres = {
'command': t.command_str(),
'duration': tend - tstart,
'date': strftime("%Y/%m/%d %H:%M:%S", gmtime(tend)),
'stdout': stdout,
'stderr': stderr,
}
tres.update(status)
**status
)
print(test_result_summary(t.name, tres))
test_result_line.stop(**tres)
# tee, similar to tee(1) utility, copies data from fin to fout appending them to buf.
def tee(fin, fout, buf):
......@@ -251,6 +253,29 @@ def tee(fin, fout, buf):
buf.append(data)
# test_result_summary returns one-line summary for test result.
# it returns something like 'ok # 100t 3f'
# **kw is what is passed to test_result_line.stop().
def test_result_summary(name, kw):
def v(name):
return kw.get(name, '?')
_ = v('error_count')
if _ == '?':
st = '?'
elif _ != 0:
st = 'error'
else:
_ = v('failure_count')
if _ == '?':
st = '?'
elif _ != 0:
st = 'fail'
else:
st = 'ok'
return '%s\t%s\t%.3fs\t# %st %se %sf %ss' % (st, name, kw['duration'], v('test_count'), v('error_count'), v('failure_count'), v('skip_count'))
# LocalTestResult* handle tests runs, when master_url was not provided and tests are run locally.
class LocalTestResult:
......@@ -270,25 +295,8 @@ class LocalTestResult:
class LocalTestResultLine:
def stop(self, **kw):
def v(name):
return kw.get(name, '?')
_ = v('error_count')
if _ == '?':
st = '?'
elif _ != 0:
st = 'error'
else:
_ = v('failure_count')
if _ == '?':
st = '?'
elif _ != 0:
st = 'fail'
else:
st = 'ok'
print('%s\t%s\t%.3fs\t# %st %se %sf %ss' % (st, self.name, kw['duration'], v('test_count'), v('error_count'), v('failure_count'), v('skip_count')))
# XXX + dump .json ?
pass
# support for well-known summary functions
......
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