From c6eac1583aada3d34e98fc8c490b1909221bfbcb Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Thu, 12 Mar 2009 08:15:12 -0400 Subject: Wondering about the mechanics of running the user's script. --- TODO.txt | 2 ++ coverage/cmdline.py | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/TODO.txt b/TODO.txt index 0fde057a..7f418aa5 100644 --- a/TODO.txt +++ b/TODO.txt @@ -102,6 +102,7 @@ x Tricky swapping of collector like figleaf, pycov, et al. (Don't need to do * Tests +- Switch to a real test runner, like nose. - Tests about the .coverage file. - Tests about the --long-form of arguments. - Tests about overriding the .coverage filename. @@ -111,3 +112,4 @@ x Tricky swapping of collector like figleaf, pycov, et al. (Don't need to do - Coverage test coverage.py! - Tests that tracing stops after calling stop() - More intensive thread testing. +- Tests about the "import __main__" in cmdline.py diff --git a/coverage/cmdline.py b/coverage/cmdline.py index 58eae714..0561f327 100644 --- a/coverage/cmdline.py +++ b/coverage/cmdline.py @@ -112,14 +112,18 @@ class CoverageScript: if settings.get('erase'): self.coverage.erase() + if settings.get('execute'): if not args: help_fn("Nothing to do.") + # Create the runtime environment the script on the cmdline expects. sys.argv = args - self.coverage.start() - import __main__ sys.path[0] = os.path.dirname(sys.argv[0]) + import __main__ # TODO: I think this is useless... + self.coverage.start() execfile(sys.argv[0], __main__.__dict__) + self.coverage.stop() + if settings.get('combine'): self.coverage.combine() -- cgit v1.2.1