avocado.job: Prevent 2 output plugins to output to the stdout at the same time

With the new attributes, change the output setup procedure
to verify if more than one output plugin wants to use the
stdout, in which case we print an error message and fail.
Signed-off-by: NLucas Meneghel Rodrigues <lmr@redhat.com>
上级 327a88d5
......@@ -191,15 +191,31 @@ class Job(object):
self.test_runner = test_runner_class(job=self,
test_result=self.result_proxy)
def _set_output_plugins(self):
plugin_using_stdout = None
e_msg = ("Avocado could not set %s and %s both to output to stdout. ")
e_msg_2 = ("Please set the output flag of one of them to a file "
"to avoid conflicts.")
for key in self.args.__dict__:
if key.endswith('_result'):
result_class = getattr(self.args, key)
if issubclass(result_class, result.TestResult):
result_plugin = result_class(self.output_manager,
self.args)
if result_plugin.output == '-':
if plugin_using_stdout is not None:
e_msg %= (plugin_using_stdout.output_option,
result_plugin.output_option)
self.output_manager.log_fail_header(e_msg)
self.output_manager.log_fail_header(e_msg_2)
sys.exit(error_codes.numeric_status['AVOCADO_JOB_FAIL'])
else:
plugin_using_stdout = result_plugin
self.result_proxy.add_output_plugin(result_plugin)
def _make_test_result(self):
if self.args:
for key in self.args.__dict__:
if key.endswith('_result'):
result_class = getattr(self.args, key)
if issubclass(result_class, result.TestResult):
result_plugin = result_class(self.output_manager,
self.args)
self.result_proxy.add_output_plugin(result_plugin)
self._set_output_plugins()
if not self.result_proxy.output_plugins:
default_plugin = result.HumanTestResult(self.output_manager, self.args)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册