Skip to content

Commit

Permalink
✨ Completed Setupinator-based logging
Browse files Browse the repository at this point in the history
  • Loading branch information
mkarlesky committed Jun 20, 2024
1 parent 7dd8bb5 commit 7865b0f
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 36 deletions.
53 changes: 32 additions & 21 deletions lib/ceedling/configurator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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


Expand Down Expand Up @@ -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

Expand Down
10 changes: 4 additions & 6 deletions lib/ceedling/configurator_plugins.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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


Expand Down
4 changes: 4 additions & 0 deletions lib/ceedling/plugin_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
27 changes: 18 additions & 9 deletions lib/ceedling/setupinator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand All @@ -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' )
Expand All @@ -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' )
Expand All @@ -124,15 +133,15 @@ 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 )

@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
Expand All @@ -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 )

Expand Down

0 comments on commit 7865b0f

Please sign in to comment.