From ee00c881690c83665159623409be41c43d475339 Mon Sep 17 00:00:00 2001 From: Mike Karlesky Date: Sat, 18 May 2024 14:39:20 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fixed=20test=20runner=20generati?= =?UTF-8?q?on=20cmdline=20args?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Clarified how runner generation configuration is assembled during startup - Ensured automatic test runner generation cmdline args setting from other features occurs before it gets cloned --- lib/ceedling/configurator.rb | 42 +++++++++++++++++++++++++----------- lib/ceedling/generator.rb | 2 +- lib/ceedling/setupinator.rb | 1 + lib/ceedling/unity_utils.rb | 2 +- 4 files changed, 32 insertions(+), 15 deletions(-) diff --git a/lib/ceedling/configurator.rb b/lib/ceedling/configurator.rb index 6765e4e3..267f2bee 100644 --- a/lib/ceedling/configurator.rb +++ b/lib/ceedling/configurator.rb @@ -104,18 +104,21 @@ def populate_defaults(config) def populate_unity_defaults(config) - unity = config[:unity] || {} - @runner_config = unity.merge(config[:test_runner] || {}) + # Do nothing end + def populate_cmock_defaults(config) - # cmock has its own internal defaults handling, but we need to set these specific values + # Cmock has its own internal defaults handling, but we need to set these specific values # 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 + # Note: These need to end up in the hash given to initialize cmock for this to be successful cmock = config[:cmock] || {} - # yes, we're duplicating the default mock_prefix in cmock, but it's because we need CMOCK_MOCK_PREFIX always available in Ceedling's environment + # Yes, we're duplicating the defaults in CMock, but it's because: + # (A) We always need CMOCK_MOCK_PREFIX in Ceedling's environment + # (B) Test runner generator uses these same configuration values cmock[:mock_prefix] = 'Mock' if (cmock[:mock_prefix].nil?) + cmock[:mock_suffix] = '' if (cmock[:mock_suffix].nil?) # just because strict ordering is the way to go cmock[:enforce_strict_ordering] = true if (cmock[:enforce_strict_ordering].nil?) @@ -137,18 +140,37 @@ def populate_cmock_defaults(config) cmock[:includes].uniq! end - @runner_config = cmock.merge(@runner_config || config[:test_runner] || {}) - @cmock_config = cmock end + def configure_test_runner_generation(config) + use_backtrace = config[:project][:use_backtrace] + + # TODO: Potentially update once :gdb and :simple are disentangled + if (use_backtrace == :gdb) or (use_backtrace == :simple) + config[:test_runner][:cmdline_args] = true + end + + # Copy CMock options needed by test runner generation + config[:test_runner][:mock_prefix] = config[:cmock][:mock_prefix] + config[:test_runner][:mock_suffix] = config[:cmock][:mock_suffix] + config[:test_runner][:enforce_strict_ordering] = config[:cmock][:enforce_strict_ordering] + + @runner_config = config[:test_runner] + 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. return @runner_config.clone end def get_cmock_config + # Clone because test mock generation is not thread-safe; + # The mock generator is manufactured for each use with configuration changes for each use. return @cmock_config.clone end @@ -181,12 +203,6 @@ def tools_setup(config) # Populate optional option to control verification of executable in search paths tool[:optional] = false if (tool[:optional].nil?) end - - use_backtrace = config[:project][:use_backtrace] - # TODO: Remove :gdb once it and :simple are disentangled - if (use_backtrace == :gdb) or (use_backtrace == :simple) - config[:test_runner][:cmdline_args] = true - end end diff --git a/lib/ceedling/generator.rb b/lib/ceedling/generator.rb index 2c672a2c..5c686718 100644 --- a/lib/ceedling/generator.rb +++ b/lib/ceedling/generator.rb @@ -320,7 +320,7 @@ def generate_test_results(tool:, context:, test_name:, test_filepath:, executabl shell_result = @backtrace.gdb_output_collector( shell_result ) when :simple # TODO: Identify problematic test just from iterating with test case filters - else + else # :none # Otherwise, call a crash a single failure so it shows up in the report shell_result = @generator_test_results.create_crash_failure( executable, shell_result ) end diff --git a/lib/ceedling/setupinator.rb b/lib/ceedling/setupinator.rb index aaf02d8f..31af7330 100644 --- a/lib/ceedling/setupinator.rb +++ b/lib/ceedling/setupinator.rb @@ -39,6 +39,7 @@ def do_setup( app_cfg ) @ceedling[:configurator].populate_defaults( config_hash ) @ceedling[:configurator].populate_unity_defaults( config_hash ) @ceedling[:configurator].populate_cmock_defaults( config_hash ) + @ceedling[:configurator].configure_test_runner_generation( config_hash ) @ceedling[:configurator].eval_environment_variables( config_hash ) @ceedling[:configurator].eval_paths( config_hash ) @ceedling[:configurator].standardize_paths( config_hash ) diff --git a/lib/ceedling/unity_utils.rb b/lib/ceedling/unity_utils.rb index 224fa523..ac264bb1 100644 --- a/lib/ceedling/unity_utils.rb +++ b/lib/ceedling/unity_utils.rb @@ -19,7 +19,7 @@ def setup @test_case_excl = '' @test_runner_defines = [] - # Refering to Unity implementation of the parser implemented in the unit.c : + # Refering to Unity implementation of the parser implemented in the unity.c : # # case 'l': /* list tests */ # case 'f': /* filter tests with name including this string */