Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GCovr does not generate a valid report

I want to set up my Jenkins with Cobertura to track code coverage. Unfortunately I can not generate a valid xml.

I'm using:

  • gcovr 2.5-prerelease (r2774)
  • Xcode 4.6.1 Build version 4H512

My project is generating code coverage files correctly, but the report created with gcovr is not useful.

The command I use to generate the report is:

gcovr -r /Users/Shared/Jenkins/Home/jobs/CodeCoverage/workspace 
--object-directory /Users/Shared/Jenkins/Home/Library/Developer/Xcode/DerivedData/myProject-aooceqwwovrizceerghqvhflcfty//Build/Intermediates/myProject.build/Development/myProject.build/Objects-normal/x86_64 
--exclude '.*Developer.*' 
--exclude '.*Tests.*' 
--xml

This will create me this output:

<?xml version="1.0" ?>
<!DOCTYPE coverage SYSTEM 'http://cobertura.sourceforge.net/xml/coverage-03.dtd'>
<coverage branch-rate="0.0" line-rate="0.0" timestamp="1364322914" version="gcovr 2.5-prerelease (r2774)">
<sources>
    <source>
        /Users/Shared/Jenkins/Home/jobs/CodeCoverage/workspace/Project/myProject/
    </source>
</sources>
<packages/>
</coverage>

Additional Informations:

If I remove --object-directory and -r and then I execute the command from the derived data directory a valid report is generated. This report can be read from cobertura but can not show any detailed information about the source files.

like image 414
Giuseppe Avatar asked Mar 26 '13 18:03

Giuseppe


2 Answers

When working with XCode, I've found that using $WORKSPACE/build as the build directory helps with this problem. This keeps the Derived Data directory out of it, and also neatly keeps my object files in the build directory. It also prevents two builds from interfering with each other.

If using the Xcode build tool, set SYMROOT to $WORKSPACE/build in the Tool's build configuration. If you're building from the command line, set it manually on the command line or in the environment.

Then a gcovr script such as:

/your/path/to/gcovr -r . --object-directory build/YourApp.build/Coverage-iphonesimulator/YourApp.build/Objects-normal/i386 --xml > build/coverage.xml

(your path may vary slightly depending on what you call your build style, etc.)

And finally in the Cobertura config, point at build/coverage.xml, and you should get annotated source when you use the tool within Jenkins.

Should do the trick. I've been really happy with that configuration on our small farm of Mac Minis.

like image 135
gaige Avatar answered Nov 09 '22 13:11

gaige


gcovr should be executed from the folder where the .gcda and .gcno files exist. And the root path is the folder where the source files(.c or .cpp) exist.

With this, the command looks like something as shown below.

rr-mac:gcdaFolder$ gcovr -r /path_to_C_sourceFiles/ .

For output html file below command works

rr-mac:gcdaFolder$ gcovr --html -o Filename_rp.html -r /path_to_C_sourceFiles/ .

Note: The dot(.) at the end is mandatory

like image 2
Rajesh Pappireddy Avatar answered Nov 09 '22 14:11

Rajesh Pappireddy