Repository navigation
Mock same-named headers by directory - #1326
Merged
Merged
Conversation
This was referenced Oct 8, 2026
A test mocking two headers that share a basename, each named by its directory, is the traditional-mock counterpart of the pending Partial example. It stays pending until CMock and Unity can name a mock by the folder its #include names. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CMock and Unity's runner generator name a mock's include guard and lifecycle functions by its filename alone, so two same-named mocks in one test collide. With :cmock -> :mock_name_include_folder both tools fold the directory a test's #include names into that identity instead. Ceedling enables the option by default and mirrors it into :test_runner. Each mock records its #include as written, and stage_generate_mocks hands that directory to CMock as its folder. The mock keeps its mirrored location whenever the folder ends it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Generator#generate_mock roots CMock above the folder, hands it the folder, and reports the mock's own directory to plugins. A leading ./ is dropped from the folder, as the runner drops it. PIPELINE.md describes the naming and placement. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mkarlesky
force-pushed
the
feature/same-named-mocks
branch
from
October 17, 2026 22:12
df8c1d8 to
040f875
Compare
mkarlesky
marked this pull request as ready for review
October 17, 2026 22:12
Ceedling now hands the mock generator the folder each mock's #include names, and the runner names its lifecycle calls by that folder. The FFF plugin's stand-in for CMock took no folder, so mock generation failed. It now takes the folder, writes the fake below its root at that folder, and names the fake's guard and control functions as CMock does under :mock_name_include_folder, so the runner's calls link. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A test can name two same-named headers by directory, but it could not mock both. CMock and Unity's runner named a mock by filename alone, so the two mocks shared an include guard and lifecycle symbols. That affected traditional mocks and
MOCK_PARTIAL_PUBLIC_MODULE_ATPartials alike.ThrowTheSwitch/Unity#854 and ThrowTheSwitch/CMock#540 add
:mock_name_include_folderto both tools.next_versionalready pins their merge commits (2eece702), so this PR changes no submodule. It enables the option and hands CMock the folder each mock's#includenames. It also carries #1325's pending example, which now passes.Behavior
The new
:cmock↳:mock_name_include_foldersetting defaults totruein Ceedling and is mirrored into:test_runner, like:mock_prefixand:mock_suffix. A mock included asdrivers/uart/mock_config.hgets the guard and lifecycle functionsdrivers_uart_mock_config, and the runner calls those same names. A bare#include "mock_config.h", or one with a leading./only, keeps its current name.The folder is the
#includeas written, not the mock's mirrored location, because the runner sees only the#include.#includethat spells part of the real header's path.#includespelling more path than the mirror holds places its mock below the per-test mock root at the written path, which the root search path still reaches.The CMock configuration, with the new option, is part of each mock's cache meta, so toggling it regenerates mocks.
Changes
MockDetails: gainsinclude_path, the#includeas the test wrote it (test_invoker_types.rb,test_build_planner.rb).TestBuildExecutor#mock_folder_and_path: derives CMock's folder and the mock's directory.stage_generate_mockspasses both togenerate_mock.Generator#generate_mock(folder:): roots CMock above the folder and passes the folder tosetup_mocks. Plugin hooks still receive the mock's own directory as:output_path.defaults.rb, andRUNNER_CMOCK_OPTIONSinconfigurator.rb.NAMING, after99a87b94removed the bumpy/camel swap that Unity#855 made unnecessary.PIPELINE.md: describes the naming and placement.Tests
#include, a folder that ends the mirror, a leading./, a deeper written path, and the option off;generate_mockroots CMock above the folder, passes the folder, and reports the mock's own directory to plugins;:test_runner;MockDetails#include_path.partials_module_disambiguation_spec.rbnow pass.same_named_modules,partials_module_disambiguation,header_include_path_validation,conditional_mock_includes,delta_builds,plugin_delta_builds,mocks_partials_configuration_validation.rake lintis clean across 503 files. The backlog is unchanged at 835 and lists no new file.Changelog, Known Issues, Breaking Changes and mkdocs edits will follow as uncommitted diffs after CI.
🤖 Generated with Claude Code