-
Notifications
You must be signed in to change notification settings - Fork 7.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmock: can't use :subdir option because of the way generated c files are added to the MOCK_GENERATED_SRCS list (IDFGH-12326) #13360
Comments
Hi @BastienGermond! It seems that there are two different aspects here:
Do you have problems with both or just one of these aspects? |
Hi @0xjakob,
The issue is that the files generated with the cmock_configuration What I'm trying to say is that currently the path is hardcoded expecting the default values from CMock ( In case we have a mock_config.yaml like this :
This would generate files following this path :
esp-idf/tools/cmake/component.cmake Lines 552 to 553 in 60a2bf6
esp-idf/tools/cmake/component.cmake Lines 558 to 560 in 60a2bf6
And because of this different path the c-files are not registered correctly (and thus not found/compiled during compilation causing missing symbols during linking).
I also have this problem caused by not using :subdir, in my project I use a I patched it the first time the same way esp-idf does for freertos with adding manually my correct header with :includes_h_pre_orig_header. esp-idf/tools/mocks/freertos/mock/mock_config.yaml Lines 2 to 4 in 60a2bf6
CMock still add an However, in case the "nvs.h" was not something found in any include path or something that is not wanted in this header, the compilation will fail with an include not found error or maybe collide with the right header (myproject/nvs.h). I apologize if my explanation was unclear. Please let me know if you did not catch what I mean and I will try to rephrase it 😄. |
It starts to make much more sense now, thanks! Supporting Regarding support for custom |
Not really, and I agree that I don't see a use case right now. Maybe some company may have some convention about filename enforced by tools ? I was mentioning them only since they will not work with the current process, the real issue for me was the missing |
Answers checklist.
General issue report
Hello,
While trying to play with CMock for my project I noticed that it is not possible to mock component that use some kind of namespaced headers (e.g
#include <myproject/logic.h>
) and for that use :subdir option from CMock.The issue is caused by the way mocked files are added in:
esp-idf/tools/cmake/component.cmake
Line 553 in 60a2bf6
Every mocked files are expected to be directly under
/mocks/
, is it possible to maybe add another configuration option toidf_component_mock
to specify aSUBFOLDER
?Since the :subdir option is closely related to :mock_path maybe it would be useful to have by default
mocks
and something else if specified otherwise ?Example of mock_config.yaml used :
Currently, the build fails because it will not be able to find the c files generated under
mocks/myproject/Mock<...>.c
and expect c filesmocks/Mock<...>.c
.The text was updated successfully, but these errors were encountered: