-
Notifications
You must be signed in to change notification settings - Fork 362
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
OpenCppCoverage coverage report not working since upgrade to 1.2.x #1669
Comments
Some updates about this: I've tried to append one "/" after the drive, and still fails. I'm not sure how are the expected values in the report to work properly. [18:09:35] : [Step 7/14] 18:09:35.807 DEBUG: cached measures for 'E:\w\70c9368db3bcf0f1\tools\code_coverage\report_fixed.xml' : current cache content data = '0' |
Hi @ericlemes, could you make one sample please:
Regards, |
Hi @ericlemes, could you please answer questions above. Looking to the code this part is no more available:
In our doku we normally recommend that relative paths in reports should start with |
@guwirth Thanks for the comments. I'll have a look at this and get back to you as soon as I can. I'm just a bit busy now unfortunately :-( |
Hi @guwirth , I've finally got some time to get a fully working example. The code is in: https://github.com/ericlemes/StackTDDExample. Running OpenCppCoverage with the following command: OpenCppCoverage --sources C:\SandBox\StackTDDExample\Stack.Core --export_type=cobertura -- Stack.Core.Tests.exe I've got the coverage report (attached) and I've changed the coverage report as recommended using forward slashes and starting with ./, also trying to match the case. I didn't manage to get coverage published in any scenario Sonar 6.7.6 |
I am new to OpenCppCoverage and SonarQube. But I had success to get my coverage reports being recognized by editing the Cobertura file as followed:
|
Hey @MarcoWagner , Thank you very much. This pretty much answer my question. It is a shame that the behaviour changed and broke my previous setup, but at least I can fix now. |
@ericlemes & @MarcoWagner an idea how this should be supported without patching the report? An extra sensor? What I also understood is that the error is in OpenCppCoverage and will be fixed, right? |
@jmecosta you are also using OpenCppCoverage? How you are doing it? |
I dont know the Cobertura file format that well. On the OpenCppCoverage side: the On the sonar-cxx side: the OpenCppCoverage, case problem: OpenCppCoverage/OpenCppCoverage#53 |
@guwirth im not using OpenCppCover, ive used it only for local coverage analysis but the sonar builds are still done with bullseye. But it looks to me that OpenCppCover could provide absolute paths in the report. |
Hi @guwirth , There are reports in OpenCppCoverage issue tracker that it works fine with Jenkins and other tools. I don't think building a specific sensor would be the way to go. I think the issue happens because our sonar sensor expects the path to be relative to the sources directory. With OpenCppCoverage output if you compute the path following all the structure, the paths are not incorrect. For me the information that @MarcoWagner is helpful because at least I can fix my hacking tool and make it work. I believe the way to go would be to check if it is possible to the sensor discover the paths the way it is (since other tools can compute them with no issues), but also a fix from OpenCppCoverage would be interesting. |
Hi @ericlemes, @MarcoWagner, @ivangalkin, think to solve this we should have first a common understanding about the involved parts:
Question is also how to combine? Any other points? Regards, |
Hey @guwirth, Also, I'd consider forward and backward slashes (/ and ) and case-insensitive file matching. The how to combine is a tricky one. I think you should combine root + source + filename and always get the right file, so, it should automatically add slashes when combining. Regards, Eric |
Looking into the sample from @ericlemes Stack.Core.TestsCoverage.xml.zip <?xml version="1.0" encoding="utf-8"?>
<coverage line-rate="1" branch-rate="0" complexity="0" branches-covered="0" branches-valid="0" timestamp="0" lines-covered="73" lines-valid="73" version="0">
<sources>
<source>c:</source>
</sources>
<packages>
<package>
<classes>
<class name="heapallocator.h" filename="./Stack.Core/HeapAllocator.h" line-rate="1" branch-rate="0" complexity="0">
</class>
<class name="stack.h" filename="sandbox\stacktddexample\stack.core\stack.h" line-rate="1" branch-rate="0" complexity="0">
</class>
<class name="givenastack.cpp" filename="sandbox\stacktddexample\stack.core.tests\givenastack.cpp" line-rate="1" branch-rate="0" complexity="0">
</class>
<class name="stack.core.tests.cpp" filename="sandbox\stacktddexample\stack.core.tests\stack.core.tests.cpp" line-rate="1" branch-rate="0" complexity="0">
</class>
</classes>
</package>
</packages>
</coverage> |
@guwirth before editing with my self build tool mine looks the same as @ericlemes given sample. |
@ericlemes and @MarcoWagner I tried a fix with #1709. Please try with latest snapshot: https://ci.appveyor.com/project/SonarOpenCommunity/sonar-cxx/branch/master/artifacts |
Hey @guwirth, sorry for my delay. I'm adding this to my backlog here and we should see progress in the next couple of weeks. |
Hey @guwirth, I am working with @ericlemes on this. |
Works for me too. Thank you. |
@ericlemes & @MarcoWagner thx for your feedback. |
Description
I don't believe OpenCppCoverage ever worked properly with sonar-cxx, but was working fine with a little hack.
The issue is that in the coverage report, it uses the full path, without the drive specified (see OpenCppCoverage/OpenCppCoverage#46).
One example is:
<class name="asyncexecutionpolicy.h" filename="w\70c9368db3bcf0f1\handheld\src-deps\core\include\core\checkedresourceservice\asyncexecutionpolicy.h" line-rate="1" branch-rate="0" complexity="0">
To fix this issue, I've written this hack: https://github.com/ericlemes/CoberturaCoverageReportBaseDirFixer, which was working fine in sonar-cxx 1.1.0. The logic was just to strip a given file prefix (the working directory) and use the relative path.
It seems that the commit f8f599a broke this, because it now adds the drive, without the first "/" to the path, making the sensor not finding the file therefore not appending the measure.
Steps to reproduce the problem
Extract coverage report with OpenCppCoverage and publish analysis using the sonar-cxx coverage sensor.
It is expected that the coverage information is published, but it doesn't happen.
Known workarounds
None so far. I'll update my hack with the current behaviour, which should be available in https://github.com/ericlemes/CoberturaCoverageReportBaseDirFixer
LOG file
[16:11:57] : [Step 6/13] 16:11:57.357 DEBUG: save coverage measure for file: 'e:w/70c9368db3bcf0f1/handheld/src/common/world/attribute/attributemodifier.cpp' cxxFile = 'null'
[16:11:57] : [Step 6/13] 16:11:57.357 DEBUG: Cannot find the file 'e:w/70c9368db3bcf0f1/handheld/src/common/world/attribute/attributemodifier.cpp', ignoring coverage measures
Related information
The text was updated successfully, but these errors were encountered: