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

--keep seems broken #285

Open
misery opened this issue Oct 9, 2018 · 7 comments
Labels

Comments

@misery
Copy link

@misery misery commented Oct 9, 2018

We want to use SonarQube with Code Coverage report. We already uses gcovr with jenkins which works flawlessly (thanks!!!). As sonarqube uses gcov files directly we tried "--keep" of gcovr to avoid complex excludes which are already defined in gcovr cmdline. But it looks like gcovr will delete any .gcov files even we add "--keep".

Also it seems it writes it to /tmp/tmp****/. It would be great if non-excluded gcov files could be re-used by other programs.

See: https://docs.sonarqube.org/display/PLUG/SonarCFamily+Coverage+Results+Import

@latk

This comment has been minimized.

Copy link
Member

@latk latk commented Oct 9, 2018

oops, this is a regression (more or less).

When gcovr runs gcov, it generates .gcov files in your build directory. This will necessarily overwrite any existing gcov files in your directory structure. As part of multithreading support (-j), we parse the gcov output to find the filenames and move them to a tempdir, so that the next gcov invocation can run before the .gcov files have been parsed. There will be at least one gcov run per object file (and possibly more, because gcovr has to guess the correct starting directory).

With --keep, gcovr should move the files back from the tempdir into the build directory, but this will be a “last one wins” situation as there will be one .gcov file per source file per compilation unit. Especially headers are present in multiple compilation units. I'm therefore not sure whether your plan to feed these files to SonarQube will work.

I'm torn between updating the docs for --keep that it should only be used in conjunction with --use-gcov-files, or re-instating the previous behaviour which is likely buggy (as in: coverage will be lost). A third option would be to write a reporter that outputs .gcov files with summarized coverage (similar to our HTML reports). But that seems fairly insane and I don't have the time. (But if anyone would be offering to do that work … hint, hint.)

Anyway, thanks for this report. I'll think more about it but I don't think I'll be able to fix it soonishly.

@latk latk added the Type: Bug label Oct 9, 2018
@misery

This comment has been minimized.

Copy link
Author

@misery misery commented Oct 19, 2018

Thanks! Since we use cmake I switched to test_coverage_collect_gcov and tweaked it a little bit for SonarQube.

The idea was to just move /tmp/* stuff to $localBuildDir/tmp_gcov/*. So it could still be in parallel. But of course... maybe SonarQube don't allow multiple .gcov files for the same file.

@latk

This comment has been minimized.

Copy link
Member

@latk latk commented Oct 19, 2018

@misery

This comment has been minimized.

Copy link
Author

@misery misery commented Oct 22, 2018

Thanks for your answer.

I don't have time to contribute in the near future even I really would do that. But yes, I can try the generic test data here with a developer version. There is no problem to add this.

Well, that should explain why Jenkins says 59 % coverage and Sonar says 52 % coverage.

@misery

This comment has been minimized.

Copy link
Author

@misery misery commented Feb 7, 2019

Any progress here? Can I test something? :-)

@latk

This comment has been minimized.

Copy link
Member

@latk latk commented Feb 11, 2019

I'm sorry you have been waiting for months, but so far there is no progress. Please understand that while I try to be responsive around administrative and support issues (like triaging issues and reviewing PRs), at the moment any work on gcovr is just a hobby and will happen if and when it happens.

@misery

This comment has been minimized.

Copy link
Author

@misery misery commented Sep 17, 2019

Looks like my sonarqube problem is fixed by #308

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.