summaryrefslogtreecommitdiff
path: root/coverage/cmdline.py
diff options
context:
space:
mode:
authorZooko Ofsimplegeo <zooko@simplegeo.com>2010-04-19 16:08:37 -0600
committerZooko Ofsimplegeo <zooko@simplegeo.com>2010-04-19 16:08:37 -0600
commit3fa1d99066ecbbd02b15885b18c6e99385733954 (patch)
treefcf1a4755626614cdda21a42b4c87f449bda1615 /coverage/cmdline.py
parent5c2e817e0606ee912fbb4f44550d8b29cf0cd278 (diff)
downloadpython-coveragepy-3fa1d99066ecbbd02b15885b18c6e99385733954.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.
Diffstat (limited to 'coverage/cmdline.py')
-rw-r--r--coverage/cmdline.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/coverage/cmdline.py b/coverage/cmdline.py
index 9e15074..acf8903 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(