From: Peter O. <obe...@us...> - 2010-08-23 14:47:51
|
Update of /cvsroot/ltp/utils/analysis/lcov/bin In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv685/bin Modified Files: geninfo lcov Log Message: lcov: add option to exclude external files Implement an option for users to specify that external source files should be excluded when capturing coverage data. External source files are files which are not located in the directories specified by the --directory and --base-directory options of lcov/geninfo. Index: geninfo =================================================================== RCS file: /cvsroot/ltp/utils/analysis/lcov/bin/geninfo,v retrieving revision 1.83 retrieving revision 1.84 diff -C2 -d -r1.83 -r1.84 *** geninfo 20 Aug 2010 13:08:24 -0000 1.83 --- geninfo 23 Aug 2010 14:47:38 -0000 1.84 *************** *** 150,153 **** --- 150,154 ---- sub int_handler(); sub parse_ignore_errors(@); + sub is_external($); *************** *** 179,185 **** --- 180,189 ---- our $no_markers = 0; our $opt_derive_func_data = 0; + our $opt_external = 1; + our $opt_no_external; our $debug = 0; our $gcov_caps; our @gcov_options; + our @internal_dirs; our $cwd = `pwd`; *************** *** 220,224 **** "geninfo_checksum" => \$checksum, "geninfo_no_checksum" => \$no_checksum, # deprecated ! "geninfo_compat_libtool" => \$compat_libtool}); # Merge options --- 224,230 ---- "geninfo_checksum" => \$checksum, "geninfo_no_checksum" => \$no_checksum, # deprecated ! "geninfo_compat_libtool" => \$compat_libtool, ! "geninfo_external" => \$opt_external, ! }); # Merge options *************** *** 249,252 **** --- 255,260 ---- "derive-func-data" => \$opt_derive_func_data, "debug" => \$debug, + "external" => \$opt_external, + "no-external" => \$opt_no_external, )) { *************** *** 268,271 **** --- 276,284 ---- $no_compat_libtool = undef; } + + if (defined($opt_no_external)) { + $opt_external = 0; + $opt_no_external = undef; + } } *************** *** 420,423 **** --- 433,442 ---- } + # Build list of directories to identify external files + foreach my $entry(@data_directory, $base_directory) { + next if (!defined($entry)); + push(@internal_dirs, solve_relative_path($cwd, $entry)); + } + # Do something foreach my $entry (@data_directory) { *************** *** 468,471 **** --- 487,491 ---- --no-markers Ignore exclusion markers in source code --derive-func-data Generate function data from line data + --(no-)external Include (ignore) data for external files For more information see: $lcov_url *************** *** 989,992 **** --- 1009,1022 ---- } + # Skip external files if requested + if (!$opt_external) { + if (is_external($source_filename)) { + info(" ignoring data for external file ". + "$source_filename\n"); + unlink($gcov_file); + next; + } + } + # Write absolute path of source file printf(INFO_HANDLE "SF:%s\n", $source_filename); *************** *** 1167,1170 **** --- 1197,1204 ---- # Remove . $result =~ s/\/\.\//\//g; + $result =~ s/\/\.$/\//g; + + # Remove trailing / + $result =~ s/\/$//g; # Solve .. *************** *** 3086,3087 **** --- 3120,3138 ---- } } + + # + # is_external(filename) + # + # Determine if a file is located outside of the specified data directories. + # + + sub is_external($) + { + my ($filename) = @_; + my $dir; + + foreach $dir (@internal_dirs) { + return 0 if ($filename =~ /^\Q$dir\/\E/); + } + return 1; + } Index: lcov =================================================================== RCS file: /cvsroot/ltp/utils/analysis/lcov/bin/lcov,v retrieving revision 1.76 retrieving revision 1.77 diff -C2 -d -r1.76 -r1.77 *** lcov 20 Aug 2010 14:58:48 -0000 1.76 --- lcov 23 Aug 2010 14:47:40 -0000 1.77 *************** *** 187,190 **** --- 187,192 ---- our $opt_list_width = 80; our $opt_list_truncate_max = 20; + our $opt_external; + our $opt_no_external; our $ln_overall_found; our $ln_overall_hit; *************** *** 270,273 **** --- 272,277 ---- "list-full-path" => \$opt_list_full_path, "no-list-full-path" => \$opt_no_list_full_path, + "external" => \$opt_external, + "no-external" => \$opt_no_external, )) { *************** *** 295,298 **** --- 299,307 ---- $opt_no_list_full_path = undef; } + + if (defined($opt_no_external)) { + $opt_external = 0; + $opt_no_external = undef; + } } *************** *** 494,497 **** --- 503,507 ---- --derive-func-data Generate function data from line data --list-full-path Print full path during a list operation + --(no-)external Include (ignore) data for external files For more information see: $lcov_url *************** *** 821,824 **** --- 831,842 ---- @param = (@param, "--debug"); } + if (defined($opt_external) && $opt_external) + { + @param = (@param, "--external"); + } + if (defined($opt_external) && !$opt_external) + { + @param = (@param, "--no-external"); + } system(@param) and exit($? >> 8); } |