Repository navigation
Conversation
The runner names each mock's Init, Verify and Destroy calls by the mock's filename alone. Two mocks sharing a filename in different folders therefore collapse to the same calls. With :mock_name_include_folder enabled the runner keeps the folder a mock is included from, so uart/MockConfig.h yields uart_MockConfig_Init(). CMock gains a matching option that names its generated functions the same way. The option defaults to off and leaves existing runners unchanged. 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.
A test cannot use two mocks that share a filename. The runner names each mock's
Init(),Verify(), andDestroy()calls by the filename alone. For instance,uart/MockConfig.handspi/MockConfig.hboth produceMockConfig_Init(). This PR adds an opt-in option that keeps the folder a mock is included from. A companion CMock PR adds the matching option on the generator side.Behavior
With
:mock_name_include_folderenabled,#include "uart/MockConfig.h"yields calls touart_MockConfig_Init(),uart_MockConfig_Verify()anduart_MockConfig_Destroy(). A mock included without a folder keeps its current name. A leading./is ignored. The result passes throughTypeSanitizer.sanitize_c_identifieras before, so/and\become_.The option defaults to off, and runners generated without it are unchanged. Runner and mocks must agree on naming, so enabling it in only one tool breaks the link. It can be set in an options hash, in a
:unityYAML section, or in a:cmocksection shared with CMock, becausegrab_configalready falls back to that section.Changes
auto/generate_test_runner.rb:default_optionsgainsmock_name_include_folder: false. When the option is on,create_mock_managementstrips only the extension from each mock include. Otherwise it keepsFile.basename(mock, '.*').docs/UnityHelperScriptsGuide.md: new:mock_name_include_folderentry beside:mock_prefixand:mock_suffix.test/tests/test_generate_test_runner.rb: theSameNamedMocksByFoldercase generates, compiles, links and runs a runner against two same-named stand-in mocks and checks that each mock's lifecycle functions are called.NameMocksByBasenameWithoutFolderOptionchecks that the default still names by filename.test/testdata/uart/MockConfig.h,test/testdata/spi/MockConfig.h,test/testdata/testRunnerGeneratorWithSameNamedMocks.c: the stand-in mocks and their test file.Related