Skip to content

Commit

Permalink
🐛 Fixed test runner generation cmdline args
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
mkarlesky committed May 18, 2024
1 parent e74d45c commit ee00c88
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 15 deletions.
42 changes: 29 additions & 13 deletions lib/ceedling/configurator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?)
Expand All @@ -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

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


Expand Down
2 changes: 1 addition & 1 deletion lib/ceedling/generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions lib/ceedling/setupinator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down
2 changes: 1 addition & 1 deletion lib/ceedling/unity_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit ee00c88

Please sign in to comment.