diff options
author | Zooko Ofsimplegeo <zooko@simplegeo.com> | 2010-04-19 16:08:37 -0600 |
---|---|---|
committer | Zooko Ofsimplegeo <zooko@simplegeo.com> | 2010-04-19 16:08:37 -0600 |
commit | ce4dbf3b92dcccf146cdf8c0bfb2f6da0a7c5dd5 (patch) | |
tree | c1841e353e5968604551161e2afbd4ebad38fe75 /coverage/cmdline.py | |
parent | 6638c632a10af6477a712f1a86af6d9e9ab3a3e3 (diff) | |
download | python-coveragepy-git-ce4dbf3b92dcccf146cdf8c0bfb2f6da0a7c5dd5.tar.gz |
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.
--HG--
extra : transplant_source : %1F.4%81%E8%DA%0B%D0%D5%9D%89%DE%E1vY%E6%CD%1A%EB%C9
Diffstat (limited to 'coverage/cmdline.py')
-rw-r--r-- | coverage/cmdline.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/coverage/cmdline.py b/coverage/cmdline.py index 9e15074b..acf8903d 100644 --- a/coverage/cmdline.py +++ b/coverage/cmdline.py @@ -54,6 +54,12 @@ class Opts(object): help="Omit files when their filename path starts with one of these " "prefixes." ) + require = optparse.Option( + '', '--require', action='store', + metavar="PRE1,PRE2,...", + help="Include files only when their filename path starts with one of these " + "prefixes." + ) output_xml = optparse.Option( '-o', '', action='store', dest="outfile", metavar="OUTFILE", @@ -99,6 +105,7 @@ class CoverageOptionParser(optparse.OptionParser, object): help=None, ignore_errors=None, omit=None, + require=None, parallel_mode=None, pylib=None, rcfile=True, @@ -219,6 +226,7 @@ CMDS = { Opts.directory, Opts.ignore_errors, Opts.omit, + Opts.require, ] + GLOBAL_ARGS, usage = "[options] [modules]", description = "Make annotated copies of the given files, marking " @@ -256,6 +264,7 @@ CMDS = { Opts.directory, Opts.ignore_errors, Opts.omit, + Opts.require, ] + GLOBAL_ARGS, usage = "[options] [modules]", description = "Create an HTML report of the coverage of the files. " @@ -267,6 +276,7 @@ CMDS = { [ Opts.ignore_errors, Opts.omit, + Opts.require, Opts.show_missing, ] + GLOBAL_ARGS, usage = "[options] [modules]", @@ -280,6 +290,8 @@ CMDS = { Opts.pylib, Opts.parallel_mode, Opts.timid, + Opts.omit, + Opts.require, ] + GLOBAL_ARGS, defaults = {'erase_first': True}, cmd = "run", @@ -291,6 +303,7 @@ CMDS = { [ Opts.ignore_errors, Opts.omit, + Opts.require, Opts.output_xml, ] + GLOBAL_ARGS, cmd = "xml", @@ -495,6 +508,10 @@ class CoverageScript(object): if options.omit: omit = options.omit.split(',') report_args['omit_prefixes'] = omit + require = None + if options.require: + require = options.require.split(',') + report_args['require_prefixes'] = require if 'report' in options.actions: self.coverage.report( |