diff options
-rw-r--r-- | CHANGES.rst | 7 | ||||
-rw-r--r-- | coverage/cmdline.py | 10 | ||||
-rw-r--r-- | coverage/config.py | 6 | ||||
-rw-r--r-- | coverage/control.py | 11 | ||||
-rw-r--r-- | coverage/data.py | 11 | ||||
-rw-r--r-- | doc/cmd.rst | 5 | ||||
-rw-r--r-- | tests/test_api.py | 17 | ||||
-rw-r--r-- | tests/test_cmdline.py | 14 | ||||
-rw-r--r-- | tests/test_config.py | 5 | ||||
-rw-r--r-- | tests/test_process.py | 2 |
10 files changed, 21 insertions, 67 deletions
diff --git a/CHANGES.rst b/CHANGES.rst index dbfd1908..71b2689d 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -9,10 +9,9 @@ Change history for Coverage.py Version 4.1 ----------- -- When combining data files, you can now ignore errors while reading the data - files, using the ``--ignore-errors`` command line switch, or the ``[combine] - ignore_errors`` configuration file setting. I don't understand why people - are seeing corrupt data files, but this lets them continue combining anyway. +- When combining data files, unreadable files will now generate a warning + instead of failing the command. This is more in line with the older + coverage.py v3.7.1 behavior, which silently ignored unreadable files. Prompted by `issue 418`_. - Code that uses ``sys.settrace(sys.gettrace())`` used to incur more than a 2x diff --git a/coverage/cmdline.py b/coverage/cmdline.py index 6f5719fd..46a87ca6 100644 --- a/coverage/cmdline.py +++ b/coverage/cmdline.py @@ -58,10 +58,6 @@ class Opts(object): '-i', '--ignore-errors', action='store_true', help="Ignore errors while reading source files.", ) - ignore_combine_errors = optparse.make_option( - '-i', '--ignore-errors', action='store_true', - help="Ignore errors while reading data files.", - ) include = optparse.make_option( '', '--include', action='store', metavar="PAT1,PAT2,...", @@ -270,9 +266,7 @@ CMDS = { 'combine': CmdOptionParser( "combine", - [ - Opts.ignore_combine_errors, - ] + GLOBAL_ARGS, + GLOBAL_ARGS, usage="<path1> <path2> ... <pathN>", description=( "Combine data from multiple coverage files collected " @@ -471,7 +465,7 @@ class CoverageScript(object): elif options.action == "combine": self.coverage.load() data_dirs = args or None - self.coverage.combine(data_dirs, ignore_errors=options.ignore_errors) + self.coverage.combine(data_dirs) self.coverage.save() return OK diff --git a/coverage/config.py b/coverage/config.py index 8aff41dc..458d4903 100644 --- a/coverage/config.py +++ b/coverage/config.py @@ -162,9 +162,6 @@ class CoverageConfig(object): self.source = None self.timid = False - # Defaults for [combine] - self.ignore_combine_errors = False - # Defaults for [report] self.exclude_list = DEFAULT_EXCLUDE[:] self.fail_under = 0 @@ -280,9 +277,6 @@ class CoverageConfig(object): ('source', 'run:source', 'list'), ('timid', 'run:timid', 'boolean'), - # [combine] - ('ignore_combine_errors', 'combine:ignore_errors', 'boolean'), - # [report] ('exclude_list', 'report:exclude_lines', 'regexlist'), ('fail_under', 'report:fail_under', 'int'), diff --git a/coverage/control.py b/coverage/control.py index a5741a47..1fb0f5bf 100644 --- a/coverage/control.py +++ b/coverage/control.py @@ -763,7 +763,7 @@ class Coverage(object): self.get_data() self.data_files.write(self.data, suffix=self.data_suffix) - def combine(self, data_paths=None, ignore_errors=None): + def combine(self, data_paths=None): """Combine together a number of similarly-named coverage data files. All coverage data files whose name starts with `data_file` (from the @@ -782,8 +782,6 @@ class Coverage(object): self._init() self.get_data() - self.config.from_args(ignore_combine_errors=ignore_errors) - aliases = None if self.config.paths: aliases = PathAliases() @@ -792,12 +790,7 @@ class Coverage(object): for pattern in paths[1:]: aliases.add(pattern, result) - self.data_files.combine_parallel_data( - self.data, - aliases=aliases, - data_paths=data_paths, - ignore_errors=self.config.ignore_combine_errors, - ) + self.data_files.combine_parallel_data(self.data, aliases=aliases, data_paths=data_paths) def get_data(self): """Get the collected data and reset the collector. diff --git a/coverage/data.py b/coverage/data.py index b8d9dadf..fb0b0224 100644 --- a/coverage/data.py +++ b/coverage/data.py @@ -662,7 +662,7 @@ class CoverageDataFiles(object): filename += "." + suffix data.write_file(filename) - def combine_parallel_data(self, data, aliases=None, data_paths=None, ignore_errors=False): + def combine_parallel_data(self, data, aliases=None, data_paths=None): """Combine a number of data files together. Treat `self.filename` as a file prefix, and combine the data from all @@ -678,10 +678,9 @@ class CoverageDataFiles(object): If `data_paths` is not provided, then the directory portion of `self.filename` is used as the directory to search for data files. - Every data file found and combined is then deleted from disk. - - If `ignore_errors` is True, then files that cannot be read will cause - a warning, and will not be deleted. + Every data file found and combined is then deleted from disk. If a file + cannot be read, a warning will be issued, and the file will not be + deleted. """ # Because of the os.path.abspath in the constructor, data_dir will @@ -705,8 +704,6 @@ class CoverageDataFiles(object): try: new_data.read_file(f) except CoverageException as exc: - if not ignore_errors: - raise if self.warn: # The CoverageException has the file name in it, so just # use the message as the warning. diff --git a/doc/cmd.rst b/doc/cmd.rst index e9695ef8..dab226d7 100644 --- a/doc/cmd.rst +++ b/doc/cmd.rst @@ -221,9 +221,8 @@ systems, coverage.py won't know how to combine the data. You can tell coverage.py how the different locations correlate with a ``[paths]`` section in your configuration file. See :ref:`config_paths` for details. -Some techniques for collecting data can result in corrupt data files. If you -have this problem, you can use the ``--ignore-errors`` option to turn those -errors into warnings instead. +If any data files can't be read, coverage.py will print a warning indicating +the file and the problem. .. _cmd_reporting: diff --git a/tests/test_api.py b/tests/test_api.py index ad322224..a7cadab3 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -305,19 +305,8 @@ class ApiTest(CoverageTest): self.make_file(".coverage.foo", """La la la, this isn't coverage data!""") def test_combining_corrupt_data(self): - self.make_corrupt_data_files() - cov = coverage.Coverage() - - msg = r"Couldn't read data from '.*\.coverage\.foo'" - with self.assertRaisesRegex(CoverageException, msg): - cov.combine() - - # The bad file still exists. - self.assert_exists(".coverage.foo") - - def test_combining_corrupt_data_while_ignoring_errors(self): - # If you combine a corrupt data file with ignore_errors=True, then you - # will get a warning, and the file will remain. + # If you combine a corrupt data file, then you will get a warning, + # and the file will remain. self.make_corrupt_data_files() cov = coverage.Coverage() warning_regex = ( @@ -325,7 +314,7 @@ class ApiTest(CoverageTest): r"CoverageException: Doesn't seem to be a coverage\.py data file" ) with self.assert_warnings(cov, [warning_regex]): - cov.combine(ignore_errors=True) + cov.combine() # We got the results from code1 and code2 properly. self.check_code1_code2(cov) diff --git a/tests/test_cmdline.py b/tests/test_cmdline.py index 932c9ef9..c78e3468 100644 --- a/tests/test_cmdline.py +++ b/tests/test_cmdline.py @@ -190,20 +190,14 @@ class CmdLineTest(BaseCmdLineTest): self.cmd_executes("combine datadir1", """\ .coverage() .load() - .combine(["datadir1"], ignore_errors=None) + .combine(["datadir1"]) .save() """) # coverage combine without args self.cmd_executes("combine", """\ .coverage() .load() - .combine(None, ignore_errors=None) - .save() - """) - self.cmd_executes("combine -i", """\ - .coverage() - .load() - .combine(None, ignore_errors=True) + .combine(None) .save() """) @@ -212,13 +206,13 @@ class CmdLineTest(BaseCmdLineTest): self.cmd_executes("combine --rcfile cov.ini", """\ .coverage(config_file='cov.ini') .load() - .combine(None, ignore_errors=None) + .combine(None) .save() """) self.cmd_executes("combine --rcfile cov.ini data1 data2/more", """\ .coverage(config_file='cov.ini') .load() - .combine(["data1", "data2/more"], ignore_errors=None) + .combine(["data1", "data2/more"]) .save() """) diff --git a/tests/test_config.py b/tests/test_config.py index 6d6c7f80..93a7bbf6 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -235,9 +235,6 @@ class ConfigFileTest(CoverageTest): plugins.a_plugin plugins.another - [{section}combine] - ignore_errors = True - [{section}report] ; these settings affect reporting. exclude_lines = @@ -304,8 +301,6 @@ class ConfigFileTest(CoverageTest): self.assertTrue(cov.config.parallel) self.assertEqual(cov.config.concurrency, "thread") - self.assertTrue(cov.config.ignore_combine_errors) - self.assertEqual(cov.get_exclude_list(), ["if 0:", r"pragma:?\s+no cover", "another_tab"]) self.assertTrue(cov.config.ignore_errors) self.assertEqual(cov.config.include, ["a/", "b/"]) diff --git a/tests/test_process.py b/tests/test_process.py index b41472d6..4902f7c0 100644 --- a/tests/test_process.py +++ b/tests/test_process.py @@ -112,7 +112,7 @@ class ProcessTest(CoverageTest): self.make_file(".coverage.bad", "This isn't a coverage data file.") # Combine the parallel coverage data files into .coverage . - out = self.run_command("coverage combine -i") + out = self.run_command("coverage combine") self.assert_exists(".coverage") self.assert_exists(".coverage.bad") warning_regex = ( |