From 130b1a2f0b221d584d65edf035906fb0e8c45996 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Tue, 28 Jul 2015 06:46:25 -0400 Subject: When directories are provided to combine data files, fail if one doesn't exist. --- coverage/data.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'coverage/data.py') diff --git a/coverage/data.py b/coverage/data.py index 7e14a69..de68dba 100644 --- a/coverage/data.py +++ b/coverage/data.py @@ -601,15 +601,23 @@ class CoverageDataFiles(object): re-map paths to match the local machine's. If `data_dirs` is provided, then it combines the data files from each - directory into a single file. + directory into a single file. If `data_dirs` 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. """ + # Because of the os.path.abspath in the constructor, data_dir will + # never be an empty string. data_dir, local = os.path.split(self.filename) localdot = local + '.*' data_dirs = data_dirs or [data_dir] files_to_combine = [] for d in data_dirs: + if not os.path.isdir(d): + raise CoverageException("Couldn't combine from non-existent directory '%s'" % (d,)) pattern = os.path.join(os.path.abspath(d), localdot) files_to_combine.extend(glob.glob(pattern)) -- cgit v1.2.1