From 66d5fefdbb498690e47602b5ee953b9734964687 Mon Sep 17 00:00:00 2001 From: Peter Galantha Date: Tue, 19 Dec 2017 17:12:14 -0800 Subject: [PATCH] fix for coverage reports w/ absolute file path (#69) fix for coverage reports w/ absolute file path --- CHANGELOG | 4 ++++ diff_cover/__init__.py | 2 +- diff_cover/command_runner.py | 4 ++++ diff_cover/tests/test_java_violations_reporter.py | 2 +- diff_cover/violationsreporters/java_violations_reporter.py | 2 +- 5 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 1b38c148..0a49c344 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,7 @@ +12/19/2017 v1.0.2 + + * Fix bug where clover uses absolute path in its xml report + 12/08/2017 v1.0.1 * Add Support for clover and checkstyle diff --git a/diff_cover/__init__.py b/diff_cover/__init__.py index 687e6fdb..a04f87a2 100644 --- a/diff_cover/__init__.py +++ b/diff_cover/__init__.py @@ -1,3 +1,3 @@ -VERSION = '1.0.1' +VERSION = '1.0.2' DESCRIPTION = 'Automatically find diff lines that need test coverage.' QUALITY_DESCRIPTION = 'Automatically find diff lines with quality violations.' diff --git a/diff_cover/command_runner.py b/diff_cover/command_runner.py index 4586fbec..7922a55f 100644 --- a/diff_cover/command_runner.py +++ b/diff_cover/command_runner.py @@ -1,3 +1,4 @@ +import re import six import subprocess @@ -38,6 +39,9 @@ def execute(command): raise stderr = _ensure_unicode(stderr) + # after version 1.8.0 pylint writes a message to stderr: + # Using config file {} + stderr = re.sub(r'^Using config file .*$', '', stderr).strip() # If we get a non-empty output to stderr, raise an exception if bool(stderr) and process.returncode: raise CommandError(stderr) diff --git a/diff_cover/tests/test_java_violations_reporter.py b/diff_cover/tests/test_java_violations_reporter.py index f3e56e3c..640149d0 100644 --- a/diff_cover/tests/test_java_violations_reporter.py +++ b/diff_cover/tests/test_java_violations_reporter.py @@ -45,7 +45,7 @@ class CloverXmlCoverageReporterTest(unittest.TestCase): def setUp(self): # Paths generated by git_path are always the given argument - _git_path_mock = patch('diff_cover.violationsreporters.violations_reporter.GitPathTool').start() + _git_path_mock = patch('diff_cover.violationsreporters.java_violations_reporter.GitPathTool').start() _git_path_mock.relative_path = lambda path: path _git_path_mock.absolute_path = lambda path: path diff --git a/diff_cover/violationsreporters/java_violations_reporter.py b/diff_cover/violationsreporters/java_violations_reporter.py index 9497ffa8..c68e6970 100644 --- a/diff_cover/violationsreporters/java_violations_reporter.py +++ b/diff_cover/violationsreporters/java_violations_reporter.py @@ -39,7 +39,7 @@ def _get_src_path_line_nodes(xml_document, src_path): """ files = [file_tree for file_tree in xml_document.findall(".//file") - if file_tree.get('path') == src_path + if GitPathTool.relative_path(file_tree.get('path')) == src_path or []] if not files: return None