diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2014-10-26 16:08:29 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2014-10-26 16:08:29 -0400 |
commit | 48e5456376c0937b47df99862f2c4ab29fea599c (patch) | |
tree | 82d76ba1850e073a4b0437b5ced53e12095878ff /coverage | |
parent | 9b8e67fe48ca5d9d1d6e1a7f03eac625388cc7c7 (diff) | |
download | python-coveragepy-git-48e5456376c0937b47df99862f2c4ab29fea599c.tar.gz |
Allow the --debug switch on any command
Diffstat (limited to 'coverage')
-rw-r--r-- | coverage/cmdline.py | 15 | ||||
-rw-r--r-- | coverage/control.py | 46 |
2 files changed, 29 insertions, 32 deletions
diff --git a/coverage/cmdline.py b/coverage/cmdline.py index 3d1f5f6a..e3a09bb5 100644 --- a/coverage/cmdline.py +++ b/coverage/cmdline.py @@ -1,6 +1,6 @@ """Command-line support for Coverage.""" -import glob, optparse, os, sys, time, traceback +import glob, optparse, os, sys, traceback from coverage.execfile import run_python_file, run_python_module from coverage.misc import CoverageException, ExceptionDuringRun, NoSource @@ -218,8 +218,9 @@ class CmdOptionParser(CoverageOptionParser): return (other == "<CmdOptionParser:%s>" % self.cmd) GLOBAL_ARGS = [ - Opts.rcfile, + Opts.debug, Opts.help, + Opts.rcfile, ] CMDS = { @@ -293,7 +294,6 @@ CMDS = { Opts.append, Opts.branch, Opts.concurrency, - Opts.debug, Opts.pylib, Opts.parallel_mode, Opts.module, @@ -577,12 +577,13 @@ class CoverageScript(object): return ERR for info in args: if info == 'sys': + sysinfo = self.coverage.sysinfo() print("-- sys ----------------------------------------") - for line in info_formatter(self.coverage.sysinfo()): + for line in info_formatter(sysinfo): print(" %s" % line) elif info == 'data': - print("-- data ---------------------------------------") self.coverage.load() + print("-- data ---------------------------------------") print("path: %s" % self.coverage.data.filename) print("has_arcs: %r" % self.coverage.data.has_arcs()) summary = self.coverage.data.summary(fullpath=True) @@ -667,11 +668,7 @@ 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 as err: # An exception was caught while running the product code. The # sys.exc_info() return tuple is packed into an ExceptionDuringRun diff --git a/coverage/control.py b/coverage/control.py index 66979c33..4c087655 100644 --- a/coverage/control.py +++ b/coverage/control.py @@ -262,6 +262,29 @@ class Coverage(object): self._inited = True + # Create the matchers we need for _should_trace + if self.source or self.source_pkgs: + self.source_match = TreeMatcher(self.source) + else: + if self.cover_dir: + self.cover_match = TreeMatcher([self.cover_dir]) + if self.pylib_dirs: + self.pylib_match = TreeMatcher(self.pylib_dirs) + if self.include: + self.include_match = FnmatchMatcher(self.include) + if self.omit: + self.omit_match = FnmatchMatcher(self.omit) + + # The user may want to debug things, show info if desired. + if self.debug.should('config'): + self.debug.write("Configuration values:") + config_info = sorted(self.config.__dict__.items()) + self.debug.write_formatted_info(config_info) + + if self.debug.should('sys'): + self.debug.write("Debugging info:") + self.debug.write_formatted_info(self.sysinfo()) + def _canonical_dir(self, morf): """Return the canonical directory of the module or file `morf`.""" morf_filename = PythonCodeUnit(morf, self.file_locator).filename @@ -495,29 +518,6 @@ class Coverage(object): if self._auto_data: self.load() - # Create the matchers we need for _should_trace - if self.source or self.source_pkgs: - self.source_match = TreeMatcher(self.source) - else: - if self.cover_dir: - self.cover_match = TreeMatcher([self.cover_dir]) - if self.pylib_dirs: - self.pylib_match = TreeMatcher(self.pylib_dirs) - if self.include: - self.include_match = FnmatchMatcher(self.include) - if self.omit: - self.omit_match = FnmatchMatcher(self.omit) - - # The user may want to debug things, show info if desired. - if self.debug.should('config'): - self.debug.write("Configuration values:") - config_info = sorted(self.config.__dict__.items()) - self.debug.write_formatted_info(config_info) - - if self.debug.should('sys'): - self.debug.write("Debugging info:") - self.debug.write_formatted_info(self.sysinfo()) - self.collector.start() self._started = True self._measured = True |