提交 4782e04b 编写于 作者: R Rudá Moura 提交者: Cleber Rosa

avocado.plugins.htmlresult: Detect stdout problem at the beginning.

Detect output to stdout as invalid at the beginning of execution
of the plugin, and not at the end of the html result execution.

Fix problem detected on test_output_incompatible_setup_3 when
sysinfo profile daemons are started and then left running, after
plugin exits with code 2.
Signed-off-by: NRudá Moura <rmoura@redhat.com>
上级 dca0b7d7
......@@ -221,25 +221,20 @@ class HTMLTestResult(TestResult):
template = html.get_resource_path('templates', 'report.mustache')
report_contents = renderer.render(open(template, 'r').read(), context)
static_basedir = html.get_resource_path('static')
if self.output == '-':
self.view.notify(event='error', msg="HTML to stdout not supported "
"(not all HTML resources can be embedded to a single file)")
sys.exit(exit_codes.AVOCADO_JOB_FAIL)
else:
output_dir = os.path.dirname(os.path.abspath(self.output))
utils_path.init_dir(output_dir)
for resource_dir in os.listdir(static_basedir):
res_dir = os.path.join(static_basedir, resource_dir)
out_dir = os.path.join(output_dir, resource_dir)
if os.path.exists(out_dir):
shutil.rmtree(out_dir)
shutil.copytree(res_dir, out_dir)
with codecs.open(self.output, 'w', 'utf-8') as report_file:
report_file.write(report_contents)
if self.args is not None:
if getattr(self.args, 'open_browser'):
webbrowser.open(self.output)
output_dir = os.path.dirname(os.path.abspath(self.output))
utils_path.init_dir(output_dir)
for resource_dir in os.listdir(static_basedir):
res_dir = os.path.join(static_basedir, resource_dir)
out_dir = os.path.join(output_dir, resource_dir)
if os.path.exists(out_dir):
shutil.rmtree(out_dir)
shutil.copytree(res_dir, out_dir)
with codecs.open(self.output, 'w', 'utf-8') as report_file:
report_file.write(report_contents)
if self.args is not None:
if getattr(self.args, 'open_browser'):
webbrowser.open(self.output)
class HTML(plugin.Plugin):
......@@ -280,6 +275,13 @@ class HTML(plugin.Plugin):
def activate(self, app_args):
try:
if app_args.html_output:
self.parser.application.set_defaults(html_result=HTMLTestResult)
if app_args.html_output == '-':
view = output.View(app_args=app_args)
view.notify(event='error',
msg="HTML to stdout not supported "
"(not all HTML resources can be embedded to a single file)")
sys.exit(exit_codes.AVOCADO_JOB_FAIL)
else:
self.parser.application.set_defaults(html_result=HTMLTestResult)
except AttributeError:
pass
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册