Repository navigation
Conversation
CMock names a mock's include guard and its Init, Verify and Destroy functions by the mock's filename alone. Two mocks sharing a filename in different folders therefore share a guard and define the same symbols. With :mock_name_include_folder enabled the generator folds the folder a mock is generated into below :mock_path into that name, so a mock of config.h in uart/ becomes uart_Mockconfig. The option defaults to off and leaves existing mocks unchanged. Unity's test runner generator gains a matching option, and vendor/unity moves to that commit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 8, 2026
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.
Two mocks of the same filename cannot coexist in one test. CMock derives a mock's include guard and its
Init(),Verify(), andDestroy()function names from the mock's filename alone. For example, mocks ofuart/config.handspi/config.hshare the include guard_MOCKCONFIG_Hcausing the second header to compile as empty. Both also defineMockconfig_Init()and its siblings, which collide at link. This PR adds an opt-in option that folds the mock's folder into that name.Behavior
With
:mock_name_include_folderenabled, a mock's name includes the folder it is generated into below:mock_path. That folder is built from:subdirand any folder passed tosetup_mocks, exactly as the existing placement logic increate_mockbuilds it. A mock ofconfig.hgenerated intouart/gets the guard_UART_MOCKCONFIG_Hand functions nameduart_Mockconfig_Init()and so on. A mock with no folder keeps its current name, and a leading./is ignored.The option defaults to off, and mocks generated without it are unchanged. Unity's runner generator needs its option of the same name to call the renamed functions. A test should include such a mock by the same folder, which is the path the runner generator sees.
Changes
lib/cmock_config.rb::mock_name_include_folder => falseinCMOCK_DEFAULT_OPTIONS.lib/cmock_generator.rb:initializereads the option once. When it is on and a folder is present,create_mockcomputes:clean_namefrom the folder plus the mock name. Guard and lifecycle names already derive from:clean_name.docs/CMock_Summary.md: new:mock_name_include_folderentry.test/unit/cmock_generator_main_test.rb: covers the default, the option on with a folder (including a./prefix), and the option on without a folder. Both generator fixtures gain the new config expectation.vendor/unity: moves to the Unity companion PR's commit so both tools carry the matching option. That commit descends from the previous pin.Related
vendor/unitymoves to the merged commit.