From f5eb0c766d6d529b2d6b8c8984bc0f953f9b6770 Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Mon, 26 Nov 2012 10:32:57 +0100 Subject: Provide intelligent warnings for missing/invalid .gcno files No gcno file indicates that the the source was not built with code coverage. If the gcno file exists but predates the source file, then probably not rebuilt since last change. --- git-coverage | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/git-coverage b/git-coverage index f9c22f1..102b6ca 100755 --- a/git-coverage +++ b/git-coverage @@ -34,6 +34,9 @@ def match_any_re(regexps, line): return True return False +def warning(string): + print >> sys.stderr, string + # ---------------------------------------------------------------------------- # PATCH PARSING # @@ -248,9 +251,20 @@ class GccCoverage: match = "%s/*%s.gcno" % (directory, base) else: match = "*%s.gcno" % (base, ) + bad_mtime = False + mtime = os.path.getmtime(filename) for gcno in self._gcno_cache: if fnmatch.fnmatch(gcno, match): - matches.append(gcno) + if os.path.getctime(gcno) < mtime: + bad_mtime = True + else: + matches.append(gcno) + + if not matches: + if bad_mtime: + warning("%s: Found old coverage data, likely not built" % filename) + else: + warning("%s: Found no coverage data" % filename) return matches def _find_directory_gcno_compiled_in(self, gcno, filename): -- cgit v1.2.3