2

I am working on an enormous django project that takes hours to generate a coverage report (using the coverage.py library). Instead, I want travis to generate a report on only the functions that have been changed in my PR.

My current idea is to write something in .travis.yml to run a git diff between my branch and the branch it is being PR'd against, getting the function names from that output, and then running testing with coverage on those functions.

This seems like a problem that other people must have run into, is there some cleaner way of doing this?

Preethi Vaidyanathan
  • 1,203
  • 1
  • 12
  • 32

1 Answers1

0

In one of my previous answers, I helped someone get their last modified php files inside a git folder (Not what you need but this might help you).

Check the following:

https://stackoverflow.com/a/50128977/9395299

Look at this question also:

Is there a way to ask git diff to show the method name instead of the class name?

It points to the following documentation:

https://git-scm.com/docs/gitattributes#_defining_a_custom_hunk_header

This might help you a bit more.

I have never done that before but apparently you can specify a git diff attribute to show you what you really need (in your case your python functions).

From there you could get the list of your functions and pass them to your coverage reporter.

Maël Pedretti
  • 718
  • 7
  • 22