diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2009-03-15 14:52:45 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2009-03-15 14:52:45 -0400 |
commit | 3f802a17d18f790a997fb5fc7ababcc6bbdaa2b1 (patch) | |
tree | 23d499af8396ac5f6356b9bf2c9008aa6f102640 | |
parent | 739802b74a5fefe6f24b35ab1d7f1894f5315973 (diff) | |
download | python-coveragepy-git-3f802a17d18f790a997fb5fc7ababcc6bbdaa2b1.tar.gz |
The cmdline code now returns a status code.
-rw-r--r-- | TODO.txt | 17 | ||||
-rw-r--r-- | coverage/cmdline.py | 13 |
2 files changed, 25 insertions, 5 deletions
@@ -20,6 +20,7 @@ x Tricky swapping of collector like figleaf, pycov, et al. (Don't need to do - If tracing, canonical_filename_cache overlaps with should_trace_cache. Skip
canonical_filename_cache. Maybe it isn't even worth it...
+
* Accuracy
- Record magic number of module to ensure code hasn't changed
@@ -28,6 +29,7 @@ x Tricky swapping of collector like figleaf, pycov, et al. (Don't need to do sense together.
- Do I still need the lines in annotate_file that deal specially with "else"?
+
* Power
- API for getting coverage data.
@@ -38,6 +40,7 @@ x Tricky swapping of collector like figleaf, pycov, et al. (Don't need to do - Track callers of functions (ala std module trace)
- Method/Class/Module coverage reporting.
+
* Convenience
- Why can't you specify execute (-x) and report (-r) in the same invocation?
@@ -46,6 +49,7 @@ x Tricky swapping of collector like figleaf, pycov, et al. (Don't need to do - Support 2.3 - 3.0?
http://pythonology.blogspot.com/2009/02/making-code-run-on-python-20-through-30.html
+
* Beauty
- HTML report
@@ -53,6 +57,7 @@ x Tricky swapping of collector like figleaf, pycov, et al. (Don't need to do - Dynamic effects in HTML report
- Footer in reports pointing to coverage home page.
+
* Community
- New docs, rather than pointing to Gareth's
@@ -67,6 +72,14 @@ x Tricky swapping of collector like figleaf, pycov, et al. (Don't need to do - Point discussion to TIP
- PEP 8 compliance?
+
+* Programmability
+
++ Don't use sys.exit in CoverageScript.
++ Remove singleton
+ + Initialization of instance variables in the class.
+
+
* Modernization
+ Decide on minimum supported version
@@ -77,8 +90,6 @@ x Tricky swapping of collector like figleaf, pycov, et al. (Don't need to do - Get rid of the recursive nonsense.
- Docstrings.
+ Remove huge document-style comments.
-+ Remove singleton
- + Initialization of instance variables in the class.
- Better names:
+ self.cache -> self.cache_filename -> CoverageData.filename
+ self.usecache -> CoverageData.use_file
@@ -95,10 +106,12 @@ x Tricky swapping of collector like figleaf, pycov, et al. (Don't need to do + lineno
+ filename
+
* Correctness
- What does -p (parallel mode) mean with -e (erase data)?
+
* Tests
+ Switch to a real test runner, like nose.
diff --git a/coverage/cmdline.py b/coverage/cmdline.py index 0787f19e..2d4977c7 100644 --- a/coverage/cmdline.py +++ b/coverage/cmdline.py @@ -45,6 +45,7 @@ Coverage data is saved in the file .coverage by default. Set the COVERAGE_FILE environment variable to save it somewhere else. """.strip() + class CoverageScript: def __init__(self): import coverage @@ -56,11 +57,11 @@ class CoverageScript: print error print print USAGE % self.covpkg.__dict__ - sys.exit(1) def command_line(self, argv, help_fn=None): # Collect the command-line options. help_fn = help_fn or self.help + OK, ERR = 0, 1 settings = {} optmap = { '-a': 'annotate', @@ -90,6 +91,7 @@ class CoverageScript: if settings.get('help'): help_fn() + return OK # Check for conflicts and problems in the options. for i in ['erase', 'execute']: @@ -97,6 +99,7 @@ class CoverageScript: if settings.get(i) and settings.get(j): help_fn("You can't specify the '%s' and '%s' " "options at the same time." % (i, j)) + return ERR args_needed = (settings.get('execute') or settings.get('annotate') @@ -106,8 +109,10 @@ class CoverageScript: or args_needed) if not action: help_fn("You must specify at least one of -e, -x, -c, -r, or -a.") + return ERR if not args_needed and args: help_fn("Unexpected arguments: %s" % " ".join(args)) + return ERR # Do something. self.coverage.parallel_mode = settings.get('parallel-mode') @@ -119,6 +124,7 @@ class CoverageScript: if settings.get('execute'): if not args: help_fn("Nothing to do.") + return ERR # Create the runtime environment the script on the cmdline expects. sys.argv = args sys.path[0] = os.path.dirname(sys.argv[0]) @@ -144,9 +150,10 @@ class CoverageScript: if settings.get('annotate'): reporter = AnnotateReporter(self.coverage, ignore_errors) reporter.report(args, directory, omit_prefixes=omit) - + + return OK # Main entrypoint. This is installed as the script entrypoint, so don't # refactor it away... def main(): - CoverageScript().command_line(sys.argv[1:]) + return CoverageScript().command_line(sys.argv[1:]) |