From bcd237f5ea2fdfd0d77ac9ad2aa090c981df83c1 Mon Sep 17 00:00:00 2001 From: Mike Karlesky Date: Wed, 3 Jan 2024 10:24:43 -0500 Subject: [PATCH] Added logging to plugin execution MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - plugin_manager now logs plugin activity for plugins with defined event handlers - Removed plugin base class’s event handler methods as they erroneously and unnecessarily caused each plugin to define (blank) handlers for every event --- lib/ceedling/plugin.rb | 40 ---------------------------------- lib/ceedling/plugin_manager.rb | 17 ++++++++++++++- 2 files changed, 16 insertions(+), 41 deletions(-) diff --git a/lib/ceedling/plugin.rb b/lib/ceedling/plugin.rb index 26e8a09d..c2988770 100644 --- a/lib/ceedling/plugin.rb +++ b/lib/ceedling/plugin.rb @@ -42,46 +42,6 @@ def initialize(system_objects, name) end def setup; end - - # Preprocessing (before / after each and every header file preprocessing operation before mocking) - def pre_mock_preprocess(arg_hash); end - def post_mock_preprocess(arg_hash); end - - # Preprocessing (before / after each and every test preprocessing operation before runner generation) - def pre_test_preprocess(arg_hash); end - def post_test_preprocess(arg_hash); end - - # Mock generation (before / after each and every mock) - def pre_mock_generate(arg_hash); end - def post_mock_generate(arg_hash); end - - # Test runner generation (before / after each and every test runner) - def pre_runner_generate(arg_hash); end - def post_runner_generate(arg_hash); end - - # Compilation (before / after each and test or source file compilation) - def pre_compile_execute(arg_hash); end - def post_compile_execute(arg_hash); end - - # Linking (before / after each and every test executable or release artifact) - def pre_link_execute(arg_hash); end - def post_link_execute(arg_hash); end - - # Test fixture execution (before / after each and every test fixture executable) - def pre_test_fixture_execute(arg_hash); end - def post_test_fixture_execute(arg_hash); end - - # Test task (before / after each test executable build) - def pre_test(test); end - def post_test(test); end - - # Release task (before / after a release build) - def pre_release; end - def post_release; end - - # Whole shebang (any use of Ceedling) - def pre_build; end - def post_build; end def summary; end diff --git a/lib/ceedling/plugin_manager.rb b/lib/ceedling/plugin_manager.rb index 3aa42681..513fcbcf 100644 --- a/lib/ceedling/plugin_manager.rb +++ b/lib/ceedling/plugin_manager.rb @@ -100,9 +100,24 @@ def camelize(underscored_name) end def execute_plugins(method, *args) + handlers = 0 + + @plugin_objects.each do |plugin| + handlers += 1 if plugin.respond_to?(method) + end + + if handlers > 0 + heading = @reportinator.generate_heading( "Plugins (#{handlers}) > :#{method}" ) + @streaminator.stdout_puts(heading, Verbosity::OBNOXIOUS) + end + @plugin_objects.each do |plugin| begin - plugin.send(method, *args) if plugin.respond_to?(method) + if plugin.respond_to?(method) + message = @reportinator.generate_progress( " + #{plugin.name}" ) + @streaminator.stdout_puts(message, Verbosity::OBNOXIOUS) + plugin.send(method, *args) + end rescue @streaminator.stderr_puts("Exception raised in plugin: #{plugin.name}, in method #{method}") raise