summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStef Walter <stefw@redhat.com>2014-04-17 06:31:56 (UTC)
committer Stef Walter <stefw@redhat.com>2014-04-17 06:31:56 (UTC)
commit1898dd5e2107005eccbd7999de9d1dabff772d7f (patch)
tree71364ee80af94c83dce05fd2e1b90d016103e446
parentc9cbfab9f6325ce4ef01292287734a1cb2243e3c (diff)
Fix lookup up out of tree builds with subdir-objectsHEADmaster
-rwxr-xr-xgit-coverage32
1 files changed, 21 insertions, 11 deletions
diff --git a/git-coverage b/git-coverage
index 483e9e7..11f5202 100755
--- a/git-coverage
+++ b/git-coverage
@@ -283,15 +283,24 @@ class GccCoverage:
paths.append(os.path.abspath(path))
os.path.walk(".", visit, self._gcno_unresolved)
- def _directory_gcno_compiled_in(self, gcno):
- (directory, base) = os.path.split(gcno)
-
- # libtool always gets it's grubby little fingers involved
- (parent, last) = os.path.split(directory)
- if last == ".libs":
- return parent
-
- return directory
+ def _directory_gcno_compiled_in(self, gcno, source):
+ (directory, unused) = os.path.split(gcno)
+ (srcdir, unused) = os.path.split(source)
+
+ # Remove any common bits from gcno and source
+ # paths to account for automake subdir-objects
+ while True:
+ (parent, last) = os.path.split(directory)
+ (sparent, slast) = os.path.split(srcdir)
+
+ # libtool always gets it's grubby little fingers involved
+ if last == ".libs":
+ directory = parent
+ elif last == slast:
+ directory = parent
+ srcdir = sparent
+ else:
+ return directory
def _add_to_gcno_cache(self, gcno, source):
if source not in self._gcno_cache:
@@ -330,13 +339,14 @@ class GccCoverage:
# Run the gcno file through gcov in the --no-output mode
# which will tell us the source file(s) it represents
- directory = self._directory_gcno_compiled_in(gcno)
for line in subprocess_lines(cmd + [gcno]):
match = self._file_re.match(line.strip())
if not match:
continue
filename = match.group(1)
+ directory = self._directory_gcno_compiled_in(gcno, filename)
+
# We've found a gcno/source combination, make note of it
path = os.path.join(directory, filename)
self._add_to_gcno_cache(gcno, os.path.normpath(path))
@@ -377,7 +387,7 @@ class GccCoverage:
for gcno in self._lookup_gcno_files(filename):
# Need to run gcov in the same directory compiled in
- directory = self._directory_gcno_compiled_in(gcno)
+ directory = self._directory_gcno_compiled_in(gcno, filename)
oldcwd = os.getcwd()
os.chdir(directory)