-
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
TEST_SOURCE_FILE: Ceedling 1.0.0 tries to compile and link to source file, even when directive is commented out #978
Comments
Hi, @mikewzr. Thank you so much for this report and so sorry for the trouble here. I totally agree that commenting out that macro should cause it to be ignored! I just reviewed Ceedling’s test suite for handling this and tried to recreate the problem. So far, I am unable to find an unhandled case nor replicate the problem. I see you're using the test preprocessing option. If I include
Something is clearly broken. My hunch is that something about how Ceedling calls your toolchain preprocessor is producing different results on your system than Ceedling is expecting. If you happen to be able to and are willing to do so, I'd be interested to know if the Dockerized version of Ceedling succeeds with the same project configuration and C files. If it does, this would be a strong indication that something about your toolchain preprocessor is behaving differently than we expect. |
I have similar problem with Ceedling v1.0.0, I noticed that it try to run tests that are defined out like this: #if REMOVED
void test_my_removed_test()
{
// Ceedling try to run this test
}
#endif |
out of curiosity, @parmi93 -- why do things like this? I have no disagreement that ceedling should handle these situations, but I rarely understand the reason. It would be far better (in my opinion) to use |
I hadn't thought of using |
@parmi93 Mark's recommendation is a good one. That said, just so you know, Ceedling can handle the case you described and should be doing so… If test preprocessing is enabled. Without this option configured, test cases will be discovered in your test file and then run no matter if they are surrounded by an p.s. For anyone following this thread, the original issue described by @mikewzr and the one described by @parmi93 are similar in concept but largely unrelated in features. Commenting out |
Hello @mkarlesky, I'm using gcc 14.2.1 provided by DNF on Fedora 41. I stripped away some paths and includes (replaced by %stripped% and %stripped-includes%, respectively), because it is a project for the company I'm working. I also tried to run Ceedling in the container, but it did not resolve the issue. It too complains about not finding the file, although it is commented out. |
I'm really quite stumped on this one so far, @mikewzr. I gather there is some sensitive information in your project. Are you able to provide (anonymized) project configuration, the test file, and any mixins you might be using? |
Hello, I discussed with the team today and it would probably be very hard to anonymize the project file good enough. But we came up with the idea of creating a minimal example, which would be easier to debug anyway. Thus, I set up a little project with the new command of Ceedling itself, to try if I get the same behavior on my system. And the result is yes, it still tries to find files in commented out The directory now looks like this:
The project file is essentially the default generated one, with
And the resulting output of the Ceedling preprocessing step:
I hope this helps and feel free to ask any further question, if you need anything else. Here is the project.yml file for completeness:
|
Thanks for the extra info. I see what the issue is. I'll have a fix rolling out soon. :) |
Nice, thank you. Happy that I could help. 👍 |
@mikewzr We found the problem. The root cause is a difference in the preprocessors offered by the locally installed toolchains that Ceedling calls. There's a few different steps involved in preprocessing test and mockable header files. In one of those steps Ceedling asks It turns out that some toolchains interpret this mode differently — specifically, some preserve comments. The code in Ceedling that processes the file on the other side of this directives-only preprocessing step assumes that comments will have been stripped by the toolchain preprocessor. Therein lies the problem! Unfortunately, it doesn't appear there's a foolproof way to ensure comments get stripped out via the toolchain preprocessor. But, Ceedling handles comment stripping itself in other cases. With a little surgery we can make use of that functionality to ensure toolchain-preprocessed output is always stripped of comments in this case. The fix is forthcoming. |
Hi @mikewzr -- if you're able, can you give the latest prerelease of 1.0.1 a shot? I believe it should fix the issue you encountered. |
I have a template test file in my project with following snippet in there:
Behavior:
Ceedling 1.0.0 tries to compile and link to files added with TEST_SOURCE_FILE even when they are commented out.
In this case, Ceedling tries to link to the file
FILE_UNDER_TEST.c
, which does not exist.Ceedling output (cropped):
Expectation:
As I am writing C code, I expect code commented out to not be used in any compilation, tests, etc.
Versions:
Fedora 41
Ruby 3.3.6
Ceedling 1.0.0
The text was updated successfully, but these errors were encountered: