Skip to content

Commit

Permalink
Merge branch 'test/flags_defines_string_replacement' into test/ceedli…
Browse files Browse the repository at this point in the history
…ng_0_32_rc
  • Loading branch information
mkarlesky committed May 23, 2024
2 parents 4b2dbd3 + 5d68f3d commit d5e2776
Show file tree
Hide file tree
Showing 8 changed files with 209 additions and 110 deletions.
1 change: 1 addition & 0 deletions bin/objects.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ projectinator:
- path_validator
- yaml_wrapper
- loginator
- system_wrapper

configinator:
compose:
Expand Down
13 changes: 11 additions & 2 deletions bin/projectinator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Projectinator
DEFAULT_PROJECT_FILEPATH = './' + DEFAULT_PROJECT_FILENAME
DEFAULT_YAML_FILE_EXTENSION = '.yml'

constructor :file_wrapper, :path_validator, :yaml_wrapper, :loginator
constructor :file_wrapper, :path_validator, :yaml_wrapper, :loginator, :system_wrapper

# Discovers project file path and loads configuration.
# Precendence of attempts:
Expand Down Expand Up @@ -102,6 +102,15 @@ def extract_mixins(config:)
enabled = _mixins[:enabled] || []
enabled = enabled.clone # Ensure it's a copy of configuration section

# Handle any inline Ruby string expansion
load_paths.each do |load_path|
load_path.replace( @system_wrapper.module_eval( load_path ) ) if (load_path =~ RUBY_STRING_REPLACEMENT_PATTERN)
end

enabled.each do |mixin|
mixin.replace( @system_wrapper.module_eval( mixin ) ) if (mixin =~ RUBY_STRING_REPLACEMENT_PATTERN)
end

# Remove the :mixins section of the configuration
config.delete( :mixins )

Expand All @@ -113,7 +122,7 @@ def extract_mixins(config:)
def validate_mixin_load_paths(load_paths)
validated = @path_validator.validate(
paths: load_paths,
source: 'Config :mixins ↳ :load_paths',
source: 'Config :mixins ↳ :load_paths =>',
type: :directory
)

Expand Down
2 changes: 1 addition & 1 deletion docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ Not all Pull Requests require these things, but here's a great list of things to

## :heart: Who Loves Emoji?

