6

From the llvm-cov docs:

llvm-cov show [options] -instr-profile PROFILE BIN [-object BIN,...] [[-object BIN]] [SOURCES]

The llvm-cov show command shows line by line coverage of the binaries BIN,... using the profile data PROFILE. It can optionally be filtered to only show the coverage for the files listed in SOURCES.

I'm using the following command:

xcrun llvm-cov show -instr-profile "${PROFDATA}" "${BINARY}" codecov_source_files > Coverage.report

Where codecov_source_files is a file with this line:

*Router.swift

So basically what I want is the report to only contain files with the suffix: Router.swift

But i'm getting a Coverage.report with all the classes in the project.

What am I missing?

Lucien
  • 8,263
  • 4
  • 30
  • 30

2 Answers2

7

It's badly worded but SOURCES is actually a list of file names, not the name of a file containing a list of filenames.

They need to be the paths to the actual source files on disk. It doesn't support wildcards or regex unfortunately.

Edit: By reading the source I have discovered that you can also list directories as SOURCES and it will recurse into them. Also there is an undocumented option -dump-collected-paths which prints the files the SOURCES match.

Timmmm
  • 88,195
  • 71
  • 364
  • 509
  • 1
    Thank you for finding out `SOURCES` could be a folder. That really should be documented. Here is a full example of this for others that was tested with Clang 4.0. It will only show coverage for files in the `src_dir` folder. `llvm-cov show -format=html -instr-profile=default.profdata my_exe src_dir/ > coverage.html` – phoenix Jul 06 '17 at 11:21
  • 2
    You also might want to use `-output-dir=PATH` instead of `> coverage.html`. I don't believe the latter gives you per-file outputs. – Timmmm Jul 06 '17 at 12:30
  • Thank you @Timmmm, the `-output-dir` argument is MUCH nicer! – phoenix Jul 06 '17 at 13:03
0
  • you can use help to look up supported commands
$ llvm-cov show --help
$ llvm-cov report --help
  • Maybe the following command is the function you want
 --ignore-filename-regex=<string> - Skip source code files with file paths that match the given regular expression

huahua
  • 1
  • 2
  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Nov 25 '22 at 10:52