diff --git a/avocado/job.py b/avocado/job.py index 2a36f1f633cc5e472e3330f742a1eeb54b92f75b..f1c7c695658cfd1a0c979c13705713e91c7778ef 100644 --- a/avocado/job.py +++ b/avocado/job.py @@ -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)