Skip to content

Commit

Permalink
Fix for issue #780
Browse files Browse the repository at this point in the history
Ceedling could not handle test filenames that included dashes, specifically when those filenames became key names in the `:defines:` section of the project file. All other aspects of a dashed filename for source or test C files appears to work without issue.

The issue was in the automated creation of the internal configurator object’s accessor methods. In the case of `:defines:` entries, key names became Ruby method names. Dashes are illegal in Ruby method names. The fix was simply to replace any dashes with underscores in generated Ruby method names inserted into configurator.

Given the limits on allowed C filename characters, Ruby method names, and practical conventions, dashes _should_ be the only complicating character in filenames.
  • Loading branch information
mkarlesky committed Jul 21, 2023
1 parent 4edd567 commit d3c0bff
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/ceedling/configurator_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,12 @@ def build_global_constants(config)


def build_accessor_methods(config, context)
# Fill configurator object with accessor methods
config.each_pair do |key, value|
# fill configurator object with accessor methods
eval("def #{key.to_s.downcase}() return @project_config_hash[:#{key}] end", context)
# Convert key names to Ruby method names
# Some key names can be C file names that can include dashes; dashes are not allowed in Ruby method names
# Downcase the key names for consistency and replace any illegal dashes with legal underscores
eval("def #{key.to_s.gsub('-','_').downcase}() return @project_config_hash[:#{key}] end", context)
end
end

Expand Down

0 comments on commit d3c0bff

Please sign in to comment.