-
Notifications
You must be signed in to change notification settings - Fork 250
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
Ceedling 1.0.1 does not resolve #include directives before mocking a header #1010
Comments
Hi @mikewzr -- sorry about the trouble and THANK YOU for the detailed report. You've provided a lot of good information for us to work with here! I actually believe this is working the way it's intended, and you were just lucky enough that the problems in In version This bug also had the side effect that, in some cases, meant that functions defined in nested headers were also being mocked (whereas usually only the functions directly in the specified headers are mocked). At worst, this can lead to the double-inclusion problem above for generated mocks. Often it just generates a lot of mocks which aren't actually going to be used. It sound like, in your situation, it wasn't leading to either of the problems above, and you desired to have those functions mocked anyway. So it all seemed purposeful. The intended behavior is that a test is written with an explicit list of all the files which need mocking. This means that if you need mocks from a nested header file, you should be required to include that header file. In your situation, your test includes Including all the headers required for your test fixes the problem and it returns the control of what is included to you, the test writer. So that's the theory. As with anything, there are tradeoffs abound. At its best, this behavior means more work for the test writer (which we don't love). At its worst, it is somehow challenging to create the perfect circumstances to include all the nested headers with their required defines, etc. It can get tedious hunting down what is needed. This is why we often recommend building a single header file (
Ok. I think I've rambled long enough now, though I'm happy to chat further about any of these things if need be. Best of luck! |
I just tried out Ceedling 1.0.1 for my ESP IDF project and noticed some new linker errors, which weren't present with Ceedling 1.0.0.
These functions where mocked before with Ceedling 1.0.0. I was investigating the issue a little bit by comparing the prepocessed header files and found out the following:
The preprocessed file
gpio.h
looks like this, after executing Ceedling 1.0.0:The same file (with the same project.yml) looks like this, when preprocessed by Ceedling 1.0.1:
It seems like Ceedling 1.0.1 does not process the include statements in the header-to-be-mocked anymore. The file I'm trying to mock is part of the ESP IDF and can be viewed here: https://github.com/espressif/esp-idf/blob/v5.3.1/components/esp_driver_gpio/include/driver/gpio.h.
The text was updated successfully, but these errors were encountered: