SimonKagstrom / kcov

Code coverage tool for compiled programs, Python and Bash which uses debugging information to collect and report data without special compilation options
http://simonkagstrom.github.io/kcov/
GNU General Public License v2.0
712 stars 109 forks source link

kcov cannot merge directories created using the --collect-only option #327

Closed cattanimarco closed 2 years ago

cattanimarco commented 4 years ago

When running kcov--merge with a list of directories created via kcov --collect-only the merge result is invalid (0% coverage)

SimonKagstrom commented 4 years ago

Yes, you are right. This behavior would be nice to have.

The reason it doesn't work is because the merge-parser is also a "writer", and --collect-only means that all "writers" are skipped. A solution could be to allow forcing some writers, i.e., the merge-parser in this case.

cattanimarco commented 4 years ago

It actually fails even though I don't use --collect-only during the merge phase, e.g. kcov --collect-only /tmp/single_n exec n times and then kcov --merge /tmp/merged /tmp/single_* Is this expected too?

SimonKagstrom commented 4 years ago

Yes, this is expected. I should have explained more: the merge parser relies on a database which is written by a "writer" when kcov runs. This database is not the same as the collection database, which is produced also with collect-only.

The bug is really in the collection step, and in the report / merge step it doesn't matter if collect-only is passed, since it doesn't do any collection anyway.

The merge writer needs special casing to always run, in contrast to the other writers which does not run on collect-only.

SimonKagstrom commented 4 years ago

Fixed with 4e4c8ad, I believe.