Commit comments, Issues, Feature Requests... they can all use a little sprucing up, right? Consider using the following emoji for a mix of function and :sparkles: dazzle!
Commit comments, Issues, Feature Requests... they can all use a little sprucing up, right? Consider using the following emoji for a mix of function and :sparkles: dazzle! We encourage loosely following the conventions of [gitmoji](https://gitmoji.dev) for contributing to Ceedling.

- actions
- :seedling: `:seedling:` (or other plants) when growing new features. Choose your fav! :cactus: :herb: :evergreen_tree: :palm_tree: :deciduous_tree: :blossom:
Expand Down
247 changes: 145 additions & 102 deletions docs/CeedlingPacket.md

Large diffs are not rendered by default.

10 changes: 8 additions & 2 deletions docs/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This changelog is complemented by two other documents:

---

# [1.0.0 pre-release] — 2024-05-17
# [1.0.0 pre-release] — 2024-05-23

## 🌟 Added

Expand Down Expand Up @@ -83,6 +83,12 @@ Each test executable is now built as a mini project. Using improved `:defines` h

One powerful new feature is the ability to test the same source file built differently for different tests. Imagine a source file has three different conditional compilation sections. You can now write unit tests for each of those sections without complicated gymnastics to cause your test suite to build and run properly.

### Inline Ruby string expansion for `:flags` and `:defines` configuration entries

Inline Ruby string expansion has been, well, expanded for use in `:flags` and `:defines` entries to complement existing such functionality in `:environment`, `:paths`, `:tools`, etc.

The previously distributed documentation for inline Ruby string expansion has been collected into a single subsection within the project file documentation and improved.

### `report_tests_log_factory` plugin

This new plugin consolidates a handful of previously discrete report gernation plugins into a single plugin that also enables low-code, custom, end-user created reports.
Expand All @@ -105,7 +111,7 @@ Segmentation faults are now reported as failures instead of an error with as muc

### Pretty logging output

Ceedling logging now optionally includes emoji and nice Unicode characters . Ceedling will attempt to determine if your platform supports it. You can use an environment variable `CEEDLING_DECORATORS` or your project configuration `:project``:use_decorators` to force the feature on or off.
Ceedling logging now optionally includes emoji and nice Unicode characters. Ceedling will attempt to determine if your platform supports it. You can use the environment variable `CEEDLING_DECORATORS` to force the feature on or off. See the documentation for logging decorators in _[CeedlingPacket](CeedlingPacket.md)_.

## 💪 Fixed

Expand Down
6 changes: 3 additions & 3 deletions docs/ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ These release notes are complemented by two other documents:

---

# 1.0.0 pre-release — May 17, 2024
# 1.0.0 pre-release — May 23, 2024

## 🏴‍☠️ Avast, Breaking Changes, Ye Scallywags!

Expand Down Expand Up @@ -115,8 +115,8 @@ There’s more to be done, but Ceedling’s documentation is more complete and a
- The historically unwieldy `verbosity` command line task now comes in two flavors. The original recipe numeric parameterized version (e.g. `[4]`) exist as is. The new extra crispy recipe includes — funny enough — verbose task names `verbosity:silent`, `verbosity:errors`, `verbosity:complain`, `verbosity:normal`, `verbosity:obnoxious`, `verbosity:debug`.
- This release marks the beginning of the end for Rake as a backbone of Ceedling. Over many years it has become clear that Rake’s design assumptions hamper building the sorts of features Ceedling’s users want, Rake’s command line structure creates a messy user experience for a full application built around it, and Rake’s quirks cause maintenance challenges. Particularly for test suites, much of Ceedling’s (invisible) dependence on Rake has been removed in this release. Much more remains to be done, including replicating some of the abilities Rake offers.
- This is the first ever release of Ceedling with proper release notes. Hello, there! Release notes will be a regular part of future Ceedling updates. If you haven't noticed already, this edition of the notes are detailed and quite lengthy. This is entirely due to how extensive the changes are in the 1.0.0 release. Future releases will have far shorter notes.
- The `fake_function_framework` plugin has been renamed simply `fff`
- Optional output decorators have been added for your output stream enjoyment (see `:use_decorators`)
- The `fake_function_framework` plugin has been renamed simply `fff`.
- Optional Unicode and emoji decorators have been added for your output stream enjoyment. See the documentation for logging decorators in _[CeedlingPacket](CeedlingPacket.md)_.

## 🚨 Important Changes in Behavior to Be Aware Of

Expand Down
37 changes: 37 additions & 0 deletions lib/ceedling/configurator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,20 @@ def eval_paths(config)
end


# Handle any Ruby string replacement for :flags string arrays
def eval_flags(config)
# Descend down to array of command line flags strings regardless of depth in config block
traverse_hash_eval_string_arrays( config[:flags] )
end


# Handle any Ruby string replacement for :defines string arrays
def eval_defines(config)
# Descend down to array of #define strings regardless of depth in config block
traverse_hash_eval_string_arrays( config[:defines] )
end


def standardize_paths(config)
# Individual paths that don't follow `_path` convention processed here
paths = [
Expand Down Expand Up @@ -486,6 +500,7 @@ def reform_path_entries_as_lists( container, entry, value )
container[entry] = [value] if value.kind_of?( String )
end


def collect_path_list( container )
paths = []

Expand All @@ -498,6 +513,7 @@ def collect_path_list( container )
return paths.flatten()
end


def eval_path_entries( container )
paths = []

Expand All @@ -513,5 +529,26 @@ def eval_path_entries( container )
end
end


# Traverse configuration tree recursively to find terminal leaf nodes that are a list of strings;
# expand in place any string with the Ruby string replacement pattern.
def traverse_hash_eval_string_arrays(config)
case config

when Array
# If it's an array of strings, process it
if config.all? { |item| item.is_a?( String ) }
# Expand in place each string item in the array
config.each do |item|
item.replace( @system_wrapper.module_eval( item ) ) if (item =~ RUBY_STRING_REPLACEMENT_PATTERN)
end
end

when Hash
# Recurse
config.each_value { |value| traverse_hash_eval_string_arrays( value ) }
end
end

end

3 changes: 3 additions & 0 deletions lib/ceedling/setupinator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,11 @@ def do_setup( app_cfg )
@ceedling[:configurator].populate_unity_defaults( config_hash )
@ceedling[:configurator].populate_cmock_defaults( config_hash )
@ceedling[:configurator].configure_test_runner_generation( config_hash )
# Evaluate environment vars before sections that might reference them with inline Ruby string expansion
@ceedling[:configurator].eval_environment_variables( config_hash )
@ceedling[:configurator].eval_paths( config_hash )
@ceedling[:configurator].eval_flags( config_hash )
@ceedling[:configurator].eval_defines( config_hash )
@ceedling[:configurator].standardize_paths( config_hash )
@ceedling[:configurator].find_and_merge_plugins( app_cfg[:ceedling_plugins_path], config_hash )
@ceedling[:configurator].tools_setup( config_hash )
Expand Down

0 comments on commit d5e2776

Please sign in to comment.