From: Peter O. <obe...@us...> - 2005-03-08 14:23:37
|
Update of /cvsroot/ltp/utils/analysis/lcov/bin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14018/analysis/lcov/bin Modified Files: genhtml Log Message: lcov: - added optional legend to HTML output - changed background color for "good coverage" entries to green for consistency reasons Index: genhtml =================================================================== RCS file: /cvsroot/ltp/utils/analysis/lcov/bin/genhtml,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** genhtml 9 Aug 2004 11:15:02 -0000 1.7 --- genhtml 8 Mar 2005 14:22:56 -0000 1.8 *************** *** 49,52 **** --- 49,54 ---- # 2003-07-10 / Peter Oberparleiter: added line checksum support # 2004-08-09 / Peter Oberparleiter: added configuration file support + # 2005-03-04 / Cal Pierog: added legend to HTML output, fixed coloring of + # "good coverage" background # *************** *** 119,122 **** --- 121,127 ---- sub escape_html($); sub get_bar_graph_code($$$); + sub classify_coverage_rate($); + sub get_png_for_coverage_rate($); + sub coverage_rate_helper($); sub write_png_files(); *************** *** 132,135 **** --- 137,141 ---- sub write_header_line(*$$;$$); sub write_header_epilog(*$); + sub write_header_legend(*$); sub write_file_table(*$$$$); *************** *** 178,181 **** --- 184,188 ---- our $no_sourceview; # If set, do not create a source code view for each file our $highlight; # If set, highlight lines covered by converted data only + our $legend; # If set, include legend in output our $tab_size = 8; # Number of spaces to use in place of tab our $config; # Configuration file contents *************** *** 220,224 **** "genhtml_no_source" => \$no_sourceview, "genhtml_num_spaces" => \$tab_size, ! "genhtml_highlight" => \$highlight}); } --- 227,232 ---- "genhtml_no_source" => \$no_sourceview, "genhtml_num_spaces" => \$tab_size, ! "genhtml_highlight" => \$highlight, ! "genhtml_legend" => \$legend}); } *************** *** 237,240 **** --- 245,249 ---- "frames" => \$frames, "highlight" => \$highlight, + "legend" => \$legend, "quiet" => \$quiet, "help|h" => \$help, *************** *** 370,373 **** --- 379,383 ---- --num-spaces NUM Replace tabs with NUM spaces in source view --highlight Highlight lines with converted-only data + --legend Include color legend in HTML output See $lcov_url for more information about this tool. *************** *** 1557,1560 **** --- 1567,1594 ---- + /* All views: header legend item format */ + td.legendItem + { + text-align: right; + padding-right: 6px; + padding-top: 10px; + padding-bottom: 2px; + font-family: sans-serif; + font-weight: bold; + } + + + /* All views: header legend item value format */ + td.legendValue + { + text-align: left; + padding-top: 10px; + padding-bottom: 2px; + color: #000000; + font-family: sans-serif; + font-weight: bold; + } + + /* All views: color of horizontal ruler */ td.ruler *************** *** 1622,1626 **** padding-left: 10px; padding-right: 10px; ! background-color: #DAE7FE; font-weight: bold; } --- 1656,1660 ---- padding-left: 10px; padding-right: 10px; ! background-color: #A7FC9D; font-weight: bold; } *************** *** 1634,1638 **** padding-left: 10px; padding-right: 10px; ! background-color: #DAE7FE; } --- 1668,1683 ---- padding-left: 10px; padding-right: 10px; ! background-color: #A7FC9D; ! } ! ! ! /* Directory view/File view (all): legend entry for high coverage ! rate */ ! span.coverLegendHi ! { ! text-align: center; ! padding-left: 10px; ! padding-right: 10px; ! background-color: #A7FC9D; } *************** *** 1661,1664 **** --- 1706,1723 ---- + /* Directory view/File view (all): legend entry for medium coverage + rate */ + span.coverLegendMed + { + text-align: center; + padding-left: 10px; + padding-right: 10px; + margin-top: 5px; + margin-bottom: 5px; + margin-right: 2px; + background-color: #FFEA20; + } + + /* Directory view/File view (all): percentage entry for files with low coverage rate */ *************** *** 1684,1687 **** --- 1743,1758 ---- + /* Directory view/File view (all): legend entry for low coverage + rate */ + span.coverLegendLo + { + text-align: center; + padding-left: 10px; + padding-right: 10px; + margin-right: 2px; + background-color: #FF0000; + } + + /* File view (all): "show/hide details" link format */ a.detail:link *************** *** 1795,1798 **** --- 1866,1880 ---- + /* Source code view: format for Cov legend */ + span.LegendCov + { + text-align: center; + padding-left: 10px; + padding-right: 10px; + margin-right: 2px; + background-color: #CAD7FE; + } + + /* Source code view: format for lines which were not executed */ span.lineNoCov *************** *** 1802,1805 **** --- 1884,1898 ---- + /* Source code view: format for NoCov legend */ + span.LegendNoCov + { + text-align: center; + padding-left: 10px; + padding-right: 10px; + margin-right: 2px; + background-color: #FF6230; + } + + /* Source code view: format for lines which were executed only in a previous version */ *************** *** 1808,1811 **** --- 1901,1914 ---- background-color: #B5F7AF; } + + + /* Source code view: format for DiffCov legend */ + span.LegendDiffCov + { + text-align: center; + padding-left: 10px; + padding-right: 10px; + background-color: #B5F7AF; + } END_OF_CSS ; *************** *** 1848,1854 **** # Decide which .png file to use ! if ($rate < $med_limit) { $png_name = "ruby.png"; } ! elsif ($rate < $hi_limit) { $png_name = "amber.png"; } ! else { $png_name = "emerald.png"; } if ($width == 0) --- 1951,1955 ---- # Decide which .png file to use ! $png_name = get_png_for_coverage_rate($rate); if ($width == 0) *************** *** 1886,1889 **** --- 1987,2025 ---- # + # classify_coverage_rate(coverage_rate) + # + # Return the clasification ("Lo"|"Med"|"Hi") of a given coverage rate + # + sub classify_coverage_rate($) + { + my @pair = coverage_rate_helper($_[0]); + return $pair[0]; + } + + # + # get_png_for_coverage_rate(coverage_rate) + # + # Return the name of the png corresponding to the given coverage rate + # + sub get_png_for_coverage_rate($) + { + my @pair = coverage_rate_helper($_[0]); + return $pair[1]; + } + + # + # coverage_rate_helper(coverage_rate) + # + # Does the work for "classify_coverage_rate" and "get_png_for_coverage_rate". + # + sub coverage_rate_helper($) + { + my $rate = $_[0]; + if ($rate < $med_limit) { return(("Lo","ruby.png")); } + elsif ($rate < $hi_limit) { return(("Med","amber.png")); } + else { return(("Hi","emerald.png")); } + } + + # # write_html(filehandle, html_code) # *************** *** 2042,2045 **** --- 2178,2257 ---- # + # write_header_legend(filehandle, type) + # + # Write a legend describing the coloring of the code coverage. + # + + sub write_header_legend(*$) + { + my $type = $_[1]; # type of page being generated + my $legend_body; + + # main summary or subdirectory summary + if ($type == 0 or $type == 1) + { + $legend_body = (<<END_OF_HTML) + <span class="coverLegendLo"> + <b>Low:</b> 0% to $med_limit% + </span> + <span class="coverLegendMed"> + <b>Medium:</b> $med_limit% to $hi_limit% + </span> + <span class="coverLegendHi"> + <b>High:</b> $hi_limit% to 100% + </span> + END_OF_HTML + ; + } + + # source code + elsif ($type == 2) + { + my $legend_highlight; + + $legend_highlight = ""; + if ($highlight) + { + $legend_highlight = (<<END_OF_HTML) + <span class="legendDiffCov"> + converted-only + </span> + END_OF_HTML + ; + } + $legend_body = (<<END_OF_HTML) + <span class="legendNoCov"> + not executed + </span> + <span class="legendCov"> + executed + </span> + $legend_highlight + END_OF_HTML + ; + } + + # description file ($type == 3) + else { return(); } + + + # ************************************************************* + + write_html($_[0], <<END_OF_HTML) + <tr> + <td class="legendItem" width="20%">Legend:</td> + <td class="legendValue" width="80%" colspan=4> + $legend_body + </td> + </tr> + END_OF_HTML + ; + return(); + + # ************************************************************* + } + + + # # write_file_table_prolog(filehandle, left_heading, right_heading) # *************** *** 2091,2098 **** $rate = $_[4] * 100 / $_[3]; $rate_string = sprintf("%.1f", $rate)." %"; ! ! if ($rate < $med_limit) { $classification = "Lo"; } ! elsif ($rate < $hi_limit) { $classification = "Med"; } ! else { $classification = "Hi"; } } else --- 2303,2308 ---- $rate = $_[4] * 100 / $_[3]; $rate_string = sprintf("%.1f", $rate)." %"; ! ! $classification = classify_coverage_rate($rate); } else *************** *** 2675,2678 **** --- 2885,2892 ---- write_header_line(*HTML_HANDLE, "Code covered", $rate, "Executed lines", $lines_hit); + if ($legend) + { + write_header_legend(*HTML_HANDLE, $type); + } write_header_epilog(*HTML_HANDLE, $base_dir); } |