diff --git a/lib/ceedling/configurator.rb b/lib/ceedling/configurator.rb index 2feb91ba..587d7670 100644 --- a/lib/ceedling/configurator.rb +++ b/lib/ceedling/configurator.rb @@ -108,8 +108,6 @@ def populate_cmock_defaults(config, default_config) # so they're present for the build environment to access; # Note: these need to end up in the hash given to initialize cmock for this to be successful - return if !config[:project][:use_mocks] - msg = @reportinator.generate_progress( 'Collecting CMock defaults' ) @loginator.log( msg, Verbosity::OBNOXIOUS ) @@ -197,7 +195,7 @@ def populate_cmock_config(config) msg = @reportinator.generate_progress( 'Processing CMock configuration' ) @loginator.log( msg, Verbosity::OBNOXIOUS ) - cmock[:plugins] = [] if (cmock[:plugins].nil?) + # Plugins housekeeping cmock[:plugins].map! { |plugin| plugin.to_sym() } cmock[:plugins].uniq! @@ -241,10 +239,23 @@ def populate_test_runner_generation_config(config) # Merge Unity options used by test runner generation config[:test_runner][:defines] += config[:unity][:defines] + @loginator.log( "Test runner configuration: #{config[:test_runner]}", Verbosity::DEBUG ) + @runner_config = config[:test_runner] end + def populate_exceptions_config(config) + # Automagically set exception handling if CMock is configured for it + if config[:cmock][:plugins] && config[:cmock][:plugins].include?(:cexception) + msg = @reportinator.generate_progress( 'Enabling CException use based on CMock plugins settings' ) + @loginator.log( msg, Verbosity::OBNOXIOUS ) + + config[:project][:use_exceptions] = true + end + end + + def get_runner_config # Clone because test runner generation is not thread-safe; # The runner generator is manufactured for each use with configuration changes for each use. diff --git a/lib/ceedling/configurator_builder.rb b/lib/ceedling/configurator_builder.rb index af2ef49b..006dbcbc 100644 --- a/lib/ceedling/configurator_builder.rb +++ b/lib/ceedling/configurator_builder.rb @@ -60,7 +60,7 @@ def flattenify(config) config.each_key do | parent | - # gracefully handle empty top-level entries + # Gracefully handle empty top-level entries next if (config[parent].nil?) case config[parent] @@ -69,12 +69,14 @@ def flattenify(config) key = "#{parent.to_s.downcase}_#{hash.keys[0].to_s.downcase}".to_sym new_hash[key] = hash[hash.keys[0]] end + when Hash config[parent].each_pair do | child, value | key = "#{parent.to_s.downcase}_#{child.to_s.downcase}".to_sym new_hash[key] = value end - # handle entries with no children, only values + + # Handle entries with no children, only values else new_hash["#{parent.to_s.downcase}".to_sym] = config[parent] end @@ -103,26 +105,11 @@ def populate_defaults(config, defaults) def cleanup(in_hash) - # ensure that include files inserted into test runners have file extensions & proper ones at that + # Ensure that include files inserted into test runners have file extensions & proper ones at that in_hash[:test_runner_includes].map!{|include| include.ext(in_hash[:extension_header])} end - def set_exception_handling(in_hash) - # If project defines exception handling, do not change the setting. - # But, if the project omits exception handling setting... - if not in_hash[:project_use_exceptions] - # Automagically set it if cmock is configured for it - if in_hash[:cmock_plugins] && in_hash[:cmock_plugins].include?(:cexception) - in_hash[:project_use_exceptions] = true - # Otherwise, disable exceptions for the project - else - in_hash[:project_use_exceptions] = false - end - end - end - - def set_build_paths(in_hash) out_hash = {} @@ -161,7 +148,7 @@ def set_build_paths(in_hash) out_hash[:project_build_paths] = [] - # fetch already set mock path + # Fetch already set mock path out_hash[:project_build_paths] << in_hash[:cmock_mock_path] if (in_hash[:project_use_mocks]) paths.each do |path| @@ -169,9 +156,9 @@ def set_build_paths(in_hash) build_path = path[1] build_path_add_condition = path[2] - # insert path into build paths if associated with true condition + # Insert path into build paths if associated with true condition out_hash[:project_build_paths] << build_path if build_path_add_condition - # set path symbol name and path for each entry in paths array + # Set path symbol name and path for each entry in paths array out_hash[build_path_name] = build_path end diff --git a/lib/ceedling/configurator_setup.rb b/lib/ceedling/configurator_setup.rb index 7ed7ef9f..67a53874 100644 --- a/lib/ceedling/configurator_setup.rb +++ b/lib/ceedling/configurator_setup.rb @@ -6,6 +6,7 @@ # ========================================================================= require 'ceedling/constants' +require 'ceedling/exceptions' # Add sort-ability to symbol so we can order keys array in hash for test-ability class Symbol @@ -30,11 +31,10 @@ def inspect end def build_project_config(ceedling_lib_path, flattened_config) - ### flesh out config + # Housekeeping @configurator_builder.cleanup( flattened_config ) - @configurator_builder.set_exception_handling( flattened_config ) - ### add to hash values we build up from configuration & file system contents + # Add to hash values we build up from configuration & file system contents flattened_config.merge!( @configurator_builder.set_build_paths( flattened_config ) ) flattened_config.merge!( @configurator_builder.set_rakefile_components( ceedling_lib_path, flattened_config ) ) flattened_config.merge!( @configurator_builder.set_release_target( flattened_config ) ) @@ -44,7 +44,17 @@ def build_project_config(ceedling_lib_path, flattened_config) end def build_directory_structure(flattened_config) + msg = "Build paths:" flattened_config[:project_build_paths].each do |path| + msg += "\n - #{(path.nil? or path.empty?) ? '' : path}" + end + @loginator.log( msg, Verbosity::DEBUG ) + + flattened_config[:project_build_paths].each do |path| + if path.nil? or path.empty? + raise CeedlingException.new( "Blank internal project build path subdirectory value" ) + end + @file_wrapper.mkdir( path ) end end diff --git a/lib/ceedling/setupinator.rb b/lib/ceedling/setupinator.rb index bdb0ad61..850f8f1b 100644 --- a/lib/ceedling/setupinator.rb +++ b/lib/ceedling/setupinator.rb @@ -88,8 +88,8 @@ def do_setup( app_cfg ) # 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 ) + @configurator.populate_plugins_config( plugins_paths_hash, config_hash ) ## ## 4. Collect and apply defaults to user configuration @@ -115,6 +115,9 @@ def do_setup( app_cfg ) # Configure test runner generation @configurator.populate_test_runner_generation_config( config_hash ) + # Automagically enable use of exceptions based on CMock settings + @configurator.populate_exceptions_config( config_hash ) + # Evaluate environment vars again before subsequent configurations that might reference with inline Ruby string expansion @configurator.eval_environment_variables( config_hash )