From: Peter O. <obe...@us...> - 2010-08-20 13:08:33
|
Update of /cvsroot/ltp/utils/analysis/lcov/bin In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv3062/bin Modified Files: genhtml geninfo lcov Log Message: genhtml: add --ignore-errors option Provide a means for users to specify that genhtml should not abort if it cannot read a source code file. Also make handling of --ignore-errors parameter consistent accross lcov, geninfo and genhtml. Index: geninfo =================================================================== RCS file: /cvsroot/ltp/utils/analysis/lcov/bin/geninfo,v retrieving revision 1.82 retrieving revision 1.83 diff -C2 -d -r1.82 -r1.83 *** geninfo 6 Aug 2010 11:25:12 -0000 1.82 --- geninfo 20 Aug 2010 13:08:24 -0000 1.83 *************** *** 73,79 **** --- 73,85 ---- our $COMPAT_HAMMER = "hammer"; + # Error classes which users may specify to ignore during processing our $ERROR_GCOV = 0; our $ERROR_SOURCE = 1; our $ERROR_GRAPH = 2; + our %ERROR_ID = ( + "gcov" => $ERROR_GCOV, + "source" => $ERROR_SOURCE, + "graph" => $ERROR_GRAPH, + ); our $EXCL_START = "LCOV_EXCL_START"; *************** *** 143,146 **** --- 149,153 ---- sub debug($); sub int_handler(); + sub parse_ignore_errors(@); *************** *** 279,282 **** --- 286,292 ---- } + # Determine which errors the user wants us to ignore + parse_ignore_errors(@ignore_errors); + # Make sure test names only contain valid characters if ($test_name =~ s/\W/_/g) *************** *** 359,388 **** } - if (@ignore_errors) - { - my @expanded; - my $error; - - # Expand comma-separated entries - foreach (@ignore_errors) { - if (/,/) - { - push(@expanded, split(",", $_)); - } - else - { - push(@expanded, $_); - } - } - - foreach (@expanded) - { - /^gcov$/ && do { $ignore[$ERROR_GCOV] = 1; next; } ; - /^source$/ && do { $ignore[$ERROR_SOURCE] = 1; next; }; - /^graph$/ && do { $ignore[$ERROR_GRAPH] = 1; next; }; - die("ERROR: unknown argument for --ignore-errors: $_\n"); - } - } - if (system_no_output(3, $gcov_tool, "--help") == -1) { --- 369,372 ---- *************** *** 3067,3068 **** --- 3051,3087 ---- return \%capabilities; } + + # + # parse_ignore_errors(@ignore_errors) + # + # Parse user input about which errors to ignore. + # + + sub parse_ignore_errors(@) + { + my (@ignore_errors) = @_; + my @items; + my $item; + + return if (!@ignore_errors); + + foreach $item (@ignore_errors) { + $item =~ s/\s//g; + if ($item =~ /,/) { + # Split and add comma-separated parameters + push(@items, split(/,/, $item)); + } else { + # Add single parameter + push(@items, $item); + } + } + foreach $item (@items) { + my $item_id = $ERROR_ID{lc($item)}; + + if (!defined($item_id)) { + die("ERROR: unknown argument for --ignore-errors: ". + "$item\n"); + } + $ignore[$item_id] = 1; + } + } Index: genhtml =================================================================== RCS file: /cvsroot/ltp/utils/analysis/lcov/bin/genhtml,v retrieving revision 1.52 retrieving revision 1.53 diff -C2 -d -r1.52 -r1.53 *** genhtml 6 Aug 2010 11:25:12 -0000 1.52 --- genhtml 20 Aug 2010 13:08:24 -0000 1.53 *************** *** 156,159 **** --- 156,165 ---- our $BR_ADD = 1; + # Error classes which users may specify to ignore during processing + our $ERROR_SOURCE = 0; + our %ERROR_ID = ( + "source" => $ERROR_SOURCE, + ); + # Data related prototypes sub print_usage(*); *************** *** 199,202 **** --- 205,209 ---- sub warn_handler($); sub die_handler($); + sub parse_ignore_errors(@); *************** *** 280,283 **** --- 287,292 ---- our $html_gzip = 0; # Compress with gzip our $demangle_cpp = 0; # Demangle C++ function names + our @opt_ignore_errors; # Ignore certain error classes during processing + our @ignore; our @fileview_sortlist; our @fileview_sortname = ("", "-sort-l", "-sort-f", "-sort-b"); *************** *** 384,387 **** --- 393,397 ---- "no-sort" => \$no_sort, "demangle-cpp" => \$demangle_cpp, + "ignore-errors=s" => \@opt_ignore_errors, )) { *************** *** 419,422 **** --- 429,435 ---- } + # Determine which errors the user wants us to ignore + parse_ignore_errors(@opt_ignore_errors); + # Check for info filename if (!@info_filenames) *************** *** 568,571 **** --- 581,585 ---- --(no-)sort Enable (disable) sorted coverage views --demangle-cpp Demangle C++ function names + --ignore-errors ERRORS Continue after ERRORS (source) For more information see: $lcov_url *************** *** 4959,4962 **** --- 4973,4977 ---- my $datafunc = get_hash_reverse($funcdata); my $add_anchor; + my @file; if ($_[2]) *************** *** 4965,4975 **** } ! open(SOURCE_HANDLE, "<".$source_filename) ! or die("ERROR: cannot open $source_filename for reading!\n"); write_source_prolog(*HTML_HANDLE); ! ! for ($line_number = 1; <SOURCE_HANDLE> ; $line_number++) ! { chomp($_); --- 4980,5013 ---- } ! if (!open(SOURCE_HANDLE, "<".$source_filename)) { ! my @lines; ! my $last_line = 0; ! ! if (!$ignore[$ERROR_SOURCE]) { ! die("ERROR: cannot read $source_filename\n"); ! } ! ! # Continue without source file ! warn("WARNING: cannot read $source_filename!\n"); ! ! @lines = sort( { $a <=> $b } keys(%count_data)); ! if (@lines) { ! $last_line = $lines[scalar(@lines) - 1]; ! } ! return ( ":" ) if ($last_line < 1); ! ! # Simulate gcov behavior ! for ($line_number = 1; $line_number <= $last_line; ! $line_number++) { ! push(@file, "/* EOF */"); ! } ! } else { ! @file = <SOURCE_HANDLE>; ! } write_source_prolog(*HTML_HANDLE); ! $line_number = 0; ! foreach (@file) { ! $line_number++; chomp($_); *************** *** 5647,5648 **** --- 5685,5721 ---- die("$tool_name: $msg"); } + + # + # parse_ignore_errors(@ignore_errors) + # + # Parse user input about which errors to ignore. + # + + sub parse_ignore_errors(@) + { + my (@ignore_errors) = @_; + my @items; + my $item; + + return if (!@ignore_errors); + + foreach $item (@ignore_errors) { + $item =~ s/\s//g; + if ($item =~ /,/) { + # Split and add comma-separated parameters + push(@items, split(/,/, $item)); + } else { + # Add single parameter + push(@items, $item); + } + } + foreach $item (@items) { + my $item_id = $ERROR_ID{lc($item)}; + + if (!defined($item_id)) { + die("ERROR: unknown argument for --ignore-errors: ". + "$item\n"); + } + $ignore[$item_id] = 1; + } + } Index: lcov =================================================================== RCS file: /cvsroot/ltp/utils/analysis/lcov/bin/lcov,v retrieving revision 1.73 retrieving revision 1.74 diff -C2 -d -r1.73 -r1.74 *** lcov 6 Aug 2010 11:25:12 -0000 1.73 --- lcov 20 Aug 2010 13:08:24 -0000 1.74 *************** *** 169,173 **** our $no_compat_libtool; # If set, indicates that libtool mode is to be disabled our $gcov_tool; ! our $ignore_errors; our $initial; our $no_recursion = 0; --- 169,173 ---- our $no_compat_libtool; # If set, indicates that libtool mode is to be disabled our $gcov_tool; ! our @opt_ignore_errors; our $initial; our $no_recursion = 0; *************** *** 260,264 **** "no-compat-libtool" => \$no_compat_libtool, "gcov-tool=s" => \$gcov_tool, ! "ignore-errors=s" => \$ignore_errors, "initial|i" => \$initial, "no-recursion" => \$no_recursion, --- 260,264 ---- "no-compat-libtool" => \$no_compat_libtool, "gcov-tool=s" => \$gcov_tool, ! "ignore-errors=s" => \@opt_ignore_errors, "initial|i" => \$initial, "no-recursion" => \$no_recursion, *************** *** 799,805 **** @param = (@param, "--gcov-tool", $gcov_tool); } ! if ($ignore_errors) ! { ! @param = (@param, "--ignore-errors", $ignore_errors); } if ($initial) --- 799,804 ---- @param = (@param, "--gcov-tool", $gcov_tool); } ! foreach (@opt_ignore_errors) { ! @param = (@param, "--ignore-errors", $_); } if ($initial) |