Allow the combination of use_test_preprocessor and CMock's treat_inlines#421
Open
M-Bab wants to merge 1 commit intoThrowTheSwitch:masterfrom
Open
Conversation
…e CMock parse function.
This allows the treat_inlines to operate on the original header instead of the preprocessed
header which is crucial to get a correct copy of the original header (with the keywords static/inline stripped).
This needs the appropriate ceedling version to work. CMock called directly will continue
to work since an illegal path is provided (""). No error is triggered, if the treat_inlines feature is deactivated.
mvandervoord
requested changes
Nov 11, 2024
Member
mvandervoord
left a comment
There was a problem hiding this comment.
Can you retarget this PR to the branch cmock_2_6_rc instead? This is a good starting point. I'll need to backfill some tests and tweak some details. :)
| else | ||
| '' | ||
| end | ||
| if @treat_inlines == :include |
Member
There was a problem hiding this comment.
The "Ruby Way" of doing this same thing would be to have a single line which is like raise "Blah" if orig_file.nil? In this case, however, I think if an original file isn't provided, there's no reason it shouldn't just go with the specified source instead?
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.
I expect this combination to be pretty common especially in embedded unit testing. Often the preprocessor is needed because the vendor headers alone are too complex and tricky to be parsed correctly without preprocessing (NXP, STM, ...). Not to mention the own developed header files.
On the other hand you want to mock the evil inline functions that try to directly manipulate non existing registers. Even if you fake-map the registers into the host runner RAM you still have no control if the inline function was called or not. You gain a more fine grained control over your tests if the inline functions are mocked.
Unfortunately the combination of preprocessor and treat_inlines creates a copy of the original header in the include path which is stripped of all macros (=preprocessed). When the following GCC build of unit test itself is in anyway dependent on these macros the build will fail. This MR allows the specific mechanism of removing the static/inline keywords for the header copy to operate on the original file instead of the preprocessed file. While other operations of CMock run on the preprocessed file so there is no change in behaviour there.
I am not particular happy about this pull request concerning the code quality itself. It was my first touch with ruby/rake ever and I am just glad I achieved the level "works for us". Probably the tests need to be fixed. Probably there is a better or complete different way to resolve this. I just wanted to provide this to give an idea how it works. But I am also ready and willing to improve it, if you have some suggestions.
For more information compare the issue ThrowTheSwitch/Ceedling#706
This PR is dependent on this PR: ThrowTheSwitch/Ceedling#728