diff options
-rw-r--r-- | CHANGES.rst | 14 | ||||
-rw-r--r-- | coverage/cmdline.py | 11 | ||||
-rw-r--r-- | tests/test_cmdline.py | 10 |
3 files changed, 35 insertions, 0 deletions
diff --git a/CHANGES.rst b/CHANGES.rst index 3320bfe2..5ee96129 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -5,6 +5,20 @@ Change history for Coverage.py ============================== +Unreleased +---------- + +- Since ``concurrency=multiprocessing`` uses subprocesses, options specified on + the coverage.py command line will not be communicated down to them. Only + options in the configuration file will apply to the subprocesses. + Previously, the options didn't apply to the subprocesses, but there was no + indication. Now it is an error to use ``--concurrency=multiprocessing`` and + other run-affecting options on the command line. This prevents + failures like those reported in `issue 495`_. + +.. _issue 495: https://bitbucket.org/ned/coveragepy/issues/495/branch-and-concurrency-are-conflicting + + Version 4.2b1 --- 2016-07-04 ---------------------------- diff --git a/coverage/cmdline.py b/coverage/cmdline.py index e5306407..20d35892 100644 --- a/coverage/cmdline.py +++ b/coverage/cmdline.py @@ -602,6 +602,17 @@ class CoverageScript(object): self.help_fn("Can't append to data files in parallel mode.") return ERR + if options.concurrency == "multiprocessing": + # Can't set other run-affecting command line options with + # multiprocessing. + for opt_name in ['branch', 'include', 'omit', 'pylib', 'source', 'timid']: + if getattr(options, opt_name) != getattr(Opts, opt_name).default: + self.help_fn( + "Options affecting multiprocessing must be specified " + "in a configuration file." + ) + return ERR + if not self.coverage.get_option("run:parallel"): if not options.append: self.coverage.erase() diff --git a/tests/test_cmdline.py b/tests/test_cmdline.py index d72fd83c..f2531605 100644 --- a/tests/test_cmdline.py +++ b/tests/test_cmdline.py @@ -464,6 +464,16 @@ class CmdLineTest(BaseCmdLineTest): out = self.stdout() self.assertIn("option --concurrency: invalid choice: 'multiprocessing,gevent'", out) + def test_multiprocessing_needs_config_file(self): + # You can't use command-line args to add options to multiprocessing + # runs, since they won't make it to the subprocesses. You need to use a + # config file. + self.command_line("run --concurrency=multiprocessing --branch foo.py", ret=ERR) + self.assertIn( + "Options affecting multiprocessing must be specified in a configuration file.", + self.stdout() + ) + def test_run_debug(self): self.cmd_executes("run --debug=opt1 foo.py", """\ .coverage(debug=["opt1"]) |