From 3fa1d99066ecbbd02b15885b18c6e99385733954 Mon Sep 17 00:00:00 2001 From: Zooko Ofsimplegeo Date: Mon, 19 Apr 2010 16:08:37 -0600 Subject: add a --require option to specify directories which are required to be at the beginning of the path for any file that is going to be included in code coverage make the --omit and --require options apply to code coverage generation as well as to reporting; This speeds up tests from 6 seconds to 1 second on my system, as well as making the resulting .coverage db include *only* the code that I care about, which helps with my code coverage progression/regression tool. --- coverage/annotate.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'coverage/annotate.py') diff --git a/coverage/annotate.py b/coverage/annotate.py index 2117b65..9c2c7a0 100644 --- a/coverage/annotate.py +++ b/coverage/annotate.py @@ -33,9 +33,15 @@ class AnnotateReporter(Reporter): blank_re = re.compile(r"\s*(#|$)") else_re = re.compile(r"\s*else\s*:\s*(#|$)") - def report(self, morfs, directory=None, omit_prefixes=None): - """Run the report.""" - self.report_files(self.annotate_file, morfs, directory, omit_prefixes) + def report(self, morfs, directory=None, omit_prefixes=None, require_prefixes=None): + """Run the report. + `omit_prefixes` is a list of prefixes. CodeUnits that match those prefixes + will be omitted from the list. + `require_prefixes` is a list of prefixes. Only CodeUnits that match those prefixes + will be included in the list. + You are required to pass at most one of `omit_prefixes` and `require_prefixes`. + """ + self.report_files(self.annotate_file, morfs, directory, omit_prefixes, require_prefixes) def annotate_file(self, cu, analysis): """Annotate a single file. -- cgit v1.2.1