From 7efd4f50062f750df145102fc07c87fc49599bbe Mon Sep 17 00:00:00 2001 From: Christine Lytwynec Date: Tue, 21 Apr 2015 11:28:13 -0400 Subject: Added ability to combine coverage data files from multiple directories into one file via command line args. --- coverage/cmdline.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'coverage/cmdline.py') diff --git a/coverage/cmdline.py b/coverage/cmdline.py index 2be3294..c611e03 100644 --- a/coverage/cmdline.py +++ b/coverage/cmdline.py @@ -249,7 +249,7 @@ CMDS = { ), 'combine': CmdOptionParser("combine", GLOBAL_ARGS, - usage = " ", + usage = " ... ", description = "Combine data from multiple coverage files collected " "with 'run -p'. The combined results are written to a single " "file representing the union of the data." @@ -430,7 +430,8 @@ class CoverageScript(object): self.do_run(options, args) if options.action == "combine": - self.coverage.combine() + data_dirs = argv if argv else None + self.coverage.combine(data_dirs) self.coverage.save() # Remaining actions are reporting, with some common options. -- cgit v1.2.1 From 161556f47ec6b8f7c0232c21fdbdd7cc25bd3d8e Mon Sep 17 00:00:00 2001 From: Christine Lytwynec Date: Wed, 22 Apr 2015 11:45:55 -0400 Subject: Update docstring and command line help text. --- coverage/cmdline.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'coverage/cmdline.py') diff --git a/coverage/cmdline.py b/coverage/cmdline.py index c611e03..66a76fa 100644 --- a/coverage/cmdline.py +++ b/coverage/cmdline.py @@ -252,7 +252,10 @@ CMDS = { usage = " ... ", description = "Combine data from multiple coverage files collected " "with 'run -p'. The combined results are written to a single " - "file representing the union of the data." + "file representing the union of the data. The positional " + "arguments are directories from which the data files should be " + "combined. By default, only data files in the current directory " + "are combined." ), 'debug': CmdOptionParser("debug", GLOBAL_ARGS, -- cgit v1.2.1 From 79a287fae7392ffda5d42593189243844027ffe9 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 17 May 2015 17:23:43 -0400 Subject: Add a missing space to a help string. --- coverage/cmdline.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'coverage/cmdline.py') diff --git a/coverage/cmdline.py b/coverage/cmdline.py index 66a76fa..0620c8e 100644 --- a/coverage/cmdline.py +++ b/coverage/cmdline.py @@ -56,7 +56,7 @@ class Opts(object): include = optparse.make_option( '', '--include', action='store', metavar="PAT1,PAT2,...", - help="Include only files whose paths match one of these patterns." + help="Include only files whose paths match one of these patterns. " "Accepts shell-style wildcards, which must be quoted." ) pylib = optparse.make_option( -- cgit v1.2.1 From 490811b8a80ef1c0f01f6f030e049f7d28550724 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Thu, 16 Jul 2015 15:41:15 -0400 Subject: Change CoverageData.summary() to CoverageData.line_counts() --- coverage/cmdline.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'coverage/cmdline.py') diff --git a/coverage/cmdline.py b/coverage/cmdline.py index 0620c8e..1a8a026 100644 --- a/coverage/cmdline.py +++ b/coverage/cmdline.py @@ -589,7 +589,7 @@ class CoverageScript(object): print(info_header("data")) print("path: %s" % self.coverage.data.filename) print("has_arcs: %r" % self.coverage.data.has_arcs()) - summary = self.coverage.data.summary(fullpath=True) + summary = self.coverage.data.line_counts(fullpath=True) if summary: plugins = self.coverage.data.plugin_data() filenames = sorted(summary.keys()) -- cgit v1.2.1 From 4464b41812dbcad3239b3bdc8a5474a0ae178df8 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 19 Jul 2015 09:19:23 -0400 Subject: Fix a test that used an unmaintained fake implementation for data. --- coverage/cmdline.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'coverage/cmdline.py') diff --git a/coverage/cmdline.py b/coverage/cmdline.py index 1a8a026..7d01490 100644 --- a/coverage/cmdline.py +++ b/coverage/cmdline.py @@ -586,17 +586,17 @@ class CoverageScript(object): print(" %s" % line) elif info == 'data': self.coverage.load() + data = self.coverage.data print(info_header("data")) - print("path: %s" % self.coverage.data.filename) - print("has_arcs: %r" % self.coverage.data.has_arcs()) - summary = self.coverage.data.line_counts(fullpath=True) + print("path: %s" % self.coverage.data_files.filename) + print("has_arcs: %r" % data.has_arcs()) + summary = data.line_counts(fullpath=True) if summary: - plugins = self.coverage.data.plugin_data() filenames = sorted(summary.keys()) print("\n%d files:" % len(filenames)) for f in filenames: line = "%s: %d lines" % (f, summary[f]) - plugin = plugins.get(f) + plugin = data.plugin_name(f) if plugin: line += " [%s]" % plugin print(line) -- cgit v1.2.1 From 0d6aad8cf60d91e6f2f382520920c5edcb5e2520 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Wed, 22 Jul 2015 13:39:05 -0400 Subject: A way to see the raw data in the data file. --- coverage/cmdline.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'coverage/cmdline.py') diff --git a/coverage/cmdline.py b/coverage/cmdline.py index 7d01490..b15eb10 100644 --- a/coverage/cmdline.py +++ b/coverage/cmdline.py @@ -8,7 +8,7 @@ import traceback from coverage import env from coverage.execfile import run_python_file, run_python_module -from coverage.misc import CoverageException, ExceptionDuringRun, NoSource +from coverage.misc import CoverageException, ExceptionDuringRun, NoSource, pretty_data from coverage.debug import info_formatter, info_header @@ -589,9 +589,9 @@ class CoverageScript(object): data = self.coverage.data print(info_header("data")) print("path: %s" % self.coverage.data_files.filename) - print("has_arcs: %r" % data.has_arcs()) - summary = data.line_counts(fullpath=True) - if summary: + if data: + print("has_arcs: %r" % data.has_arcs()) + summary = data.line_counts(fullpath=True) filenames = sorted(summary.keys()) print("\n%d files:" % len(filenames)) for f in filenames: @@ -602,6 +602,13 @@ class CoverageScript(object): print(line) else: print("No data collected") + elif info == 'rawdata': + self.coverage.load() + if self.coverage.data: + data = self.coverage.data._read_raw_data_file(self.coverage.config.data_file) + print(pretty_data(data)) + else: + print("No data collected") else: self.help_fn("Don't know what you mean by %r" % info) return ERR -- cgit v1.2.1 From e534f087c2337dbe17364130e40761fa4e16569a Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Wed, 22 Jul 2015 20:47:24 -0400 Subject: Move the raw data dumper to a more internal place. --- coverage/cmdline.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'coverage/cmdline.py') diff --git a/coverage/cmdline.py b/coverage/cmdline.py index b15eb10..656f1c0 100644 --- a/coverage/cmdline.py +++ b/coverage/cmdline.py @@ -8,7 +8,7 @@ import traceback from coverage import env from coverage.execfile import run_python_file, run_python_module -from coverage.misc import CoverageException, ExceptionDuringRun, NoSource, pretty_data +from coverage.misc import CoverageException, ExceptionDuringRun, NoSource from coverage.debug import info_formatter, info_header @@ -602,13 +602,6 @@ class CoverageScript(object): print(line) else: print("No data collected") - elif info == 'rawdata': - self.coverage.load() - if self.coverage.data: - data = self.coverage.data._read_raw_data_file(self.coverage.config.data_file) - print(pretty_data(data)) - else: - print("No data collected") else: self.help_fn("Don't know what you mean by %r" % info) return ERR -- cgit v1.2.1 From d6a7a11f8c5a8e73a9dfd9a1ce602df775d04586 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Thu, 23 Jul 2015 21:22:30 -0400 Subject: Refer to the project consistenly as coverage.py. #275 --- coverage/cmdline.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'coverage/cmdline.py') diff --git a/coverage/cmdline.py b/coverage/cmdline.py index 656f1c0..c0c9a98 100644 --- a/coverage/cmdline.py +++ b/coverage/cmdline.py @@ -1,4 +1,4 @@ -"""Command-line support for Coverage.""" +"""Command-line support for coverage.py.""" import glob import optparse @@ -119,7 +119,7 @@ class Opts(object): class CoverageOptionParser(optparse.OptionParser, object): - """Base OptionParser for coverage. + """Base OptionParser for coverage.py. Problems don't exit the program. Defaults are initialized for all options. @@ -202,7 +202,7 @@ class CmdOptionParser(CoverageOptionParser): def __init__(self, action, options=None, defaults=None, usage=None, description=None ): - """Create an OptionParser for a coverage command. + """Create an OptionParser for a coverage.py command. `action` is the slug to put into `options.action`. `options` is a list of Option's for the command. @@ -340,7 +340,7 @@ OK, ERR, FAIL_UNDER = 0, 1, 2 class CoverageScript(object): - """The command-line interface to Coverage.""" + """The command-line interface to coverage.py.""" def __init__(self, _covpkg=None, _run_python_file=None, _run_python_module=None, _help_fn=None): @@ -360,7 +360,7 @@ class CoverageScript(object): self.coverage = None def command_line(self, argv): - """The bulk of the command line interface to Coverage. + """The bulk of the command line interface to coverage.py. `argv` is the argument list to process. @@ -613,7 +613,7 @@ def unshell_list(s): if not s: return None if env.WINDOWS: - # When running coverage as coverage.exe, some of the behavior + # When running coverage.py as coverage.exe, some of the behavior # of the shell is emulated: wildcards are expanded into a list of # filenames. So you have to single-quote patterns on the command # line, but (not) helpfully, the single quotes are included in the @@ -669,7 +669,7 @@ Documentation at %(__url__)s def main(argv=None): - """The main entry point to Coverage. + """The main entry point to coverage.py. This is installed as the script entry point. -- cgit v1.2.1 From dc0d0c613de54cd5af74a1d3ac9d86235dc0aee9 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Fri, 24 Jul 2015 10:43:46 -0400 Subject: Add license mention to the top of all files. #313. --- coverage/cmdline.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'coverage/cmdline.py') diff --git a/coverage/cmdline.py b/coverage/cmdline.py index c0c9a98..af5ff0c 100644 --- a/coverage/cmdline.py +++ b/coverage/cmdline.py @@ -1,3 +1,6 @@ +# Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 +# For details: https://bitbucket.org/ned/coveragepy/src/default/NOTICE.txt + """Command-line support for coverage.py.""" import glob -- cgit v1.2.1 From 7d968589567efd3e6e8765f7b1605e2e6d7f1ba0 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Fri, 24 Jul 2015 12:21:15 -0400 Subject: Use more specific names than 'plugins', since there will be more of them in the future. --- coverage/cmdline.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'coverage/cmdline.py') diff --git a/coverage/cmdline.py b/coverage/cmdline.py index af5ff0c..10d0f61 100644 --- a/coverage/cmdline.py +++ b/coverage/cmdline.py @@ -599,7 +599,7 @@ class CoverageScript(object): print("\n%d files:" % len(filenames)) for f in filenames: line = "%s: %d lines" % (f, summary[f]) - plugin = data.plugin_name(f) + plugin = data.file_tracer(f) if plugin: line += " [%s]" % plugin print(line) -- cgit v1.2.1 From e825f492a3e5363b0e6d3bc41b76c54e91e2a174 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 26 Jul 2015 13:38:16 -0400 Subject: I thought these were alphabetized? --- coverage/cmdline.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'coverage/cmdline.py') diff --git a/coverage/cmdline.py b/coverage/cmdline.py index 10d0f61..ff98073 100644 --- a/coverage/cmdline.py +++ b/coverage/cmdline.py @@ -139,13 +139,14 @@ class CoverageOptionParser(optparse.OptionParser, object): concurrency=None, debug=None, directory=None, + erase_first=None, fail_under=None, help=None, ignore_errors=None, include=None, + module=None, omit=None, parallel_mode=None, - module=None, pylib=None, rcfile=True, show_missing=None, @@ -153,7 +154,6 @@ class CoverageOptionParser(optparse.OptionParser, object): source=None, timid=None, title=None, - erase_first=None, version=None, ) @@ -242,8 +242,8 @@ CMDS = { [ Opts.directory, Opts.ignore_errors, - Opts.omit, Opts.include, + Opts.omit, ] + GLOBAL_ARGS, usage = "[options] [modules]", description = "Make annotated copies of the given files, marking " @@ -284,8 +284,8 @@ CMDS = { Opts.directory, Opts.fail_under, Opts.ignore_errors, - Opts.omit, Opts.include, + Opts.omit, Opts.title, ] + GLOBAL_ARGS, usage = "[options] [modules]", @@ -298,8 +298,8 @@ CMDS = { [ Opts.fail_under, Opts.ignore_errors, - Opts.omit, Opts.include, + Opts.omit, Opts.show_missing, Opts.skip_covered ] + GLOBAL_ARGS, @@ -312,13 +312,13 @@ CMDS = { Opts.append, Opts.branch, Opts.concurrency, + Opts.include, + Opts.module, + Opts.omit, Opts.pylib, Opts.parallel_mode, - Opts.module, - Opts.timid, Opts.source, - Opts.omit, - Opts.include, + Opts.timid, ] + GLOBAL_ARGS, defaults = {'erase_first': True}, usage = "[options] [program options]", @@ -329,8 +329,8 @@ CMDS = { [ Opts.fail_under, Opts.ignore_errors, - Opts.omit, Opts.include, + Opts.omit, Opts.output_xml, ] + GLOBAL_ARGS, usage = "[options] [modules]", -- cgit v1.2.1 From 5c98172ff46513e182196b59b2b432b416ce2010 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 26 Jul 2015 15:03:11 -0400 Subject: New config option: run:note lets you annotate the data file. --- coverage/cmdline.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'coverage/cmdline.py') diff --git a/coverage/cmdline.py b/coverage/cmdline.py index ff98073..b4deb58 100644 --- a/coverage/cmdline.py +++ b/coverage/cmdline.py @@ -301,7 +301,7 @@ CMDS = { Opts.include, Opts.omit, Opts.show_missing, - Opts.skip_covered + Opts.skip_covered, ] + GLOBAL_ARGS, usage = "[options] [modules]", description = "Report coverage statistics on modules." -- cgit v1.2.1 From ef8c162b454a0f294e348b27bd52475f0e512e59 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Tue, 28 Jul 2015 05:23:24 -0400 Subject: Fix brokenness in combining with an rcfile. #385 --- coverage/cmdline.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'coverage/cmdline.py') diff --git a/coverage/cmdline.py b/coverage/cmdline.py index b4deb58..669c569 100644 --- a/coverage/cmdline.py +++ b/coverage/cmdline.py @@ -436,7 +436,7 @@ class CoverageScript(object): self.do_run(options, args) if options.action == "combine": - data_dirs = argv if argv else None + data_dirs = args or None self.coverage.combine(data_dirs) self.coverage.save() -- cgit v1.2.1 From a98ffc153e5dedb5fed97ed8cbf5fbad65a248bd Mon Sep 17 00:00:00 2001 From: Alexander Todorov Date: Wed, 29 Jul 2015 19:55:43 +0300 Subject: extend combine parameters to allow for file names and shell globs --- coverage/cmdline.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'coverage/cmdline.py') diff --git a/coverage/cmdline.py b/coverage/cmdline.py index 669c569..499444c 100644 --- a/coverage/cmdline.py +++ b/coverage/cmdline.py @@ -252,13 +252,13 @@ CMDS = { ), 'combine': CmdOptionParser("combine", GLOBAL_ARGS, - usage = " ... ", + usage = " ... ", description = "Combine data from multiple coverage files collected " "with 'run -p'. The combined results are written to a single " "file representing the union of the data. The positional " - "arguments are directories from which the data files should be " - "combined. By default, only data files in the current directory " - "are combined." + "arguments are files or directories or shell globs " + "representing the data files which should be combined. " + "By default, only data files in the current directory are combined." ), 'debug': CmdOptionParser("debug", GLOBAL_ARGS, -- cgit v1.2.1 From 7f0e87b3e2a99968e7e49eb8b7d2231b801b7da9 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Thu, 30 Jul 2015 07:13:45 -0400 Subject: Refactoring cmdline in prep for getting --append to work again. --- coverage/cmdline.py | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) (limited to 'coverage/cmdline.py') diff --git a/coverage/cmdline.py b/coverage/cmdline.py index 669c569..c5a75e7 100644 --- a/coverage/cmdline.py +++ b/coverage/cmdline.py @@ -19,7 +19,7 @@ class Opts(object): """A namespace class for individual options we'll build parsers from.""" append = optparse.make_option( - '-a', '--append', action='store_false', dest="erase_first", + '-a', '--append', action='store_true', help="Append coverage data to .coverage, otherwise it is started " "clean with each run." ) @@ -135,11 +135,11 @@ class CoverageOptionParser(optparse.OptionParser, object): ) self.set_defaults( action=None, + append=None, branch=None, concurrency=None, debug=None, directory=None, - erase_first=None, fail_under=None, help=None, ignore_errors=None, @@ -320,7 +320,6 @@ CMDS = { Opts.source, Opts.timid, ] + GLOBAL_ARGS, - defaults = {'erase_first': True}, usage = "[options] [program options]", description = "Run a Python program, measuring code execution." ), @@ -427,18 +426,19 @@ class CoverageScript(object): if options.action == "debug": return self.do_debug(args) - if options.action == "erase" or options.erase_first: + elif options.action == "erase": self.coverage.erase() - else: - self.coverage.load() + return OK - if options.action == "run": - self.do_run(options, args) + elif options.action == "run": + return self.do_run(options, args) - if options.action == "combine": + elif options.action == "combine": + self.coverage.load() data_dirs = args or None self.coverage.combine(data_dirs) self.coverage.save() + return OK # Remaining actions are reporting, with some common options. report_args = dict( @@ -448,19 +448,21 @@ class CoverageScript(object): include = include, ) + self.coverage.load() + total = None if options.action == "report": total = self.coverage.report( show_missing=options.show_missing, skip_covered=options.skip_covered, **report_args) - if options.action == "annotate": + elif options.action == "annotate": self.coverage.annotate( directory=options.directory, **report_args) - if options.action == "html": + elif options.action == "html": total = self.coverage.html_report( directory=options.directory, title=options.title, **report_args) - if options.action == "xml": + elif options.action == "xml": outfile = options.outfile total = self.coverage.xml_report(outfile=outfile, **report_args) @@ -550,6 +552,10 @@ class CoverageScript(object): def do_run(self, options, args): """Implementation of 'coverage run'.""" + if not self.coverage.config.parallel: + if not options.append: + self.coverage.erase() + # Set the first path element properly. old_path0 = sys.path[0] @@ -570,17 +576,25 @@ class CoverageScript(object): finally: self.coverage.stop() if code_ran: + if options.append: + from coverage.data import CoverageData + old_data = CoverageData() + old_data.read_file(self.coverage.config.data_file) + self.coverage.data.update(old_data) self.coverage.save() # Restore the old path sys.path[0] = old_path0 + return OK + def do_debug(self, args): """Implementation of 'coverage debug'.""" if not args: self.help_fn("What information would you like: data, sys?") return ERR + for info in args: if info == 'sys': sys_info = self.coverage.sys_info() @@ -608,6 +622,7 @@ class CoverageScript(object): else: self.help_fn("Don't know what you mean by %r" % info) return ERR + return OK -- cgit v1.2.1 From e812f4dd7e82a9de6323b139c9ae3e02cd16d7f0 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Thu, 30 Jul 2015 07:34:37 -0400 Subject: Clean up from the merge of PR 62 Remove the globbing option. Added a test. Corrected parameter names and docs. Updated the AUTHORS file. --- coverage/cmdline.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'coverage/cmdline.py') diff --git a/coverage/cmdline.py b/coverage/cmdline.py index 5d1b388..a6ae7c3 100644 --- a/coverage/cmdline.py +++ b/coverage/cmdline.py @@ -256,9 +256,9 @@ CMDS = { description = "Combine data from multiple coverage files collected " "with 'run -p'. The combined results are written to a single " "file representing the union of the data. The positional " - "arguments are files or directories or shell globs " - "representing the data files which should be combined. " - "By default, only data files in the current directory are combined." + "arguments are data files or directories containing data files. " + "If no paths are provided, data files in the default data file's " + "directory are combined." ), 'debug': CmdOptionParser("debug", GLOBAL_ARGS, -- cgit v1.2.1 From 8b9ba53c845a304dfddc5a78cf0107365edc505d Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Thu, 30 Jul 2015 10:10:08 -0400 Subject: Get --append working again. --- coverage/cmdline.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'coverage/cmdline.py') diff --git a/coverage/cmdline.py b/coverage/cmdline.py index a6ae7c3..ee239b2 100644 --- a/coverage/cmdline.py +++ b/coverage/cmdline.py @@ -577,10 +577,7 @@ class CoverageScript(object): self.coverage.stop() if code_ran: if options.append: - from coverage.data import CoverageData - old_data = CoverageData() - old_data.read_file(self.coverage.config.data_file) - self.coverage.data.update(old_data) + self.coverage.combine(data_paths=[self.coverage.config.data_file]) self.coverage.save() # Restore the old path -- cgit v1.2.1 From 98f38f393b954f0e99cc16303911fb5bd26f1b61 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Thu, 30 Jul 2015 19:51:08 -0400 Subject: Can't use --append and --parallel-mode together. --- coverage/cmdline.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'coverage/cmdline.py') diff --git a/coverage/cmdline.py b/coverage/cmdline.py index ee239b2..fc40e61 100644 --- a/coverage/cmdline.py +++ b/coverage/cmdline.py @@ -547,6 +547,10 @@ class CoverageScript(object): self.help_fn("Nothing to do.") return False + if options.append and options.parallel_mode: + self.help_fn("Can't append to data files in parallel mode.") + return False + return True def do_run(self, options, args): -- cgit v1.2.1