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

Request: Report no coverage (hits=0 for all lines) for files that were not executed #290

Closed
csauge opened this issue Jan 10, 2019 · 4 comments

Comments

@csauge
Copy link

@csauge csauge commented Jan 10, 2019

This would be a good feature to add this, because today we need to use lcov tool to do so.
See: https://stackoverflow.com/questions/23923040/generating-empty-gcda-files
Or I could be great to know if a tool to generate gcda files from a gcno exists.

@latk

This comment has been minimized.

Copy link
Member

@latk latk commented Jan 10, 2019

Thank you for this suggestion, but gcovr will already report zero coverage for uncovered files! It is sufficient if the source file is referenced in a .gcno file that the compiler generates, and it is not necessary that a .gcda file was created during test execution.

However, gcov/gcovr cannot know about dead code that the compiler eliminated. If a file only consists of dead code (like a C++ template that was never instantiated, or a static function that was never called), it will not be considered as uncovered – it simply does not exist as far as gcovr is concerned. There is no good workaround.

I'm closing this issue because AFAIK this feature already exists. If you have a problem with un-executed files, please add the relevant details so that I can reopen. E.g. the output of running gcovr in --verbose mode on a small example project that demonstrates the problem.

@latk latk closed this Jan 10, 2019
@csauge

This comment has been minimized.

Copy link
Author

@csauge csauge commented Jan 10, 2019

Ok great thank you, this is good news.
I didn't know, sorry.
Is this a new feature from version 4.X ? Which ticket is fixing that ?

@latk

This comment has been minimized.

Copy link
Member

@latk latk commented Jan 10, 2019

No problem! However, this feature has been around for a long time.

According to the changelog this was released back in version 2.4 from 2012-04-13. The original ticket on Sandia's Trac is #3887 (from before gcovr was developed on GitHub). The original implementation is in commit f1296c8.

@latk

This comment has been minimized.

Copy link
Member

@latk latk commented Mar 14, 2019

Related: as discussed in issue #100, whether this works also depends on the compiler/gcov version. GCC versions 5.5+, 6.2+, and 7+ are expected to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.