which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
I am using SonarQube Developer edition v7.7 with sonar-scanner v4.2
what are you trying to achieve
I have a simple project consisting of ~200 lines of code with google tests. I have an html page successfully generated from llvm-cov showing 87% code coverage. I am trying to upload this coverage report to SonarQube but all attempts have lead to 0% coverage on the SonarQube project page.
what have you tried so far to achieve this
I have tried the following:
llvm-cov show ./MyTest -instr-profile=coverage.profdata -format=html -output-dir=coverage
llvm-cov show ./MyTest -instr-profile=coverage.profdata -show-expansions -show-regions -show-line-counts -use-color-false > coverage.txt
The SonarQube documentation does not specify what format the report needs to be in order to be parsed by SonarQube. The actual security and vulnerability scanning works fine. I just can’t seem to get the coverage report to show greater than 0%.
I run the following command with the following relevant output I receive from the scanner:
I’m assuiming I’m not feeding the scanner correctly formatted llvm-cov code coverage. Is there a specific format I need to be using or am I doing something obviously incorrect?
So I am actually running all of this through a GitLab/kubernetes/docker pipeline. Specifically, this coverage test runs in a docker container for a specific stage. All of this occurs in a container within a working directory. The working directory is /builds/mygroup/myproject where binaries are built (configured with CMake) in /builds/mygroup/myproject/build/bin and each file path listed within the coverage.txt file is /builds/mygroup/myproject/test/library/file.cpp
Massimo,
Thank you for the help. After my last post, I think I realized what was happening. As I am working with a demo/learning project for SonarQube, the tests were not correctly written. Therefore, the files listed in my coverage.txt file did not reference the actual source files that I pointed the sonar-scanner to. Once I changed the scanner to point to my test files that the coverage.txt references, I was able to see coverage percentage show up in SonarQube.