2

I use gcovr to read coverage information for program foo.c. The syntax is

gcovr -r . -b --filter=FILE_PATTERN

where the '-r .' part indicates the current directory as the search root, '-b' is for branch coverage, and the FILE_PATTERN part is to keep only the data files that match this regular expression, according to gcovr's user guide http://gcovr.com/guide.html.

So I use this following command line

gcovr -r . -b --filter='foo\\.c'

But this command finds no information regarding foo.c retrieved. It seems I use a wrong regular expression. What do you think?

zell
  • 9,830
  • 10
  • 62
  • 115

1 Answers1

1

Unless your file's name is literally: foo\.c
That regex won't match.

In regex, the double backslash creates a literal backslash.
You may be confusing regex escape sequences and C/C++ string escape sequences.

If your file's name is literally: foo.c
Use this regex pattern: foo\.c

Luv2code
  • 1,079
  • 8
  • 14
  • 2
    I have used `--exclude='.*Test.*'` to exclude any file with "Test" in the name, yet many files such as `TestIO.cpp` are still being reported - any suggestions? – David Doria Sep 25 '16 at 22:57
  • @DavidDoria Are you still affected by that problem? If you could make a small example project to reproduce this using an up-to-date gcovr, I would love to get a bug report on the gcovr project :) – amon Apr 11 '18 at 17:52
  • @amon Sorry, I haven't looked at this in a long, long time and don't have the bandwidth to do so at the moment. – David Doria Apr 12 '18 at 13:26