diff --git a/avocado/job.py b/avocado/job.py index e8ea33d29c84818b933443ac6cd542cb4ee38459..2a36f1f633cc5e472e3330f742a1eeb54b92f75b 100644 --- a/avocado/job.py +++ b/avocado/job.py @@ -178,27 +178,32 @@ class Job(object): self.test_dir = data_dir.get_test_dir() self.test_index = 1 self.status = "RUNNING" + self.result_proxy = result.TestResultProxy() self.output_manager = output.OutputManager() - def _make_test_runner(self, test_result): + def _make_test_runner(self): if hasattr(self.args, 'test_runner'): test_runner_class = self.args.test_runner else: test_runner_class = TestRunner - test_runner = test_runner_class(job=self, - test_result=test_result) - return test_runner - def _make_test_result(self, urls): - if hasattr(self.args, 'test_result'): - test_result_class = self.args.test_result - else: - test_result_class = result.HumanTestResult - if self.args is not None: - self.args.test_result_total = len(urls) - test_result = test_result_class(self.output_manager, self.args) - return test_result + self.test_runner = test_runner_class(job=self, + test_result=self.result_proxy) + + 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) + + if not self.result_proxy.output_plugins: + default_plugin = result.HumanTestResult(self.output_manager, self.args) + self.result_proxy.add_output_plugin(default_plugin) def _run(self, urls=None, multiplex_file=None): """ @@ -248,8 +253,11 @@ class Job(object): for dct in parser.get_dicts(): params_list.append(dct) - test_result = self._make_test_result(params_list) - self.test_runner = self._make_test_runner(test_result) + if self.args is not None: + self.args.test_result_total = len(params_list) + + self._make_test_result() + self._make_test_runner() self.output_manager.start_file_logging(self.debuglog, self.loglevel) diff --git a/avocado/plugins/journal.py b/avocado/plugins/journal.py index 7ae8ff674bf5d7bf4bd6605bb891d93f4afb5b5a..8bc7d41875be79089f5db81a2d238624842d22f1 100644 --- a/avocado/plugins/journal.py +++ b/avocado/plugins/journal.py @@ -121,4 +121,4 @@ class Journal(plugin.Plugin): def activate(self, app_args): if app_args.journal: - self.parser.set_defaults(test_result=TestResultJournal) + self.parser.set_defaults(journal_result=TestResultJournal) diff --git a/avocado/plugins/jsonresult.py b/avocado/plugins/jsonresult.py index 654f5ad147a8ae5cd40028c9e4d091b35dd974f1..32dcfc55f75db418316d42f6f5ccf2b5a616e993 100644 --- a/avocado/plugins/jsonresult.py +++ b/avocado/plugins/jsonresult.py @@ -94,4 +94,4 @@ class JSON(plugin.Plugin): def activate(self, app_args): if app_args.json: - self.parser.set_defaults(test_result=JSONTestResult) + self.parser.set_defaults(json_result=JSONTestResult) diff --git a/avocado/plugins/vm.py b/avocado/plugins/vm.py index 79886b2cb9bfaaefc1ef7744a94124b43bd5eaf9..7f52a1cf90b71a8c3a3688b300c16a0d245bd6a4 100644 --- a/avocado/plugins/vm.py +++ b/avocado/plugins/vm.py @@ -120,6 +120,7 @@ class VMTestResult(TestResult): self.vm.remote.send_files(test_path, self.remote_test_dir) def setup(self): + self.urls = self.args.url.split() if self.args.vm_domain is None: e_msg = ('Please set Virtual Machine Domain with option ' '--vm-domain.') @@ -289,5 +290,5 @@ class RunVM(plugin.Plugin): def activate(self, app_args): if app_args.vm: - self.parser.set_defaults(test_result=VMTestResult, + self.parser.set_defaults(vm_result=VMTestResult, test_runner=VMTestRunner) diff --git a/avocado/plugins/xunit.py b/avocado/plugins/xunit.py index 4b89c3211a120a83662c4d74a6aab290e4b297b7..1022886699814c7444a78d1df0cbef8029e42598 100644 --- a/avocado/plugins/xunit.py +++ b/avocado/plugins/xunit.py @@ -222,4 +222,4 @@ class XUnit(plugin.Plugin): def activate(self, app_args): if app_args.xunit: - self.parser.set_defaults(test_result=xUnitTestResult) + self.parser.set_defaults(xunit_result=xUnitTestResult)