提交 3652751b 编写于 作者: L Lucas Meneghel Rodrigues

avocado.job: If possible, write an HTML report at the job results dir

If the HTML plugin is enabled on this install, write a
report at html/ on that job results directory. This will
help people to read avocado test results on a portable
and pleasant way.
Signed-off-by: NLucas Meneghel Rodrigues <lmr@redhat.com>
上级 fbd73b21
......@@ -43,6 +43,11 @@ from avocado import sysinfo
from avocado import runtime
from avocado.plugins import xunit
from avocado.plugins import jsonresult
try:
from avocado.plugins import htmlresult
HTML_REPORT_SUPPORT = True
except ImportError:
HTML_REPORT_SUPPORT = False
_NEW_ISSUE_LINK = 'https://github.com/avocado-framework/avocado/issues/new'
......@@ -388,6 +393,19 @@ class Job(object):
json_plugin = jsonresult.JSONTestResult(self.view, args)
self.result_proxy.add_output_plugin(json_plugin)
# Setup the json plugin to output to the debug directory
if HTML_REPORT_SUPPORT:
html_file = os.path.join(self.logdir, 'html', 'results.html')
args = argparse.Namespace()
args.html_output = html_file
if self.args is not None:
args.open_browser = getattr(self.args, 'open_browser')
else:
args.open_browser = False
args.relative_links = True
html_plugin = htmlresult.HTMLTestResult(self.view, args)
self.result_proxy.add_output_plugin(html_plugin)
op_set_stdout = self.result_proxy.output_plugins_using_stdout()
if len(op_set_stdout) > 1:
msg = ('Options %s are trying to use stdout simultaneously' %
......
......@@ -20,6 +20,8 @@ It also contains the most basic test result class, HumanTestResult,
used by the test runner.
"""
import os
class InvalidOutputPlugin(Exception):
pass
......@@ -253,6 +255,11 @@ class HumanTestResult(TestResult):
TestResult.start_tests(self)
self.stream.notify(event="message", msg="JOB ID : %s" % self.stream.job_unique_id)
self.stream.notify(event="message", msg="JOB LOG : %s" % self.stream.logfile)
if self.args is not None:
if 'html_output' in self.args:
logdir = os.path.dirname(self.stream.logfile)
html_file = os.path.join(logdir, 'html', 'results.html')
self.stream.notify(event="message", msg="JOB HTML : %s" % html_file)
self.stream.notify(event="message", msg="TESTS : %s" % self.tests_total)
self.stream.set_tests_info({'tests_total': self.tests_total})
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册