gcovr doesn't create detailed report when source file located relative in other directories

1.5k Views Asked by At

I'm trying to get proper html output from gcovr when source file is located relative from my root directory.

For example (I will mention two cases where gcovr works, and where it has problems):

CASE:1 - gcovr works without problems My root directory is structured as follow,after I run gcovr from root with --html --html-details

source/myfile.c
obj/myfile.o, myfile.gcda, myfile.gcno, myfile.c.gcov
gcovr_reports/report.html, report_myfile.html

So everything is ok, and I have the html general report(report.html) as well as the detailed report (report_myfile.html).

CASE:2 - gcovr is not working properly My root directory is structured as follow,after I run gcovr from root with --html --html-details)

../../../Common/Source/myfile.c 
obj/Common/Source/myfile.o,     myfile.gcda,myfile.gcno,^#^#^#Common#Source#gcovmyfile.gcov
gcovr_reports/report.html, report.C

Now as you can see, gcovr generates the "report.C" file within the gcovr_report/ directory

Also the general html report (report.html) with the summary is created, but not the detailed one of my source file "myfile.c" . When I look into the obj directory it creates the following file (as you can see below):

^#^#^#Project#Common#Source#myfile.c.gcov

When I take a look into

^#^#^#Project#Common#Source#myfile.c.gcov, 

the path is resolved as follow:

Source:../../../Project/Common/Source/myfile.c

but it should be:

Source:../../../../../../../Project/Common/Source/myfile.c

The gcovr command is:

C:\Python34\Scripts\gcovr -v -b -r C:\Project\UnitTests\myModule\module1 --    object-directory C:\Project\UTests\myModule\module1\test-obj\Common\Source --     html --html-details -o govr_report\report.html

Any idea what I'm doing wrong?

1

There are 1 best solutions below

0
On

Gcovr filters the coverage data to only show files within your project, as determined by the -r root or any --filters.

Project: C:\Project\UnitTests\myModule\module1
File:    ..\..\..\Common\Source\myfile.c

The file is not within the project, so it is excluded. This is usually what you want, because the coverage of any libraries you use tends to be irrelevant.

When this is wrong, you can take over filtering and define your own --filters. You can define multiple filters, and any one must match. To disable filters entirely, use an empty filter --filter "".

Filters are regexes that are matched against the absolute source file path.

Unfortunately, filters are currently broken for Windows. It is not possible to write filters that match multiple directories, unless your working directory is a parent directory of all target directories. For example, you could go to C:\ and use the following filters:

--filter Project\\UnitTests\\myModule\\module1\\
--filter Common\\Source\\

This will change in a future version of gcovr, so please try to avoid filters that contain backslashes as path separators.

Update: Since gcovr version 4, all filters MUST use forward slashes for path separators, even on Windows. See Using Filters in the Gcovr User Guide for details.