From 7865b0fcb3653fefdb1d7820a9ce097b0aee1399 Mon Sep 17 00:00:00 2001 From: Michael Karlesky Date: Wed, 19 Jun 2024 22:27:46 -0400 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Completed=20Setupinator-based=20log?= =?UTF-8?q?ging?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/ceedling/configurator.rb | 53 +++++++++++++++++----------- lib/ceedling/configurator_plugins.rb | 10 +++--- lib/ceedling/plugin_manager.rb | 4 +++ lib/ceedling/setupinator.rb | 27 +++++++++----- 4 files changed, 58 insertions(+), 36 deletions(-) diff --git a/lib/ceedling/configurator.rb b/lib/ceedling/configurator.rb index 82f93846..3f9bd5d8 100644 --- a/lib/ceedling/configurator.rb +++ b/lib/ceedling/configurator.rb @@ -320,14 +320,14 @@ def populate_tools_supplemental_arguments(config) end - def merge_plugins_config(paths_hash, plugins_load_path, config) - msg = @reportinator.generate_progress( 'Discovering plugins' ) + def discover_plugins(paths_hash, config) + msg = @reportinator.generate_progress( 'Discovering all plugins' ) @loginator.log( msg, Verbosity::OBNOXIOUS ) # Rake-based plugins @rake_plugins = @configurator_plugins.find_rake_plugins( config, paths_hash ) if !@configurator_plugins.rake_plugins.empty? - msg = " > Rake plugins: " + @configurator_plugins.rake_plugins.join( ', ' ) + msg = " > Rake plugins: " + @configurator_plugins.rake_plugins.map{|p| p[:plugin]}.join( ', ' ) @loginator.log( msg, Verbosity::DEBUG ) end @@ -341,35 +341,43 @@ def merge_plugins_config(paths_hash, plugins_load_path, config) # Config plugins config_plugins = @configurator_plugins.find_config_plugins( config, paths_hash ) if !@configurator_plugins.config_plugins.empty? - msg = " > Config plugins: " + @configurator_plugins.config_plugins.join( ', ' ) + msg = " > Config plugins: " + @configurator_plugins.config_plugins.map{|p| p[:plugin]}.join( ', ' ) @loginator.log( msg, Verbosity::DEBUG ) end - if !config_plugins.empty? - msg = @reportinator.generate_progress( 'Merging plugin configurations' ) - @loginator.log( msg, Verbosity::OBNOXIOUS ) - end + return config_plugins + end + + + def populate_plugins_config(paths_hash, config) + # Set special plugin setting for results printing if unset + config[:plugins][:display_raw_test_results] = true if (config[:plugins][:display_raw_test_results].nil?) + + # Add corresponding path to each plugin's configuration + paths_hash.each_pair { |name, path| config[:plugins][name] = path } + end + + + def merge_config_plugins(config) + return if @configurator_plugins.config_plugins.empty? # Merge plugin configuration values (like Ceedling project file) - config_plugins.each do |plugin| - plugin_config = @yaml_wrapper.load( plugin ) + @configurator_plugins.config_plugins.each do |hash| + _config = @yaml_wrapper.load( hash[:path] ) + + msg = @reportinator.generate_progress( "Merging configuration from plugin #{hash[:plugin]}" ) + @loginator.log( msg, Verbosity::OBNOXIOUS ) # Special handling for plugin paths - if (plugin_config.include?( :paths )) - plugin_config[:paths].update( plugin_config[:paths] ) do |k,v| + if (_config.include?( :paths )) + _config[:paths].update( _config[:paths] ) do |k,v| plugin_path = plugin.match( /(.*)[\/]config[\/]\w+\.yml/ )[1] v.map {|vv| File.expand_path( vv.gsub!( /\$PLUGIN_PATH/, plugin_path) ) } end end - config.deep_merge( plugin_config ) + config.deep_merge( _config ) end - - # Set special plugin setting for results printing if unset - config[:plugins][:display_raw_test_results] = true if (config[:plugins][:display_raw_test_results].nil?) - - # Add corresponding path to each plugin's configuration - paths_hash.each_pair { |name, path| config[:plugins][name] = path } end @@ -591,8 +599,11 @@ def build_supplement(config_base, config_more) def insert_rake_plugins(plugins) - plugins.each do |plugin| - @project_config_hash[:project_rakefile_component_files] << plugin + plugins.each do |hash| + msg = @reportinator.generate_progress( "Adding plugin #{hash[:plugin]} to Rake load list" ) + @loginator.log( msg, Verbosity::OBNOXIOUS ) + + @project_config_hash[:project_rakefile_component_files] << hash[:path] end end diff --git a/lib/ceedling/configurator_plugins.rb b/lib/ceedling/configurator_plugins.rb index 12620e0c..1af76400 100644 --- a/lib/ceedling/configurator_plugins.rb +++ b/lib/ceedling/configurator_plugins.rb @@ -78,13 +78,12 @@ def find_rake_plugins(config, plugin_paths) if path = plugin_paths[(plugin + '_path').to_sym] rake_plugin_path = File.join(path, "#{plugin}.rake") if @file_wrapper.exist?( rake_plugin_path ) - plugins_with_path << rake_plugin_path - @rake_plugins << plugin + @rake_plugins << {:plugin => plugin, :path => rake_plugin_path} end end end - return plugins_with_path + return @rake_plugins end @@ -116,13 +115,12 @@ def find_config_plugins(config, plugin_paths) config_plugin_path = File.join(path, "config", "#{plugin}.yml") if @file_wrapper.exist?( config_plugin_path ) - @config_plugins << plugin - plugins_with_path << config_plugin_path + @config_plugins << {:plugin => plugin, :path => config_plugin_path} end end end - return plugins_with_path + return @config_plugins end diff --git a/lib/ceedling/plugin_manager.rb b/lib/ceedling/plugin_manager.rb index 2bab9229..85a402c9 100644 --- a/lib/ceedling/plugin_manager.rb +++ b/lib/ceedling/plugin_manager.rb @@ -22,6 +22,10 @@ def load_programmatic_plugins(plugins, system_objects) plugins.each do |hash| # Protect against instantiating object multiple times due to processing config multiple times (option files, etc) next if (@plugin_manager_helper.include?( @plugin_objects, hash[:plugin] ) ) + + msg = @reportinator.generate_progress( "Instantiating plugin class #{camelize( hash[:plugin] )}" ) + @loginator.log( msg, Verbosity::OBNOXIOUS ) + begin @system_wrapper.require_file( "#{hash[:plugin]}.rb" ) object = @plugin_manager_helper.instantiate_plugin( diff --git a/lib/ceedling/setupinator.rb b/lib/ceedling/setupinator.rb index 909fa812..bdb0ad61 100644 --- a/lib/ceedling/setupinator.rb +++ b/lib/ceedling/setupinator.rb @@ -66,10 +66,10 @@ def do_setup( app_cfg ) @configurator.merge_ceedling_runtime_config( config_hash, CEEDLING_RUNTIME_CONFIG.deep_clone ) ## - ## 2. Handle core user configuration + ## 2. Handle basic configuration ## - log_step( 'Core Project Configuration Handling' ) + log_step( 'Project Configuration Handling' ) # Evaluate environment vars before plugin configurations that might reference with inline Ruby string expansion @configurator.eval_environment_variables( config_hash ) @@ -80,10 +80,19 @@ def do_setup( app_cfg ) # Populate CMock configuration with values to tie vendor tool configurations together @configurator.populate_cmock_config( config_hash ) - @configurator.merge_plugins_config( plugins_paths_hash, app_cfg[:ceedling_plugins_path], config_hash ) + ## + ## 3. Plugin Handling + ## + + log_step( 'Plugin Handling' ) + + # Plugin handling + @configurator.discover_plugins( plugins_paths_hash, config_hash ) + @configurator.populate_plugins_config( plugins_paths_hash, config_hash ) + @configurator.merge_config_plugins( config_hash ) ## - ## 3. Collect and apply defaults to user configuration + ## 4. Collect and apply defaults to user configuration ## log_step( 'Assembling Default Settings' ) @@ -98,7 +107,7 @@ def do_setup( app_cfg ) @configurator.populate_defaults( config_hash, defaults_hash ) ## - ## 4. Fill out / modify remaining configuration from user configuration + defaults + ## 5. Fill out / modify remaining configuration from user configuration + defaults ## log_step( 'Completing Project Configuration' ) @@ -124,7 +133,7 @@ def do_setup( app_cfg ) @test_runner_manager.configure_runtime_options( app_cfg[:include_test_case], app_cfg[:exclude_test_case] ) ## - ## 5. Validate configuration + ## 6. Validate configuration ## log_step( 'Validating final project configuration', heading:false ) @@ -132,7 +141,7 @@ def do_setup( app_cfg ) @configurator.validate_final( config_hash, app_cfg ) ## - ## 6. Flatten configuration + process it into globals and accessors + ## 7. Flatten configuration + process it into globals and accessors ## # Skip logging this step as the end user doesn't care about this internal preparation @@ -141,11 +150,11 @@ def do_setup( app_cfg ) @configurator.build( app_cfg[:ceedling_lib_path], config_hash, :environment ) ## - ## 7. Final plugins handling + ## 8. Final plugins handling ## # Detailed logging already happend for plugin processing - log_step( 'Loading plugins', heading:false ) + log_step( 'Loading Plugins' ) @configurator.insert_rake_plugins( @configurator.rake_plugins )