Skip to content
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

Not getting coverage when I #include a .c file #946

Open
Joel-Skarper opened this issue Oct 25, 2024 · 0 comments
Open

Not getting coverage when I #include a .c file #946

Joel-Skarper opened this issue Oct 25, 2024 · 0 comments

Comments

@Joel-Skarper
Copy link

Hi,

I have exactly the same problem as #926. I want to test the internals of a .c file (I have a state machine and between the poisons of #including a .c and accessing the static elements or doing it "the right way" and setting the state of my tests via the public API (i.e. complex tests) I pick the first).

So my test file

#include "spard.h"

#include "spard.c"
TEST_SOURCE_FILE("spard.c") // I have no idea how to use this :S

//My tests
...

Everything compiles and works, but I still get

-----------------------------
GCOV: ✅ OVERALL TEST SUMMARY
-----------------------------
TESTED:  17
PASSED:  17
FAILED:   0
IGNORED:  0


---------------------------
GCOV: CODE COVERAGE SUMMARY
---------------------------

test_spard
----------
⚠️ WARNING: Found no coverage results for test_spard::spard.c

Running Gcovr Coverage Reports
------------------------------
Generating HTML coverage report in 'build/artifacts/gcov/gcovr'...
Done in 0.492 seconds.


Ceedling operations completed in 4.77 seconds

I have two installations of Ceedling. On Windows, I have Ceedling:: 0.31.1, but I just installed the daily available today (Ceedling => 1.0.0-9fc30fb) in WSL. The results I pasted are from the WSL.

The issue I linked suggests, on v0.31, to add a fake "spard.h" in support, so Ceedling pulls "spard.c", but because I already #included "spard.c", all hell breaks loose in the linking step, as I have two definitions of everything.

Is there a way to get coverage of an #included .c? I'm happy if it's only possible in v1.0, I hope to get rid of 0.31 soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant