diff --git a/avocado/core/loader.py b/avocado/core/loader.py index f062fa81cd8620a5975f1f54f3865c9d6b1c94fe..91a28aba9ea431ef71a638fed70064673176b126 100644 --- a/avocado/core/loader.py +++ b/avocado/core/loader.py @@ -122,6 +122,8 @@ class TestLoaderProxy(object): self._initialized_plugins = [] self.registered_plugins = [] self.reference_plugin_mapping = {} + self._label_mapping = None + self._decorator_mapping = None def register_plugin(self, plugin): try: @@ -195,6 +197,20 @@ class TestLoaderProxy(object): extra_params['loader_options'] = loaders[i][1] plugin = self.registered_plugins[supported_loaders.index(name)] self._initialized_plugins.append(plugin(args, extra_params)) + self._update_mappings() + + def _update_mappings(self): + """ + Update the mappings according the current initialized plugins + """ + # Plugins are initialized, let's update mappings + self._label_mapping = {test.MissingTest: "MISSING"} + for plugin in self._initialized_plugins: + self._label_mapping.update(plugin.get_type_label_mapping()) + self._decorator_mapping = {test.MissingTest: + output.TERM_SUPPORT.fail_header_str} + for plugin in self._initialized_plugins: + self._decorator_mapping.update(plugin.get_decorator_mapping()) def get_extra_listing(self): for loader_plugin in self._initialized_plugins: @@ -207,16 +223,10 @@ class TestLoaderProxy(object): return base_path def get_type_label_mapping(self): - mapping = {} - for loader_plugin in self._initialized_plugins: - mapping.update(loader_plugin.get_type_label_mapping()) - return mapping + return self._label_mapping def get_decorator_mapping(self): - mapping = {} - for loader_plugin in self._initialized_plugins: - mapping.update(loader_plugin.get_decorator_mapping()) - return mapping + return self._decorator_mapping def discover(self, references, which_tests=DEFAULT): """ diff --git a/selftests/functional/test_basic.py b/selftests/functional/test_basic.py index 77ff86eb0a1e0f469541f8e8c6abf93360649188..313aeb78da39f051f588f03e6f73cce9f5addf9c 100644 --- a/selftests/functional/test_basic.py +++ b/selftests/functional/test_basic.py @@ -880,6 +880,19 @@ class PluginsTest(AbsPluginsTest, unittest.TestCase): (expected_rc, result)) self.assertIn("Unable to resolve reference", output) + def test_list_no_file_loader(self): + os.chdir(basedir) + cmd_line = ("%s list --loaders external --verbose -- " + "this-wont-be-matched" % AVOCADO) + result = process.run(cmd_line, ignore_status=True) + self.assertEqual(result.exit_status, exit_codes.AVOCADO_ALL_OK, + "Avocado did not return rc %d:\n%s" + % (exit_codes.AVOCADO_ALL_OK, result)) + exp = ("Type Test\nMISSING this-wont-be-matched\n\nEXTERNAL: 0\n" + "MISSING: 1\n") + self.assertEqual(exp, result.stdout, "Stdout mismatch:\n%s\n\n%s" + % (exp, result)) + def test_plugin_list(self): os.chdir(basedir) cmd_line = '%s plugins' % AVOCADO