0

I've been using the gcovr module for monthly report generation. I work on docker, so each time I used to download the gcovr module using pip3 command on my Linux container. Recently, after downloading the module, I realized that the version of the gcovr has been upgraded from 4.2 to 5.0 and the earlier commands were not working properly.

Earlier command used for report generation:

gcovr -g --keep --html-details --html-title "TITLE" --html-medium-threshold 60 --html-high-threshold 80 --gcov-ignore-parse-errors >> report.html

With gcovr 5.0, usage of the above command threw below error:

(ERROR) a named output must be given,if the option --html-details is used

Then, as per the suggestions from the above error, I used the command below:

gcovr -g --keep --html-details -o report.html --html-title "TITLE" --html-medium-threshold 60 --html-high-threshold 80 --gcov-ignore-parse-errors

But, I believe the above command is not fully correct and with the above command, the format of the report generated is not correct and also there are a lot of unwanted *.css files getting generated in the respective folders.

As you can see from the image below, the colour is not getting highlighted as per the percentage defined in "Legend":

gcovr 5.0 report:

amon
  • 57,091
  • 2
  • 89
  • 149
User123
  • 1,498
  • 2
  • 12
  • 26

1 Answers1

1

The --html-details report format generates one HTML file per source file, and an index file. Since gcovr 5.0, their shared CSS is stored as a separate file. This is important for the security configuration of some web servers.

  • When you copy or move the html-details reports, you must copy all associated files: all the .html and .css files.

  • You can force the CSS to be embedded into each HTML file using the --html-self-contained option. This e.g. makes it possible to send a single report file via email, but the links won't work. This option was announced as part of the gcovr 5.0 changelog.

  • It seems you are only interested in the index file, not in the source code-level details. If so, consider using the --html report format instead which generates a single file by default.

Additional remarks:

  • If you want to force a specific gcovr version, you can tell pip to e.g. pip install 'gcovr ~= 4.2'. The ~= version specifier selects the most recent compatible release, thus avoiding unexpected changes.
  • All output formats can take the output name directly. Instead of --html -o foo.html you can write --html foo.html.
  • The option --gcov-ignore-parse-errors is only intended as a temporary bandaid to keep you CI pipeline running in case you've updated to a GCC version that made incompatible changes to the .gcov report format. If there are errors without this option, that is a bug in gcovr and should be reported. With this option you'll still get a report, but the report is likely to be incorrect.
  • The gcovr option -g/--use-gcov-files is easy to use incorrectly. You almost certainly will get wrong results unless you use the gcov option -l/--long-file-names.
amon
  • 57,091
  • 2
  • 89
  • 149