2

I can use gcov/lcov/genhtml to generate test coverage report for all the files, now I want to only get the report for the last 10 commits. how can I get there?

What I have tried is:

1. compile and run the program. 
2. lcov --directory . --capture --output-file redis.info
3. git diff HEAD~10..HEAD >  my.patch
4. lcov --diff ./redis.info my.patch -o redis-patch.info  

I want to the the coverage for my.patch only but failed (looks coverage for all the data still)

zhihuifan
  • 1,093
  • 2
  • 16
  • 30

1 Answers1

1

Unfortunately lcov --diff is about patching sources in case coverage was generated but sources are old. Few days ago fastcov received ability in this PR to filter coverage using diff file. It is still not in release, but can be used and one-file tool. Tool is designed for GCC 9+, but you can safely run it with any GCC version if you want only to filter ready lcov's .info file. Usage will be next:

1. compile and run the program. 
2. lcov --directory . --capture --output-file redis.info
3. git diff HEAD~10..HEAD >  my.patch
4. python fastcov.py -C ./redis.info --diff-filter my.patch --lcov -o redis-patch.info  
Roman B
  • 11
  • 1