From 6e237fd092ffb7690d9549ba295fa09dcb9bccdd Mon Sep 17 00:00:00 2001 From: Camilo Nova Date: Sat, 23 Nov 2013 15:48:38 -0500 Subject: [PATCH] Make excluding files really work Exclude locations must be paths, and should not be an empty list, if don't want to exclude anything should be None. --- discover_jenkins/tasks/with_coverage.py | 37 ++++++++----------------- 1 file changed, 12 insertions(+), 25 deletions(-) diff --git a/discover_jenkins/tasks/with_coverage.py b/discover_jenkins/tasks/with_coverage.py index 0fdcf79..cf8e7ea 100755 --- a/discover_jenkins/tasks/with_coverage.py +++ b/discover_jenkins/tasks/with_coverage.py @@ -49,9 +49,9 @@ class CoverageTask(object): make_option( "--coverage-exclude", action="append", - default=settings.COVERAGE_EXCLUDES, + default=settings.COVERAGE_EXCLUDE_PATHS, dest="coverage_excludes", - help="Module name to exclude" + help="Paths to be excluded from coverage" ) ) @@ -60,22 +60,7 @@ class CoverageTask(object): self.with_migrations = options['coverage_with_migrations'] self.html_dir = options['coverage_html_report_dir'] self.branch = options['coverage_measure_branch'] - - self.exclude_locations = [] - modnames = options['coverage_excludes'] - for modname in modnames: - try: - self.exclude_locations.append( - os.path.dirname( - import_module(modname).__file__ - ) - ) - except ImportError: - pass - - # Extra folders to exclude. Particularly useful to specify things like - # apps/company/migrations/* - self.exclude_locations.extend(settings.COVERAGE_EXCLUDES_FOLDERS) + self.exclude_locations = options['coverage_excludes'] or None self.coverage = coverage( branch=self.branch, @@ -95,18 +80,20 @@ class CoverageTask(object): if not os.path.exists(self.output_dir): os.makedirs(self.output_dir) - self.coverage.xml_report(morfs=morfs, - outfile=os.path.join( - self.output_dir, 'coverage.xml')) + + self.coverage.xml_report( + morfs=morfs, + outfile=os.path.join(self.output_dir, 'coverage.xml') + ) if self.html_dir: - self.coverage.html_report(morfs=morfs, directory=self.html_dir) + self.coverage.html_report( + morfs=morfs, + directory=self.html_dir + ) def want_file(self, filename): if not self.with_migrations and '/migrations/' in filename: return False - for location in self.exclude_locations: - if filename.startswith(location): - return False return True