Skip to content

Commit

Permalink
Restore functionality of defines being passed to all test functions.
Browse files Browse the repository at this point in the history
Restore functionality of defines being auto-injected by unity utils when necessary.
  • Loading branch information
mvandervoord committed Dec 7, 2023
1 parent c5dffed commit 5759901
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 34 deletions.
3 changes: 0 additions & 3 deletions lib/ceedling/test_invoker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -363,9 +363,6 @@ def compile_test_component(tool:TOOLS_TEST_COMPILER, context:TEST_SYM, test:, so
filepath = testable[:filepath]
flags = testable[:compile_flags]

# Tailor defines--remove duplicates and reduce list to only those needed by vendor / support file compilation
defines = @helper.tailor_defines(defines:testable[:compile_defines], filepath:source)

# Tailor search path--remove duplicates and reduce list to only those needed by vendor / support file compilation
search_paths = @helper.tailor_search_paths(search_paths:testable[:search_paths], filepath:source)

Expand Down
37 changes: 8 additions & 29 deletions lib/ceedling/test_invoker_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ class TestInvokerHelper
:file_finder,
:file_path_utils,
:file_wrapper,
:generator
:generator,
:unity_utils

def setup
# Alias for brevity
Expand Down Expand Up @@ -63,41 +64,19 @@ def compile_defines(context:, filepath:)
defines = @defineinator.generate_test_definition( filepath:filepath )
defines += @defineinator.defines( subkey:context, filepath:filepath )

# Defines for the test file
return defines
end

def tailor_defines(filepath:, defines:)
_defines = []

# Unity defines
if filepath == File.join(PROJECT_BUILD_VENDOR_UNITY_PATH, UNITY_C_FILE)
_defines += @defineinator.defines( topkey:UNITY_SYM, subkey: :defines )
defines += @defineinator.defines( topkey:UNITY_SYM, subkey: :defines )

# CMock defines
elsif @configurator.project_use_mocks and
(filepath == File.join(PROJECT_BUILD_VENDOR_CMOCK_PATH, CMOCK_C_FILE))
_defines += @defineinator.defines( topkey:CMOCK_SYM, subkey: :defines )
defines += @defineinator.defines( topkey:CMOCK_SYM, subkey: :defines )

# CException defines
elsif @configurator.project_use_exceptions and
(filepath == File.join(PROJECT_BUILD_VENDOR_CEXCEPTION_PATH, CEXCEPTION_C_FILE))
_defines += @defineinator.defines( topkey:CEXCEPTION_SYM, subkey: :defines )
defines += @defineinator.defines( topkey:CEXCEPTION_SYM, subkey: :defines )

# Support files defines
elsif (@configurator.collection_all_support.include?(filepath))
_defines = defines
_defines += @defineinator.defines( topkey:UNITY_SYM, subkey: :defines )
_defines += @defineinator.defines( topkey:CMOCK_SYM, subkey: :defines ) if @configurator.project_use_mocks
_defines += @defineinator.defines( topkey:CEXCEPTION_SYM, subkey: :defines ) if @configurator.project_use_exceptions
end

# Not a vendor file, return original defines
if _defines.length == 0
return defines
end
# Injected defines (based on other settings)
defines += unity_utils.update_defines_if_args_enables

return _defines.uniq
return defines.uniq
end

def tailor_search_paths(filepath:, search_paths:)
Expand Down
4 changes: 2 additions & 2 deletions lib/ceedling/unity_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ def create_test_runner_additional_args
# compile unity with enabled cmd line arguments
#
# @return [Array] - empty if cmdline_args is not set
def self.update_defines_if_args_enables(in_hash)
in_hash[:test_runner_cmdline_args] ? ['UNITY_USE_COMMAND_LINE_ARGS'] : []
def self.update_defines_if_args_enables()
@configurator.project_config_hash[:test_runner_cmdline_args] ? ['UNITY_USE_COMMAND_LINE_ARGS'] : []
end

# Print on output console warning about lack of support for single test run
Expand Down

0 comments on commit 5759901

Please sign in to comment.