Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(952)

Unified Diff: third_party/coverage-3.7.1/coverage/cmdline.py

Issue 225633007: Upgrade to coverage 3.7.1 and have it auto-build itself on first use. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: sigh our imports are a mess Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/coverage-3.7.1/coverage/bytecode.py ('k') | third_party/coverage-3.7.1/coverage/codeunit.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/coverage-3.7.1/coverage/cmdline.py
diff --git a/third_party/coverage-3.6/coverage/cmdline.py b/third_party/coverage-3.7.1/coverage/cmdline.py
similarity index 96%
rename from third_party/coverage-3.6/coverage/cmdline.py
rename to third_party/coverage-3.7.1/coverage/cmdline.py
index cb1d7a3e7bcf76c4672eed3e5ca0786eb80485a5..ea112a8b8f2d425be141bdde38a9603d9c685b34 100644
--- a/third_party/coverage-3.6/coverage/cmdline.py
+++ b/third_party/coverage-3.7.1/coverage/cmdline.py
@@ -1,10 +1,11 @@
"""Command-line support for Coverage."""
-import optparse, sys, traceback
+import optparse, os, sys, time, traceback
from coverage.backward import sorted # pylint: disable=W0622
from coverage.execfile import run_python_file, run_python_module
from coverage.misc import CoverageException, ExceptionDuringRun, NoSource
+from coverage.debug import info_formatter
class Opts(object):
@@ -19,6 +20,10 @@ class Opts(object):
'', '--branch', action='store_true',
help="Measure branch coverage in addition to statement coverage."
)
+ debug = optparse.make_option(
+ '', '--debug', action='store', metavar="OPTS",
+ help="Debug options, separated by commas"
+ )
directory = optparse.make_option(
'-d', '--directory', action='store', metavar="DIR",
help="Write the output files to DIR."
@@ -117,6 +122,7 @@ class CoverageOptionParser(optparse.OptionParser, object):
self.set_defaults(
actions=[],
branch=None,
+ debug=None,
directory=None,
fail_under=None,
help=None,
@@ -310,6 +316,7 @@ CMDS = {
[
Opts.append,
Opts.branch,
+ Opts.debug,
Opts.pylib,
Opts.parallel_mode,
Opts.module,
@@ -404,6 +411,7 @@ class CoverageScript(object):
source = unshell_list(options.source)
omit = unshell_list(options.omit)
include = unshell_list(options.include)
+ debug = unshell_list(options.debug)
# Do something.
self.coverage = self.covpkg.coverage(
@@ -415,6 +423,7 @@ class CoverageScript(object):
source = source,
omit = omit,
include = include,
+ debug = debug,
)
if 'debug' in options.actions:
@@ -549,15 +558,21 @@ class CoverageScript(object):
def do_execute(self, options, args):
"""Implementation of 'coverage run'."""
+ # Set the first path element properly.
+ old_path0 = sys.path[0]
+
# Run the script.
self.coverage.start()
code_ran = True
try:
try:
if options.module:
+ sys.path[0] = ''
self.run_python_module(args[0], args)
else:
- self.run_python_file(args[0], args)
+ filename = args[0]
+ sys.path[0] = os.path.abspath(os.path.dirname(filename))
+ self.run_python_file(filename, args)
except NoSource:
code_ran = False
raise
@@ -566,6 +581,9 @@ class CoverageScript(object):
if code_ran:
self.coverage.save()
+ # Restore the old path
+ sys.path[0] = old_path0
+
def do_debug(self, args):
"""Implementation of 'coverage debug'."""
@@ -575,16 +593,8 @@ class CoverageScript(object):
for info in args:
if info == 'sys':
print("-- sys ----------------------------------------")
- for label, info in self.coverage.sysinfo():
- if info == []:
- info = "-none-"
- if isinstance(info, list):
- prefix = "%15s:" % label
- for e in info:
- print("%16s %s" % (prefix, e))
- prefix = ""
- else:
- print("%15s: %s" % (label, info))
+ for line in info_formatter(self.coverage.sysinfo()):
+ print(" %s" % line)
elif info == 'data':
print("-- data ---------------------------------------")
self.coverage.load()
@@ -707,7 +717,11 @@ def main(argv=None):
if argv is None:
argv = sys.argv[1:]
try:
+ start = time.clock()
status = CoverageScript().command_line(argv)
+ end = time.clock()
+ if 0:
+ print("time: %.3fs" % (end - start))
except ExceptionDuringRun:
# An exception was caught while running the product code. The
# sys.exc_info() return tuple is packed into an ExceptionDuringRun
« no previous file with comments | « third_party/coverage-3.7.1/coverage/bytecode.py ('k') | third_party/coverage-3.7.1/coverage/codeunit.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698