X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/disorder/blobdiff_plain/71b70599a2cd81c13cc4326499a5d0c45358cd7d..c2f519409c8d38f59e169abfc39bc97586222f85:/scripts/format-gcov-report diff --git a/scripts/format-gcov-report b/scripts/format-gcov-report index 0369ab6..93ace17 100755 --- a/scripts/format-gcov-report +++ b/scripts/format-gcov-report @@ -3,20 +3,18 @@ # This file is part of DisOrder. # Copyright (C) 2007 Richard Kettlewell # -# This program is free software; you can redistribute it and/or modify +# This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or +# the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# # You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA +# along with this program. If not, see . # import re,sys,os,string @@ -33,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 @@ -66,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 @@ -82,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("