From 645b9c98dc8f509839e37055050be4f39d6161d2 Mon Sep 17 00:00:00 2001 From: Jake Hunsaker Date: Thu, 14 Nov 2019 16:10:50 -0500 Subject: [Plugin] Allow selectively disabling postprocessing Adds two mechanisms by which users can choose to disable postprocessing of collected information. First, is a global method exposed via the `--no-postproc` option. Using this option will skip postprocessing for all plugins. Second, is a per-plugin option exposed via a new 'postproc' plugin option. This is set to _True_ by default (meaning yes, perform postprocessing), which users can set to False or off to disable postprocessing for that plugin only; e.g. `-k podman.postproc=off` Closes: #286 Resolves: #1862 Signed-off-by: Jake Hunsaker --- tests/plugin_tests.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'tests/plugin_tests.py') diff --git a/tests/plugin_tests.py b/tests/plugin_tests.py index 6522fe14..9f03afa2 100644 --- a/tests/plugin_tests.py +++ b/tests/plugin_tests.py @@ -75,6 +75,18 @@ class NamedMockPlugin(Plugin): pass +class PostprocMockPlugin(Plugin): + + did_postproc = False + + def setup(self): + pass + + def postproc(self): + if self.get_option('postproc'): + self.did_postproc = True + + class ForbiddenMockPlugin(Plugin): """This plugin has a description.""" @@ -97,6 +109,7 @@ class MockOptions(object): since = None log_size = 25 allow_system_changes = False + no_postproc = False class PluginToolTests(unittest.TestCase): @@ -239,6 +252,15 @@ class PluginTests(unittest.TestCase): p.collect() self.assertEquals(p.archive.m, {}) + def test_postproc_default_on(self): + p = PostprocMockPlugin({ + 'cmdlineopts': MockOptions(), + 'sysroot': self.sysroot, + 'policy': LinuxPolicy() + }) + p.postproc() + self.assertTrue(p.did_postproc) + class AddCopySpecTests(unittest.TestCase): -- cgit