From: Brian Warner Date: Thu, 4 Jan 2007 08:26:43 +0000 (-0700) Subject: improve figleaf: fix some line-numbering bugs, add an alphabetically-sorted index... X-Git-Tag: tahoe_v0.1.0-0-UNSTABLE~407 X-Git-Url: https://git.rkrishnan.org/components/com_hotproperty/%3C?a=commitdiff_plain;h=7b2268ab3941507fda90eaedc93f6616d39efc22;p=tahoe-lafs%2Ftahoe-lafs.git improve figleaf: fix some line-numbering bugs, add an alphabetically-sorted index HTML page --- diff --git a/src/allmydata/util/figleaf.py b/src/allmydata/util/figleaf.py index 44ff5812..5a3b1fb3 100644 --- a/src/allmydata/util/figleaf.py +++ b/src/allmydata/util/figleaf.py @@ -91,7 +91,7 @@ class LineGrabber: """ self.lines = set() - self.ast = parser.suite(fp.read().strip()) + self.ast = parser.suite(fp.read()) self.tree = parser.ast2tuple(self.ast, True) self.find_terminal_nodes(self.tree) diff --git a/src/allmydata/util/figleaf_htmlizer.py b/src/allmydata/util/figleaf_htmlizer.py index 0aac077e..919fbbe9 100644 --- a/src/allmydata/util/figleaf_htmlizer.py +++ b/src/allmydata/util/figleaf_htmlizer.py @@ -145,18 +145,53 @@ def report_as_html(coverage, directory, exclude_patterns=[], root=None): pcnt_75 = [ x for x in pcnts if x >= 75 ] pcnt_50 = [ x for x in pcnts if x >= 50 ] + ## index.html index_fp = open('%s/index.html' % (directory,), 'w') + # summary info index_fp.write('figleaf code coverage report\n') - index_fp.write('

Summary

%d files total: %d files > 90%%, %d files > 75%%, %d files > 50%%

' % (len(pcnts), len(pcnt_90), len(pcnt_75), len(pcnt_50))) - index_fp.write('\n') - index_fp.write('\n' % (summary_lines, summary_cover, summary_pcnt,)) + index_fp.write('

Summary

%d files total: %d files > ' + '90%%, %d files > 75%%, %d files > 50%%

' + % (len(pcnts), len(pcnt_90), + len(pcnt_75), len(pcnt_50))) + # sorted by percentage covered + index_fp.write('

Sorted by Coverage Percentage

\n') + index_fp.write('
Filename# lines# covered% covered
totals:%d%d%.1f%%
' + '' + '\n') + index_fp.write('' + '' + '\n' + % (summary_lines, summary_cover, summary_pcnt,)) + + for filename, stuff in info_dict_items: + (n_lines, n_covered, percent_covered, display_filename) = stuff + html_outfile = make_html_filename(display_filename) + + index_fp.write('' + '\n' + % (html_outfile, display_filename, n_lines, + n_covered, percent_covered,)) + + index_fp.write('
Filename# lines# covered% covered
totals:%d%d%.1f%%
%s%d%d%.1f
\n') + + # sorted by module name + index_fp.write('

Sorted by Module Name (alphabetical)

\n') + info_dict_items.sort() + index_fp.write('' + '' + '\n') - for filename, (n_lines, n_covered, percent_covered, display_filename) in info_dict_items: + for filename, stuff in info_dict_items: + (n_lines, n_covered, percent_covered, display_filename) = stuff html_outfile = make_html_filename(display_filename) - index_fp.write('\n' % (html_outfile, display_filename, n_lines, n_covered, percent_covered,)) + index_fp.write('' + '\n' + % (html_outfile, display_filename, n_lines, + n_covered, percent_covered,)) index_fp.write('
Filename# lines# covered% covered
%s%d%d%.1f
%s%d%d%.1f
\n') + index_fp.close() logger.info('reported on %d file(s) total\n' % len(info_dict))