X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=automated-tests%2Fpatch-coverage.pl;h=1f836a4892f3d1e56c65b0b5c873ecbbedca6a37;hp=702dc0bbd625c6bbb56ce4aea8448f9aaf2d1e5e;hb=ec1db95268e1cf8e8bd893027d45a19c64b32848;hpb=3adb444b9bb5cbb26433473e8885677cc4996a29 diff --git a/automated-tests/patch-coverage.pl b/automated-tests/patch-coverage.pl index 702dc0b..1f836a4 100755 --- a/automated-tests/patch-coverage.pl +++ b/automated-tests/patch-coverage.pl @@ -54,7 +54,7 @@ sub add_counts($$); sub info(@); our $repo = Git->repository(); -our $debug=1; +our $debug=0; our $pd_debug=0; our $root; our %info_data; # Hash containing all data from .info files @@ -83,7 +83,7 @@ my %options = ( "output:s" => { "optvar"=>\$opt_output, "desc"=>"Generate html output"}, "help" => { "optvar"=>\$opt_help, "desc"=>""}, "quiet" => { "optvar"=>\$opt_quiet, "desc"=>""}, - "verbose" => { "optvar"=>\$opt_verbose, "desc"=>"" }); + "verbose" => { "optvar"=>\$opt_verbose, "desc"=>"Also output coverage" }); my %longOptions = map { $_ => $options{$_}->{"optvar"} } keys(%options); GetOptions( %longOptions ) or pod2usage(2); @@ -875,15 +875,14 @@ sub info(@) } } -# NEW STUFF -## Format per file, repeated, no linebreak +# Format per file, repeated, no linebreak # # index c1..c2 c3 # --- a/ # +++ b/ # - +# # Format of each diff hunk, repeated, no linebreak # @@ @@ line # 3 lines of context @@ -986,7 +985,7 @@ sub parse_diff $files{$file}->{"patch"} = [@checklines]; $files{$file}->{"b_lines"} = {%b_lines}; - my %filter = map { $_ => $files{$_} } grep {m!^dali(-toolkit)?/!} (keys(%files));; + my %filter = map { $_ => $files{$_} } grep {m!^dali(-toolkit|-scene-loader)?/!} (keys(%files)); if($pd_debug) { @@ -1064,6 +1063,13 @@ sub calc_patch_coverage_percentage my $abs_filename = File::Spec->rel2abs($file, $root); my $sumcountref = $info_data{$abs_filename}->{"sum"}; + if($debug>1) + { + print("File: $abs_filename\n"); + print Dumper($info_data{$abs_filename}); + print "\n"; + } + if( $sumcountref ) { for my $patch (@$patchref) @@ -1105,7 +1111,7 @@ sub calc_patch_coverage_percentage my $percent = 0; if($total_exec > 0) { $percent = 100 * $total_covered_lines / $total_exec; } - return [ $total_exec, $percent ]; + return [ $total_exec, $percent, $total_covered_lines ]; } # @@ -1312,38 +1318,12 @@ EOH ## MAIN ## ################################################################################ -my $cwd = getcwd(); # expect this to be automated-tests folder - -# execute coverage.sh, generating build/tizen/dali.info from lib, and -# *.dir/dali.info. Don't generate html -`coverage.sh -n`; -chdir ".."; -$root = getcwd(); - -our %info_data; # Hash of all data from .info files -my @info_files = split(/\n/, `find . -name dali.info`); -my %new_info; - -# Read in all specified .info files -foreach (@info_files) -{ - %new_info = %{read_info_file($_)}; - - # Combine %new_info with %info_data - %info_data = %{combine_info_files(\%info_data, \%new_info)}; -} - # Generate git diff command my @cmd=('--no-pager','diff','--no-ext-diff','-U0','--no-color'); my $status = $repo->command("status", "-s"); -if(scalar(@ARGV)) # REMOVE ME -{ - # REMOVE ME - temp to get past modifying this script in place. - push @cmd, @ARGV; -} -elsif( $status eq "" && !scalar(@ARGV)) +if( $status eq "" && !scalar(@ARGV)) { # There are no changes in the index or working tree, and # no diff arguments to append. Use the last patch instead. @@ -1367,7 +1347,7 @@ else } else { - die "Both cached & working files - cannot get correct patch from git\n"; + die "Error: Both cached & working files - cannot get correct patch from git\nRun git add first."; # Would have to diff from separate clone. } } @@ -1375,6 +1355,31 @@ else push @cmd, @ARGV; +# Before executing the diff, run the coverage.sh script. This is done here so that the +# error condition above happens straight away, rather than after spewing out lots of information. + +my $cwd = getcwd(); # expect this to be automated-tests folder +# execute coverage.sh, generating build/tizen/dali.info from lib, and +# *.dir/dali.info. Don't generate html +printf("Running coverage.sh\n"); +my $coverage_output=`./coverage.sh -n`; +chdir ".."; +$root = getcwd(); + +our %info_data; # Hash of all data from .info files +my @info_files = split(/\n/, `find . -name dali.info`); +my %new_info; + +# Read in all specified .info files +foreach (@info_files) +{ + %new_info = %{read_info_file($_)}; + + # Combine %new_info with %info_data + %info_data = %{combine_info_files(\%info_data, \%new_info)}; +} + + # Execute diff & coverage from root directory my $filesref = run_diff(@cmd); @@ -1391,21 +1396,33 @@ foreach my $file (keys(%$filesref)) } if( $filecount == 0 ) { - print "No source files found\n"; + print "Warning: No source files found\n"; exit 0; # Exit with no error. } #print_simplified_info() if $debug; #exit 0; +if($debug > 1) +{ + print "Info keys:\n"; + for my $key (keys(%info_data)) + { + print "$key\n"; + } + print "\n\n"; +} my $percentref = calc_patch_coverage_percentage($filesref); if($percentref->[0] == 0) { - print "No coverable lines found\n"; + print "Warning: No coverable lines found\n"; exit 0; } my $percent = $percentref->[1]; +printf(join("\n", grep { $_ !~ /^Remov/ } split(/\n/,$coverage_output))) if $opt_verbose; +#printf($coverage_output) if $opt_verbose; + my $color=BOLD RED; if($opt_output) { @@ -1422,6 +1439,8 @@ elsif( ! $opt_quiet ) print RESET; } +printf("\n\n=========================\nPatch coverage output:\n=========================\n"); +printf("Line Coverage: %d/%d\n", $percentref->[2], $percentref->[0]); printf("Percentage of change covered: %5.2f%\n", $percent); exit($percent<90);