提交 f1173d16 编写于 作者: A Amador Pahim 提交者: Cleber Rosa

tap: fix total number of tests

The job has the number of tests, but not the total of test executions.
This information comes from the result attribute 'tests_total', updated
by the runner.

This patch changes the tap plugin so it can use the correct information.

Reference: https://trello.com/c/tiusKNNjSigned-off-by: NAmador Pahim <apahim@redhat.com>
上级 a8178944
......@@ -66,6 +66,7 @@ class TAPResult(ResultEvents):
log = open(output, "w", 1)
self.__open_files.append(log)
self.__logs.append(file_log_factory(log))
self.is_header_printed = False
def __write(self, msg, *writeargs):
"""
......@@ -84,11 +85,6 @@ class TAPResult(ResultEvents):
self.__open_files.append(log)
self.__logs.append(file_log_factory(log))
# Start writing the tap to all streams
tests = len(job.test_suite)
if tests > 0:
self.__write("1..%d", tests)
def start_test(self, result, state):
pass
......@@ -96,6 +92,10 @@ class TAPResult(ResultEvents):
"""
Log the test status and details
"""
if not self.is_header_printed:
self.__write("1..%d", result.tests_total)
self.is_header_printed = True
status = state.get("status", "ERROR")
name = state.get("name")
if not name:
......
......@@ -427,6 +427,17 @@ class OutputPluginTest(unittest.TestCase):
os.chdir(basedir)
process.run("perl %s" % perl_script)
def test_tap_totaltests(self):
os.chdir(basedir)
cmd_line = ("./scripts/avocado run passtest.py "
"-m examples/tests/sleeptest.py.data/sleeptest.yaml "
"--job-results-dir %s "
"--tap -" % self.tmpdir)
result = process.run(cmd_line)
expr = '1..4'
self.assertIn(expr, result.stdout, "'%s' not found in:\n%s"
% (expr, result.stdout))
def test_broken_pipe(self):
os.chdir(basedir)
cmd_line = "(./scripts/avocado run --help | whacky-unknown-command)"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册