When the source file is located in other directories, gcovr fails to generate a comprehensive report

I'm having trouble getting the correct HTML output from gcovr when the source file is located relative to my root directory.

Let me illustrate with two cases where gcovr works and where it encounters issues:

CASE:1 - Successful execution of gcovr After running gcovr from my root directory with the parameters --html and --html-details, this is the structure of my root directory:

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

Everything appears to be in order, as I have both the general html report (report.html) and the detailed report for myfile.c (report_myfile.html).

CASE:2 - gcovr facing inconsistencies Upon running gcovr from my root directory with the parameters --html and --html-details, here is the structure of my root directory:

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

Now you can see that gcovr generates a "report.C" file within the gcovr_reports/ directory.

The general html report (report.html) with the summary is created successfully, but the detailed report for myfile.c is not generated. However, if we check the obj directory, we find the following file:

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

Upon examining the contents of ^#^#^#Project#Common#Source#myfile.c.gcov, we realize that the path resolution is as follows:

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

However, it should be:

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

The gcovr command used 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

Do you have any idea what could be causing this issue?

Answer №1

Gcovr eliminates coverage data that is not within the project, based on the -r root or any specified --filters.

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

The mentioned file is excluded as it does not belong to the project. This is typically desired behavior since the coverage of external libraries tends to be irrelevant.

If this exclusion is not desired, you have the option to control the filters and define your own --filters. Multiple filters can be defined, where at least one must match. To disable all filters, use an empty filter --filter "".

Filters are regular expressions used for matching against the absolute source file path.

Unfortunately, filters currently do not work properly on Windows. It is only possible to write filters that match multiple directories if your working directory is a parent directory of all target directories. For instance, you could navigate to C:\ and utilize the following filters:

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

This limitation will be addressed in a future version of gcovr, so it's advised to refrain from using filters containing backslashes as path separators.

Update: Starting from version 4 of gcovr, all filters MUST use forward slashes as path separators, even on Windows. Check out the Using Filters section in the Gcovr User Guide for more information.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Utilizing Angular to Handle Undefined Variables in String Interpolation

Seeking a way to showcase data obtained from an external API on a webpage using Angular's string interpolation. If no data is retrieved or is still pending, the aim is to display 'N/A'. An attempt was made following this method, but encoun ...

Displaying errors above the table. Executing ng-repeat in AngularJS

I've been struggling with a seemingly simple issue for hours now. I have a table displaying equipment rows using ng-repeat and input controls, and I want to display validation errors above the table. Here's what I tried: <div class="col-xs- ...

Exploring the ways to retrieve the returned Dynamic scope in AngularJS

There's a specific need I have - I require a single AngularJS function that can dynamically return the scope variable based on an input parameter. When it comes to controller functions, I've come across examples of how to achieve this dynamic sco ...

Is there a way to ensure that the table headers are printed on every page when using Google Chrome

When printing documents in Chrome browser, the table header (thead) does not appear on every page. I want to ensure that the table header is displayed on each printed page, just like it is done with IE and Firefox. However, Chrome does not support this fea ...

Attaching a click event to an input field

Seeking to serve html files from the server without relying on template engines. Below is the script used to start the server. // script.js const express = require("express"); const bodyParser = require("body-parser"); const app = express(); app.use(expr ...

using javascript to retrieve php variables

After creating a webpage, setting up Apache2 on an Ubuntu server to access it over the internet, and installing PHP5 and MySQL, I encountered issues with accessing database information on my page through a .php file. Despite having a file named test.php th ...

How can you implement a transform transition toggle when a user clicks on an element

Check out this CodePen example for a cool overlay animation: https://codepen.io/pen/MoWLrZ Experience the unique animation of two overlays as you click for the first time. However, on the second click, watch as both overlays seamlessly return to their ori ...

What is the best way to prevent table cell borders from encroaching on the padding area of the cell?

When dealing with table cell elements that have borders, it's common for them to not respect the vertical height of the cell containing them. Sometimes a child element's borders may overlap the padding or border of its containing cell. To prevent ...

Utilizing Jquery: Extracting the value of a child element upon clicking the encompassing parent div

I've created a table-like structure using divs instead of tables (because I strongly dislike tables). However, I'm facing an issue. I want to be able to click on one of the div elements and extract the values of its child elements. <div cla ...

Unlock maximum screen viewing on your custom video player with these steps to activate fullscreen

I'm having an issue with my basic video player - when toggling fullscreen, it doesn't fill the whole screen even though I tried using .fullscreen{width:100%} without success after searching for a solution. html <div class='player-contai ...

Using embedded js files in jQuery's .load() function does not function properly

In the index.html file, I have the code snippet below: <div id="page-insert"></div> function openPage(pageid) { $('#page-insert').load(pageid); } openPage('testpage.html'); Additionally, there are script files embedde ...

Issues arise when using the "placeholder" attribute within a <p:inputText tag while the inputText is devoid of any value

A current project involves implementing JSF Mojarra 2.3.9.SP02 alongside PrimeFaces 7.0 on Wildfly 17 using the Sapphire template provided by PrimeFaces. However, I've encountered a significant issue with a specific <p:inputText element within my f ...

Change the color of the div's background

My grid created using bootstrap 3 divs consists of a button, followed by a radio button, and then another button. I want to highlight these elements with a consistent background color that stretches across like a single row. Check out my attempt on this f ...

What is the best way to show toast notifications for various selections in a dropdown menu?

I have a dropdown menu labeled "FavoriteFoods" that includes options such as "Pizza," "Sushi," "Burgers," and "Biryani." When one of these food choices is selected from the dropdown, I would like a toast pop-up to appear with the message "Great choice!" ...

Secret button concealed within a div, revealing only a helpful hint

On my website, there is a list of items where each item is represented by either a picture or a name enclosed in an <article> tag. Here is an example of how it looks: <article class="client-card"> <p><img width="211" height="106" ...

Ensure that a distinct cross button is included within the text or search input and positioned to float alongside the text for

Is there a simple method to include a clear button that hovers after the text in an input field when using a search type input? <input type="search"> ...

Limiting the displayed portion of a table and implementing scrolling instead

I am currently working with a static HTML template that contains the following code: <table> <thead></thead> <tbody></tbody> </table> Using jQuery and AJAX, I am dynamically adding and removing rows and columns ...

How to position collapsible buttons in Twitter's Bootstrap framework

I have successfully created two buttons on the same line. The second button is collapsible and when clicked, it adds a row of two more buttons to the view. However, the newly collapsed row of buttons appears aligned with the second button. I would like th ...

the submit button seems to be malfunctioning

Hi there! I recently created a contact page using Dreamweaver for my website. However, after uploading my blog, the submit button on the contact form doesn't seem to be working. The technical support team at WordPress suggested that I need to edit som ...

How to Enhance Angular ui-router nested views with Resolve?

I have been working on creating a customized version of my Angular 1.4.12 application with nested views. The main purpose behind this customization is to accommodate sections within the app that require a header/content/footer structure, while others do no ...