From 43634380ce409627d74e37823fa91425cf0a3898 Mon Sep 17 00:00:00 2001 Message-Id: <43634380ce409627d74e37823fa91425cf0a3898.1714600367.git.mdw@distorted.org.uk> From: Mark Wooding Date: Sat, 6 Dec 2008 14:41:15 +0000 Subject: [PATCH] Changes to HTML coverage output: - include missing files in the main table - CSS bar graph of coverage Organization: Straylight/Edgeware From: Richard Kettlewell --- scripts/format-gcov-report | 42 ++++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/scripts/format-gcov-report b/scripts/format-gcov-report index e162395..93ace17 100755 --- a/scripts/format-gcov-report +++ b/scripts/format-gcov-report @@ -31,6 +31,9 @@ def sgmlquotechar(c): def sgmlquote(s): return string.join(map(sgmlquotechar, s),'') +def line_count(f): + return len(open(f, "r").readlines()) + missing = {} percent = {} total_lines = 0 @@ -64,6 +67,10 @@ for line in sys.stdin: covered_lines += this_lines * this_pc / 100.0 name = None +for m in missing: + percent[m] = 0 + total_lines += line_count(m) + def cmp(a,b): if percent[a] < percent[b]: return -1 elif percent[a] > percent[b]: return 1 @@ -80,22 +87,35 @@ if len(keys): if htmldir is not None and len(keys): index = open(os.path.join(htmldir, "index.html"), "w") index.write("gcov report\n") + index.write("\n"); index.write("

gcov report

\n") - index.write("\n") + index.write("
FileCoverage
\n") for k in keys: - index.write("\n") + if k in missing: + index.write("\n" + % int(percent[k])) index.write("
FileCoverage
%s%d%%\n" % - (sgmlquote(k), sgmlquote(k), percent[k])) + index.write("
%s\n" % sgmlquote(k)) + else: + index.write("%s\n" % + (sgmlquote(k), sgmlquote(k))) + index.write("%d%%\n" % percent[k]) + index.write("
\n") index.write("

Total coverage: %d%%

\n" % (100 * (covered_lines / total_lines))) - missing_files = missing.keys() - missing_files.sort() - if len(missing_files) > 0: - index.write("

Missing files:

\n") - index.write("