From 9046903e6fd20f964a61e8511024c70a71f9eb02 Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Fri, 10 Jul 2026 21:51:30 +0200 Subject: [PATCH 1/3] bin/fix.pl: Make shebang inspector code work for perltidy perltidy 20250912 was observed to misinterpret the '#' as starting a comment. --- bin/fix.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/fix.pl b/bin/fix.pl index ecfd6598..abdd6d50 100755 --- a/bin/fix.pl +++ b/bin/fix.pl @@ -101,7 +101,7 @@ ($) if ($opt_fixinterp && defined($path) && $path ne "") { $source =~ s/^#!.*perl.*\n/#!$path\n/ - unless $source =~ @^#!/usr/bin/env perl$@; + unless $source =~ m{^#!/usr/bin/env perl$}; } if ($opt_fixlibdir) { @@ -135,7 +135,7 @@ ($) if ($opt_fixinterp && defined($path) && $path ne "") { $source =~ s/^#!.*python.*\n/#!$path\n/ - unless $source =~ @^#!/usr/bin/env python3?$@; + unless $source =~ m{^#!/usr/bin/env python3?$}; } return $source; From fab01c8e4db8b0cefc2713aa41eb9ea547b5bde3 Mon Sep 17 00:00:00 2001 From: perltidy 20260705 Date: Fri, 10 Jul 2026 21:46:06 +0200 Subject: [PATCH 2/3] Mass-apply perltidy 20260705 --- bin/genhtml | 305 +++++++++++------ bin/geninfo | 50 +-- bin/lcov | 29 +- bin/perl2lcov | 9 +- lib/lcovutil.pm | 586 +++++++++++++++++++-------------- scripts/analyzeInfoFiles | 11 +- scripts/annotateutil.pm | 6 +- scripts/gitblame.pm | 3 +- scripts/gitversion.pm | 3 +- scripts/p4annotate.pm | 16 +- scripts/select.pm | 6 +- scripts/simplify.pm | 3 +- scripts/unreach.pm | 5 +- tests/bin/mkinfo | 9 +- tests/genhtml/filter/filter.pl | 6 +- 15 files changed, 621 insertions(+), 426 deletions(-) diff --git a/bin/genhtml b/bin/genhtml index 6c958cb6..57a64e53 100755 --- a/bin/genhtml +++ b/bin/genhtml @@ -570,7 +570,8 @@ sub relativeDir { my ($self, $dir_string) = @_; die("bad usage: relativeDir(" . - (defined($dir_string) ? $dir_string : '') . ') current: ' + (defined($dir_string) ? $dir_string : '') . + ') current: ' . (defined($self->[RELATIVE_DIR]) ? $self->[RELATIVE_DIR] : '') ) @@ -936,7 +937,7 @@ sub findOwnerList @owners = sort({ $b->[1]->[0] <=> $a->[1]->[0] || # missed $b->[1]->[1] <=> $a->[1]->[1] || # then total - $a->[0] cmp $b->[0] + $a->[0] cmp $b->[0] } @owners); # then by name my $truncated; if ($truncate_me && @@ -1387,8 +1388,10 @@ sub checkCoverageCriteria } my $name = $self->type() eq 'top' ? 'top' : $self->name(); my $cmd = - join(' ', @CoverageCriteria::coverageCriteriaScript) . - ' \'' . $name . '\' ' . $self->type() . ' \'json_encoded_data\''; + join(' ', @CoverageCriteria::coverageCriteriaScript) . ' \'' . + $name . '\' ' . + $self->type() . + ' \'json_encoded_data\''; # command: script name (top|dir|file) jsonString args.. lcovutil::info(1, "criteria: '$cmd'\n"); CoverageCriteria::executeCallback($self->type(), $name, \%data); @@ -1689,8 +1692,9 @@ sub data { my $self = shift; - my $lineCb = OwnerDetailCallback->new($self->[1], $self->[0], - SummaryInfo::LINE_DATA); + my $lineCb = + OwnerDetailCallback->new($self->[1], $self->[0], + SummaryInfo::LINE_DATA); my $branchCb = OwnerDetailCallback->new($self->[1], $self->[0], SummaryInfo::BRANCH_DATA); @@ -2262,9 +2266,11 @@ sub lineNo unless $which eq "base"; $loc = LINENO_BASE; } - lcovutil::ignorable_error($lcovutil::ERROR_INCONSISTENT_DATA, + lcovutil::ignorable_error( + $lcovutil::ERROR_INCONSISTENT_DATA, "\"$filename\": inconsistent '$which' line location: " . - $self->[$loc] . " -> $lineNo") + $self->[$loc] . + " -> $lineNo") if (defined($lineNo) && defined($self->[$loc]) && $self->[$loc] != $lineNo); @@ -3254,9 +3260,10 @@ sub _categorizeFunctionCov } else { $data = $lineDataMap->{$line}; lcovutil::ignorable_error($lcovutil::ERROR_INTERNAL, - "type mismatch " . $data->type() . - " -> $type for $filename:$line") - unless $data->type() == $type; + "type mismatch " . + $data->type() . + " -> $type for $filename:$line" + ) unless $data->type() == $type; } # we expect that the line number matches... $data->lineNo("current", $line, $filename); @@ -3913,7 +3920,8 @@ sub check_version_match # file is in 'diff' data: we expect the version to be different # between baseline/current if ($versionMatch) { - lcovutil::ignorable_error($lcovutil::ERROR_INCONSISTENT_DATA, + lcovutil::ignorable_error( + $lcovutil::ERROR_INCONSISTENT_DATA, "File \"$curr\" appears in 'diff' data file '" . $self->[DIFF_FILENAME] . "' but 'baseline' and 'current' versions '" . @@ -3923,7 +3931,8 @@ sub check_version_match } else { # not in 'diff': we expect the versions to be identical if (!$versionMatch) { - lcovutil::ignorable_error($lcovutil::ERROR_INCONSISTENT_DATA, + lcovutil::ignorable_error( + $lcovutil::ERROR_INCONSISTENT_DATA, "File \"$curr\" version changed from '" . ($base_version ? $base_version : 'path() . - ":$line - lineTLA:$lineTla taken:" . $br->data()); + "undef TLA for branch $blockId of " . + $self->path() . + ":$line - lineTLA:$lineTla taken:" . + $br->data()); next; # LCOV_UNREACHABLE_STOP } @@ -5000,10 +5011,11 @@ sub _countMcdcTlaData next if grep(/$tla/, ('EUC', 'ECC')); unless (defined($tla)) { # LCOV_UNREACHABLE_START - lcovutil::ignorable_error($lcovutil::ERROR_INTERNAL, + lcovutil::ignorable_error( + $lcovutil::ERROR_INTERNAL, "undef TLA for sense $sense of MC/DC " . - $expr->index() . - ' of ' . $self->path() . + $expr->index() . ' of ' . + $self->path() . ":$line - lineTLA:$lineTla taken:" . $count->[1]); next; @@ -5218,9 +5230,12 @@ sub _countFunctionTlaData lcovutil::ignorable_error($lcovutil::ERROR_INTERNAL, "undef TLA for function '" . $func->name() . - "' hit " . $h->[0] . " at line " . - $line . " (" . $lineData->tla() . - ' ' . $lineData->curr_count() . ")"); + "' hit " . + $h->[0] . + " at line " . + $line . " (" . + $lineData->tla() . ' ' . + $lineData->curr_count() . ")"); #die("this should not happen"); # This is new code - somehow miscategorized. $mergedTla = $h->[0] == 0 ? 'UNC' : 'GNC'; @@ -5251,10 +5266,16 @@ sub _countFunctionTlaData if (!defined($tla)) { # LCOV_UNREACHABLE_START lcovutil::ignorable_error($lcovutil::ERROR_INTERNAL, - "undef TLA for alias:'$alias' hit:" . - $data->[0] . " of function '" . $func->name() . - "' hit " . $h->[0] . " at line " . $line . " (" . - $lineData->tla() . ' ' . $lineData->curr_count() . ")"); + "undef TLA for alias:'$alias' hit:" . + $data->[0] . + " of function '" . + $func->name() . + "' hit " . + $h->[0] . + " at line " . + $line . " (" . + $lineData->tla() . ' ' . + $lineData->curr_count() . ")"); # die("this should not happen either"); $tla = $data->[0] == 0 ? 'UNC' : 'GNC'; $data->[1] = $tla; @@ -5897,9 +5918,10 @@ sub _synthesize ' - synthesizing fake content.' : '.'; lcovutil::ignorable_error($lcovutil::ERROR_SOURCE, - "cannot read '" . $self->path() . - "' - file is empty or unreadable$suffix") - unless $main::no_sourceview; + "cannot read '" . + $self->path() . + "' - file is empty or unreadable$suffix" + ) unless $main::no_sourceview; $why = 'empty or unreadable'; } else { my $suffix = ''; @@ -5908,11 +5930,14 @@ sub _synthesize my $plural = $num == 1 ? 'line' : "$num lines"; $suffix = ' ... synthesizing fake content for last ' . $plural; } - lcovutil::ignorable_error($lcovutil::ERROR_RANGE, + lcovutil::ignorable_error( + $lcovutil::ERROR_RANGE, $self->path() . - ' contains only ' . $currentLast . + ' contains only ' . + $currentLast . ' lines but coverage data refers to line ' . - $last_line . $suffix); + $last_line . + $suffix); $why = 'not long enough'; } # Simulate gcov behavior @@ -6017,7 +6042,8 @@ sub new my $tla = $br->tla(); my $count = $br->count(); die("unexpected branch TLA $tla for count $count at " . - $fileDetails->path() . ":$line") + $fileDetails->path() . + ":$line") unless (($count != 0) == exists($tlaData{$tla})); next if (0 == $count); $tlaData{$tla} += 1; @@ -6180,9 +6206,9 @@ sub new push(@unknown, [$f, $filename]); } } - lcovutil::info( - scalar(@unknown) . ' (of ' . (scalar(@predicted) + scalar(@unknown)) . - ") files do not appear in \'--history\' profile.\n") + lcovutil::info(scalar(@unknown) . ' (of ' . + (scalar(@predicted) + scalar(@unknown)) . + ") files do not appear in \'--history\' profile.\n") if (defined($lcovutil::profileHistoryCallback) && @unknown); @@ -6367,7 +6393,8 @@ sub completed_dependency if ($main::debugScheduler > 1) { # print parent dependencies while (my ($k, $d) = each(%{$pendingParent->[1]})) { - die("unexpected parent dependency $k ARRAY: " . $d->[0] . ' ' . + die("unexpected parent dependency $k ARRAY: " . + $d->[0] . ' ' . join('/', @{$d->[2]})) if ('ARRAY' eq ref($d) || 1 != $d); print(" $k\n"); @@ -6377,7 +6404,8 @@ sub completed_dependency if (!%{$pendingParent->[1]}) { # no more dependencies - schedule this one my $p = $pendingParent->[0]; - print("completed dependencies - schedule " . $p->[0] . ' ' . + print("completed dependencies - schedule " . + $p->[0] . ' ' . join('/', @{$p->[2]}) . "\n") if $main::debugScheduler > 1; push(@{$self->[WORKLIST]}, $p); @@ -6796,7 +6824,8 @@ sub compute lcovutil::info(" $k\n"); die("unexpected data for depend $k: $d") unless $d == 1; } - lcovutil::info(" parent: " . $p->[0]->[0] . ' ' . + lcovutil::info(" parent: " . + $p->[0]->[0] . ' ' . join('/', @{$p->[0]->[2]}) . "\n"); } # can get here if child process hit a 'die' (as opposed to an error) @@ -7276,8 +7305,7 @@ my %genhtml_options = ( Getopt::Long::Configure('default'); # Parse command line options -if ( - !lcovutil::parseOptions(\%genhtml_rc_opts, \%genhtml_options, +if (!lcovutil::parseOptions(\%genhtml_rc_opts, \%genhtml_options, \$output_directory) ) { print(STDERR "Use $tool_name --help to get usage information\n"); @@ -7965,7 +7993,8 @@ sub gen_html() if (@SourceFile::annotateScript && 0 == $SourceFile::annotatedFiles) { - lcovutil::ignorable_error($lcovutil::ERROR_ANNOTATE_SCRIPT, + lcovutil::ignorable_error( + $lcovutil::ERROR_ANNOTATE_SCRIPT, "\"--annotate-script '" . join(' ', @SourceFile::annotateScript) . "'\" did not find any revision-controlled files in your sandbox" @@ -8016,9 +8045,8 @@ sub write_dir_page my $bin_prefix = $ctrls->[3]; # Generate directory overview page including details html_create(*HTML_HANDLE, - File::Spec->catfile( - $rel_dir, "index$bin_prefix$page_suffix.$html_ext" - )); + File::Spec->catfile($rel_dir, + "index$bin_prefix$page_suffix.$html_ext")); if (!defined($trunc_dir)) { $trunc_dir = ""; } @@ -8087,18 +8115,19 @@ sub write_summary_pages($$$$$$$$) my $start = Time::HiRes::gettimeofday(); my @summaryBins; if (defined($main::show_ownerBins)) { - if (0 != scalar($summary->owners( - $main::show_ownerBins, SummaryInfo::LINE_DATA + if ( + 0 != scalar($summary->owners($main::show_ownerBins, + SummaryInfo::LINE_DATA )) || ( $lcovutil::br_coverage && - 0 != scalar($summary->owners( - $main::show_ownerBins, SummaryInfo::BRANCH_DATA + 0 != scalar($summary->owners($main::show_ownerBins, + SummaryInfo::BRANCH_DATA ))) || ( $lcovutil::mcdc_coverage && - 0 != scalar($summary->owners( - $main::show_ownerBins, SummaryInfo::MCDC_DATA + 0 != scalar($summary->owners($main::show_ownerBins, + SummaryInfo::MCDC_DATA ))) ) { # at least one owner will appear - so table will be referenced @@ -8206,7 +8235,8 @@ sub write_function_page($$$$$$$$$$$$$$$) html_create(*HTML_HANDLE, $filename); my $pagetitle = "LCOV - $title - " . - File::Spec->catfile($trunc_dir, $base_name) . " - functions"; + File::Spec->catfile($trunc_dir, $base_name) . + " - functions"; write_html_prolog(*HTML_HANDLE, $base_dir, $pagetitle); write_header(*HTML_HANDLE, 'file', # function table always written from 'file' level @@ -10187,7 +10217,8 @@ sub write_file_table_entry(*$$@) die("unexpected callback arg types: write_file_table_entry(" . ref($fileSummary) . ', ' . ref($fileDetails) . - ", $file_link, " . (defined($cbData) ? $cbData : 'undef') . ')') + ", $file_link, " . + (defined($cbData) ? $cbData : 'undef') . ')') unless (!defined($fileDetails) || 'SourceFile' eq ref($fileDetails)) && 'SummaryInfo' eq ref($fileSummary); my $esc_name = escape_html($name); @@ -10221,7 +10252,8 @@ sub write_file_table_entry(*$$@) $source_link = $suppressFileHref ? $obj_name : ("type() . " $full_path\">$obj_name"); + $fileSummary->type() . + " $full_path\">$obj_name"); } elsif (defined($file_link) && $file_link ne "") { my $target = File::Basename::basename($fileSummary->name()); @@ -10255,7 +10287,8 @@ sub write_file_table_entry(*$$@) $namecode = $suppressFileHref ? $obj_name : ("type() . " $full_path\">$obj_name"); + $fileSummary->type() . + " $full_path\">$obj_name"); $owner = ""; } elsif ($is_secondary && $primary_key ne 'name' && @@ -10539,7 +10572,8 @@ END_OF_HTML $line = $fileDetails->nextInOwnerBin($owner, $key) if $covType == SummaryInfo::LINE_DATA; $line = - $fileDetails->nextBranchInOwnerBin($owner, $key) + $fileDetails->nextBranchInOwnerBin($owner, + $key) if $covType == SummaryInfo::BRANCH_DATA; $line = $fileDetails->nextMcdcInOwnerBin($owner, $key) @@ -10552,7 +10586,8 @@ END_OF_HTML $line = $fileDetails->nextInDateBin($agebin, $key) if $covType == SummaryInfo::LINE_DATA; $line = - $fileDetails->nextBranchInDateBin($agebin, $key) + $fileDetails->nextBranchInDateBin($agebin, + $key) if $covType == SummaryInfo::BRANCH_DATA; $line = $fileDetails->nextMcdcInDateBin($agebin, $key) @@ -11158,8 +11193,10 @@ sub get_mcdc_html($$) my $expr_name = $expr->expression(); $title = - ${prefix} . ($sense ? 'True' : 'False') . - ' sense of expression "' . $expr_name . '" '; + ${prefix} . + ($sense ? 'True' : 'False') . + ' sense of expression "' . + $expr_name . '" '; if ($expr->parent()->num_groups() > 1) { $title .= 'in group "' . $expr->groupSize() . '" '; } @@ -11174,7 +11211,8 @@ sub get_mcdc_html($$) $title .= 'was dropped'; $title .= ' (previously ' . - (1 == $base_count ? '' : 'not ') . 'sensitized)' + (1 == $base_count ? '' : 'not ') . + 'sensitized)' if (defined($tla) && ($tla eq 'LBC' || $tla eq 'ECB')); @@ -11183,7 +11221,8 @@ sub get_mcdc_html($$) $title .= 'was not sensitized'; $title .= ' (previously ' . - (1 == $base_count ? '' : 'not ') . 'sensitized)' + (1 == $base_count ? '' : 'not ') . + 'sensitized)' if (defined($tla) && ($tla eq 'LBC' || $tla eq 'ECB')); } else { @@ -11380,8 +11419,10 @@ sub write_source_line(*$$$$$$$) # '$result' is used to generate the PNG frame info(2, " $bucket: line=$line " . - (defined($count) ? "count= $count " : "") . ' curr=' . - (defined($curr_count) ? $curr_count : '-') . ' base=' . + (defined($count) ? "count= $count " : "") . + ' curr=' . + (defined($curr_count) ? $curr_count : '-') . + ' base=' . (defined($base_count) ? $base_count : '-') . "\n"); } $result .= ":" . $source; @@ -11568,7 +11609,8 @@ sub write_source_line(*$$$$$$$) $bucket; my $popup = " title=\"next $label in “" . - escape_html($src_owner) . "” bin\""; + escape_html($src_owner) . + "” bin\""; # NOTE: see note below about firefox nested span bug. # this code just arranges to wrap an explicit 'span' around # the space. @@ -11657,7 +11699,8 @@ sub write_source_line(*$$$$$$$) } write_html($handle, "$html_continuation_leader$lineNumSpan" . - ' ' x 8 . " $br$mc\n"); + ' ' x 8 . + " $br$mc\n"); } # ************************************************************* @@ -11977,7 +12020,8 @@ sub buildOwnerSummaryTable($$$$$$$$$$) ($main::show_ownerBins ? "" : "un-exercised ") . "code)"; $title .= ": $num_truncated author" . - ($num_truncated == 1 ? '' : 's') . ' truncated' + ($num_truncated == 1 ? '' : 's') . + ' truncated' if $num_truncated; $title = @@ -12046,7 +12090,8 @@ sub buildOwnerSummaryTable($$$$$$$$$$) my $href = $esc_name; if (defined($detailLink)) { $href = - "$esc_name"; } $hit -= $found # negative number @@ -12322,7 +12367,8 @@ sub write_header(*$$$$$$$) # Test description header $base_dir = ""; $view = - "" . + "" . "$overview_title - test case descriptions"; } @@ -12342,7 +12388,8 @@ sub write_header(*$$$$$$$) $test .= " ( " . "" . "view descriptions )"; + "descriptions.$html_ext\">" . + "view descriptions )"; } } @@ -12351,7 +12398,8 @@ sub write_header(*$$$$$$$) # Left row push(@row_left, - [["10%", "headerItem", "Current view:"], ["10%", "headerValue", $view] + [["10%", "headerItem", "Current view:"], + ["10%", "headerValue", $view] ]); my $label = defined($baseline_title) ? "Current" : "Test"; push(@row_left, @@ -12571,8 +12619,10 @@ END_OF_HTML } if ($main::show_tla) { my @tlaRow = - buildHeaderSummaryTableRow($summary, SummaryInfo::LINE_DATA, - $fileDetail, \&SourceFile::nextTlaGroup, + buildHeaderSummaryTableRow($summary, + SummaryInfo::LINE_DATA, + $fileDetail, + \&SourceFile::nextTlaGroup, $tlaSummaryTypes); push(@dataRow, @tlaRow); } @@ -12663,12 +12713,15 @@ END_OF_HTML if ($type != $HDR_SOURCE && $type != $HDR_FUNC); my $table = - buildDateSummaryTable( - $summary, SummaryInfo::LINE_DATA, - \&SummaryInfo::lineCovCount, $fileDetail, - \&SourceFile::nextInDateBin, "Line coverage date bins:", - $dateBinDetailPage, scalar(@dataRow), - $tlaSummaryTypes); + buildDateSummaryTable($summary, + SummaryInfo::LINE_DATA, + \&SummaryInfo::lineCovCount, + $fileDetail, + \&SourceFile::nextInDateBin, + "Line coverage date bins:", + $dateBinDetailPage, + scalar(@dataRow), + $tlaSummaryTypes); push(@row_right, @$table) if ($type != $HDR_TESTDESC); @@ -12819,9 +12872,17 @@ sub get_sort_code($$$) } my $help = " title=\"Click to sort table by $alt\""; $alt = "Sort by $alt"; - return " " . $link_start . - '' . $link_end . ''; + return " " . + $link_start . + '' . + $link_end . + ''; } sub get_file_code($$$$$$) @@ -12857,18 +12918,28 @@ sub get_line_code($$$$$$$) # Text + link to detail view my $help = "title=\"Click to go to per-testcase coverage details\""; my $detail_link = - 'index' . $key . $bin_type . - '-detail' . $fileview_sortname[$sort_type] . '.' . $html_ext; + 'index' . + $key . + $bin_type . + '-detail' . + $fileview_sortname[$sort_type] . '.' . + $html_ext; $result .= " ( show details )'; + 'class="detail" href="' . + $detail_link . + '">show details )'; } else { # Text + link to standard view my $help = "title=\"Click to hide per-testcase coverage details\""; $result .= - " ( hide details )'; + " ( hide details )'; } # Add sort button $result .= get_sort_code($sort_link, "line coverage", $base); @@ -13012,22 +13083,31 @@ sub write_file_table(*$$$$$$) get_file_code($hide, $file_col_title, $use_sort_button && $sort_type != $SORT_FILE, $bin_type, $primary_key, $base_dir); - my $line_code = get_line_code($show, $sort_type, + my $line_code = get_line_code($show, + $sort_type, "Line Coverage", $use_sort_button && $sort_type != $SORT_LINE, - $bin_type, $primary_key, $base_dir); + $bin_type, + $primary_key, + $base_dir); my $func_code = get_func_code($hide, "Function Coverage", $use_sort_button && $sort_type != $SORT_FUNC, - $bin_type, $primary_key, $base_dir); + $bin_type, + $primary_key, + $base_dir); my $br_code = get_br_code($hide, "Branch Coverage", $use_sort_button && $sort_type != $SORT_BRANCH, - $bin_type, $primary_key, $base_dir); + $bin_type, + $primary_key, + $base_dir); my $mcdc_code = get_mcdc_code($hide, "MC/DC Coverage", $use_sort_button && $sort_type != $SORT_MCDC, - $bin_type, $primary_key, $base_dir); + $bin_type, + $primary_key, + $base_dir); my @head_columns; @@ -13085,9 +13165,12 @@ sub write_file_table(*$$$$$$) $showBinDetail = 'owner'; } my $num_columns = - write_file_table_prolog(*HTML_HANDLE, $file_code, + write_file_table_prolog( + *HTML_HANDLE, + $file_code, defined($showBinDetail) ? $showBinDetail : undef, - $primary_key, @head_columns); + $primary_key, + @head_columns); my @tableRows; if ($primary_key eq 'name') { @@ -13514,9 +13597,9 @@ sub write_file_table(*$$$$$$) push(@results, [$found, $hit, SummaryInfo::LINE_DATA, - TestcaseTlaCount->new( - $testdata->value($testname), $fileDetails, - SummaryInfo::LINE_DATA) + TestcaseTlaCount->new($testdata->value($testname), + $fileDetails, + SummaryInfo::LINE_DATA) ]); # there might not be optional test data for some tests - that type was # not enabled @@ -13524,9 +13607,9 @@ sub write_file_table(*$$$$$$) [$mcdc_found, $mcdc_hit, SummaryInfo::MCDC_DATA, - TestcaseTlaCount->new( - $test_mcdc->value($testname), $fileDetails, - SummaryInfo::MCDC_DATA) + TestcaseTlaCount->new($test_mcdc->value($testname), + $fileDetails, + SummaryInfo::MCDC_DATA) ]) if ($hasMcdcData && defined($test_mcdc->value($testname))); @@ -13535,9 +13618,9 @@ sub write_file_table(*$$$$$$) [$br_found, $br_hit, SummaryInfo::BRANCH_DATA, - TestcaseTlaCount->new( - $testbrdata->value($testname), $fileDetails, - SummaryInfo::BRANCH_DATA) + TestcaseTlaCount->new($testbrdata->value($testname), + $fileDetails, + SummaryInfo::BRANCH_DATA) ]) if ($hasBranchData && defined($testbrdata->value($testname))); @@ -13546,9 +13629,9 @@ sub write_file_table(*$$$$$$) [$fn_found, $fn_hit, SummaryInfo::FUNCTION_DATA, - TestcaseTlaCount->new( - $testfncdata->value($testname), $fileDetails, - SummaryInfo::FUNCTION_DATA) + TestcaseTlaCount->new($testfncdata->value($testname), + $fileDetails, + SummaryInfo::FUNCTION_DATA) ]) if ($includeFunctionColumns && defined($testfncdata->value($testname))); @@ -13557,8 +13640,10 @@ sub write_file_table(*$$$$$$) # Insert link to description of available if ($test_description{$testname}) { $href = - "" . "$testname"; + "" . + "$testname"; } write_file_table_detail_entry(*HTML_HANDLE, $base_dir, $href, $showBinDetail, $activeTlaCols, @results); @@ -13665,7 +13750,8 @@ sub write_source($$$$$$$$) # foreground/background - to make distinctive $empty .= ' ' . - (' ' x (8 - 3)) . '...'; + (' ' x (8 - 3)) . + '...'; $empty .= ' ' x $main::br_field_width if $showBranches; $empty .= ' ' x $main::mcdc_field_width if $showMcdc; $empty .= ' ' x $main::tla_field_width; @@ -14090,7 +14176,8 @@ sub remove_unused_descriptions() $after = scalar(keys(%test_description)); if ($after < $before) { - info("Removed " . ($before - $after) . + info("Removed " . + ($before - $after) . " unused descriptions, $after remaining.\n"); } } diff --git a/bin/geninfo b/bin/geninfo index 2afb0d60..e79fec33 100755 --- a/bin/geninfo +++ b/bin/geninfo @@ -884,15 +884,16 @@ sub add_worklist_entry { my ($self, $filename, $directory) = @_; if (exists($self->[1]->{$filename})) { - lcovutil::ignorable_error($lcovutil::ERROR_USAGE, - "duplicate file $filename in both " . - $self->[1]->{$filename} . - " and $directory" - . - (lcovutil::is_ignored( - $lcovutil::ERROR_USAGE) ? - ' (skip latter)' : - '')); + lcovutil::ignorable_error( + $lcovutil::ERROR_USAGE, + "duplicate file $filename in both " . + $self->[1]->{$filename} . + " and $directory" + . + ( + lcovutil::is_ignored($lcovutil::ERROR_USAGE) + ? ' (skip latter)' : + '')); return; } $self->[1]->{$filename} = $directory; @@ -1337,8 +1338,8 @@ sub gen_info(@) @predicted = sort({ $b->[1] <=> $a->[1] or $a->[2] cmp $b->[2] } @predicted); - lcovutil::info(scalar(@unknown) . - ' (of ' . (scalar(@predicted) + scalar(@unknown)) . + lcovutil::info(scalar(@unknown) . ' (of ' . + (scalar(@predicted) + scalar(@unknown)) . ") files do not appear in \'--history\' profile.\n") if (@unknown); if (@predicted) { @@ -1548,8 +1549,8 @@ sub gen_info(@) $lcovutil::maxParallelism = 1; if ($chunk->[0]) { my $num = scalar(@{$chunk->[1]}); - lcovutil::info( - "Processing $num file" . ($num == 1 ? '' : 's') . + lcovutil::info("Processing $num file" . + ($num == 1 ? '' : 's') . " from chunk 0 serially\n"); } my $now = Time::HiRes::gettimeofday(); @@ -1663,8 +1664,9 @@ sub process_dafile($$$$) # Try to find base directory automatically if requested by user if ($lcovutil::rc_auto_base) { - $base_dir = find_base_from_source($base_dir, - [keys(%{$instr}), keys(%{$graph})]); + $base_dir = + find_base_from_source($base_dir, + [keys(%{$instr}), keys(%{$graph})]); } adjust_source_filenames($instr, $base_dir); @@ -1767,8 +1769,9 @@ sub process_dafile($$$$) # Skip files that are not mentioned in the graph file if (!@matches) { lcovutil::ignorable_error($lcovutil::ERROR_MISMATCH, - "cannot find an entry for " . - $gcov_file . " in $graph_file_extension file"); + "cannot find an entry for " . + $gcov_file . + " in $graph_file_extension file"); unlink($gcov_file) unless $lcovutil::preserve_intermediates; next; } @@ -1777,8 +1780,9 @@ sub process_dafile($$$$) $source_filename = $matches[0]; } else { # Try to solve the ambiguity - $source_filename = solve_ambiguous_match($gcov_file, \@matches, - \@gcov_content); + $source_filename = + solve_ambiguous_match($gcov_file, \@matches, + \@gcov_content); } $source_filename = ReadCurrentSource::resolve_path($source_filename, 1); @@ -2647,8 +2651,7 @@ sub intermediate_json_to_info($) ); if ($lcovutil::opt_adjust_unexecuted_blocks) { $count = 0; - } elsif ( - lcovutil::warn_once("unexecuted block", + } elsif (lcovutil::warn_once("unexecuted block", $ERROR_INCONSISTENT_DATA) ) { lcovutil::ignorable_warning($ERROR_INCONSISTENT_DATA, @@ -3180,8 +3183,9 @@ sub process_graphfile($$) # Try to find base directory automatically if requested by user if ($lcovutil::rc_auto_base) { - $base_dir = find_base_from_source($base_dir, - [keys(%{$instr}), keys(%{$graph})]); + $base_dir = + find_base_from_source($base_dir, + [keys(%{$instr}), keys(%{$graph})]); } adjust_source_filenames($instr, $base_dir); diff --git a/bin/lcov b/bin/lcov index 9da08340..c2bef51d 100755 --- a/bin/lcov +++ b/bin/lcov @@ -311,13 +311,14 @@ if (@ARGV && $reset) ) { die("Extra parameter found: '" . - join(" ", @ARGV) . - "'\n" . "Use $tool_name --help to get usage information\n"); + join(" ", @ARGV) . "'\n" . + "Use $tool_name --help to get usage information\n"); } if (!@ARGV) { if ($directory || $kernel_directory) { - die("--" . ($directory ? "directory" : "kernel-directory") . + die("--" . + ($directory ? "directory" : "kernel-directory") . " specified but no directories provided\n" . "Use $tool_name --help to get usage information\n"); } @@ -327,7 +328,8 @@ if (!@ARGV) { [scalar(@intersect), '--intersect'], [scalar(@difference), '--subtract'], ) { - die($d->[1] . " specified but no tracefiles provided\n" . + die($d->[1] . + " specified but no tracefiles provided\n" . "Use $tool_name --help to get usage information\n") if ($d->[0]); } @@ -404,7 +406,8 @@ eval { info("Pruned result: retained " . scalar(@$pruned) . " of " . - scalar(@$merged) . " files\n"); + scalar(@$merged) . + " files\n"); my $file = InOutFile->out($output_filename); my $hdl = $file->hdl(); print($hdl join("\n", @$pruned) . "\n"); @@ -595,7 +598,8 @@ sub check_options() $i > 1) { die("invalid command line:\n $0 " . join(' ', @main::cmdArgs) . - "\nNeed " . ($i > 1 ? 'only ' : '') . + "\nNeed " . + ($i > 1 ? 'only ' : '') . "one of options -z, -c, -a, -e, -r, -l, --intersect, --subtract, or --summary\n" . "Use $tool_name --help to get usage information\n"); } @@ -894,8 +898,7 @@ sub lcov_geninfo(@) } push(@param, "--base-directory", $base_directory) if $base_directory; - foreach ( - split($lcovutil::split_char, + foreach (split($lcovutil::split_char, join($lcovutil::split_char, @lcovutil::opt_ignore_errors)) ) { # pass only the 'ignore' options that geninfo understands @@ -1605,14 +1608,15 @@ sub merge_traces($$) my @data = AggregateTraces::find_from_glob(@ARGV); info('.. found: ' . - scalar(@data) . " 'base' trace file" . + scalar(@data) . + " 'base' trace file" . (1 == scalar(@data) ? '' : 's') . ".\n"); die("must specify at least one 'base' tracefile") unless @data; my @merge = AggregateTraces::find_from_glob(@$list); info(' ' . - scalar(@merge) . - ' file' . (1 == scalar(@merge) ? '' : 's') . ' to ' . + scalar(@merge) . ' file' . + (1 == scalar(@merge) ? '' : 's') . ' to ' . ($op == TraceInfo::INTERSECT ? 'intersect' : 'subtract') . ".\n"); my $srcReader = ReadCurrentSource->new(); @@ -2022,7 +2026,8 @@ sub setup_gkv() # Check /proc $dir = defined($gcov_dir) ? $gcov_dir : $proc_dir; if (check_gkv_proc($dir)) { - info("Found " . $GKV_NAME[$GKV_PROC] . + info("Found " . + $GKV_NAME[$GKV_PROC] . " gcov kernel support at $dir\n"); return ($GKV_PROC, $dir); } diff --git a/bin/perl2lcov b/bin/perl2lcov index 0e54b3af..18e225ab 100755 --- a/bin/perl2lcov +++ b/bin/perl2lcov @@ -256,8 +256,10 @@ foreach my $db_path (@ARGV) { ) { next unless defined($c->[1]); foreach my $line ($c->[1]->items) { - lcovutil::ignorable_error($lcovutil::ERROR_INCONSISTENT_DATA, - 'found ' . $c->[0] . + lcovutil::ignorable_error( + $lcovutil::ERROR_INCONSISTENT_DATA, + 'found ' . + $c->[0] . " coverpoint on $line but no lineCov there" ) unless defined($stmts->location($line)); } @@ -414,7 +416,8 @@ foreach my $db_path (@ARGV) { --$last; } lcovutil::info(1, - "resetting " . $func->name() . + "resetting " . + $func->name() . " end line to $last (from $end)\n"); $func->set_end_line($last); diff --git a/lib/lcovutil.pm b/lib/lcovutil.pm index f7d72d79..74a428e8 100644 --- a/lib/lcovutil.pm +++ b/lib/lcovutil.pm @@ -1033,7 +1033,8 @@ sub configure_callback }; if ($@ || !defined($$cb)) { - lcovutil::ignorable_error($lcovutil::ERROR_PACKAGE, + lcovutil::ignorable_error( + $lcovutil::ERROR_PACKAGE, "unable to create callback from module '$script'" . (defined($@) ? ": $@" : '')); } @@ -1114,93 +1115,90 @@ my ($cExtensions, $rtlExtensions, $javaExtensions, $perlExtensions, $pythonExtensions); my %rc_common = ( - 'derive_function_end_line' => \$lcovutil::derive_function_end_line, - 'derive_function_end_line_all_files' => + 'derive_function_end_line' => \$lcovutil::derive_function_end_line, + 'derive_function_end_line_all_files' => \$derive_function_end_line_all_files, - 'trivial_function_threshold' => \$lcovutil::trivial_function_threshold, - "lcov_tmp_dir" => \$lcovutil::tmp_dir, - "lcov_json_module" => \$JsonSupport::rc_json_module, - "branch_coverage" => \$lcovutil::br_coverage, - 'mcdc_coverage' => \$lcovutil::mcdc_coverage, - "function_coverage" => \$lcovutil::func_coverage, - "lcov_excl_line" => \$lcovutil::EXCL_LINE, - "lcov_excl_br_line" => \$lcovutil::EXCL_BR_LINE, - "lcov_excl_exception_br_line" => \$lcovutil::EXCL_EXCEPTION_LINE, - "lcov_excl_start" => \$lcovutil::EXCL_START, - "lcov_excl_stop" => \$lcovutil::EXCL_STOP, - "lcov_excl_br_start" => \$lcovutil::EXCL_BR_START, - "lcov_excl_br_stop" => \$lcovutil::EXCL_BR_STOP, - "lcov_excl_exception_br_start" => \$lcovutil::EXCL_EXCEPTION_BR_START, - "lcov_excl_exception_br_stop" => \$lcovutil::EXCL_EXCEPTION_BR_STOP, - 'lcov_unreachable_start' => \$lcovutil::UNREACHABLE_START, - 'lcov_unreachable_stop' => \$lcovutil::UNREACHABLE_STOP, - 'lcov_unreachable_line' => \$lcovutil::UNREACHABLE_LINE, - 'retain_unreachable_coverpoints_if_executed' => + 'trivial_function_threshold' => \$lcovutil::trivial_function_threshold, + "lcov_tmp_dir" => \$lcovutil::tmp_dir, + "lcov_json_module" => \$JsonSupport::rc_json_module, + "branch_coverage" => \$lcovutil::br_coverage, + 'mcdc_coverage' => \$lcovutil::mcdc_coverage, + "function_coverage" => \$lcovutil::func_coverage, + "lcov_excl_line" => \$lcovutil::EXCL_LINE, + "lcov_excl_br_line" => \$lcovutil::EXCL_BR_LINE, + "lcov_excl_exception_br_line" => \$lcovutil::EXCL_EXCEPTION_LINE, + "lcov_excl_start" => \$lcovutil::EXCL_START, + "lcov_excl_stop" => \$lcovutil::EXCL_STOP, + "lcov_excl_br_start" => \$lcovutil::EXCL_BR_START, + "lcov_excl_br_stop" => \$lcovutil::EXCL_BR_STOP, + "lcov_excl_exception_br_start" => \$lcovutil::EXCL_EXCEPTION_BR_START, + "lcov_excl_exception_br_stop" => \$lcovutil::EXCL_EXCEPTION_BR_STOP, + 'lcov_unreachable_start' => \$lcovutil::UNREACHABLE_START, + 'lcov_unreachable_stop' => \$lcovutil::UNREACHABLE_STOP, + 'lcov_unreachable_line' => \$lcovutil::UNREACHABLE_LINE, + 'retain_unreachable_coverpoints_if_executed' => \$lcovutil::retainUnreachableCoverpointIfHit, - "ignore_unreachable_flag" => \$lcovutil::ignore_unreachable_flag, - "ignore_errors" => \@rc_ignore, - "max_message_count" => \$lcovutil::suppressAfter, - "message_log" => \$lcovutil::message_log, - 'expected_message_count' => \@rc_expected_msg_counts, - 'stop_on_error' => \$lcovutil::stop_on_error, - 'treat_warning_as_error' => \$lcovutil::treat_warning_as_error, - 'warn_once_per_file' => \$lcovutil::warn_once_per_file, - 'check_data_consistency' => \$lcovutil::check_data_consistency, - "rtl_file_extensions" => \$rtlExtensions, - "c_file_extensions" => \$cExtensions, - "perl_file_extensions" => \$perlExtensions, - "python_file_extensions" => \$pythonExtensions, - "java_file_extensions" => \$javaExtensions, - 'info_file_pattern' => \$info_file_pattern, - "filter_lookahead" => \$lcovutil::source_filter_lookahead, - "filter_bitwise_conditional" => + "ignore_unreachable_flag" => \$lcovutil::ignore_unreachable_flag, + "ignore_errors" => \@rc_ignore, + "max_message_count" => \$lcovutil::suppressAfter, + "message_log" => \$lcovutil::message_log, + 'expected_message_count' => \@rc_expected_msg_counts, + 'stop_on_error' => \$lcovutil::stop_on_error, + 'treat_warning_as_error' => \$lcovutil::treat_warning_as_error, + 'warn_once_per_file' => \$lcovutil::warn_once_per_file, + 'check_data_consistency' => \$lcovutil::check_data_consistency, + "rtl_file_extensions" => \$rtlExtensions, + "c_file_extensions" => \$cExtensions, + "perl_file_extensions" => \$perlExtensions, + "python_file_extensions" => \$pythonExtensions, + "java_file_extensions" => \$javaExtensions, + 'info_file_pattern' => \$info_file_pattern, + "filter_lookahead" => \$lcovutil::source_filter_lookahead, + "filter_bitwise_conditional" => \$lcovutil::source_filter_bitwise_are_conditional, - 'filter_blank_aggressive' => \$filter_blank_aggressive, - "profile" => \$lcovutil::profile, - "parallel" => \$lcovutil::maxParallelism, - "memory" => \$lcovutil::maxMemory, - "memory_percentage" => \$lcovutil::memoryPercentage, - "max_fork_fails" => \$lcovutil::max_fork_fails, - "max_tasks_per_core" => \$lcovutil::max_tasks_per_core, - "fork_fail_timeout" => \$lcovutil::fork_fail_timeout, - 'source_directory' => \@rc_source_directories, - 'build_directory' => \@rc_build_dir, - - "no_exception_branch" => \$lcovutil::exclude_exception_branch, - 'filter' => \@rc_filter, - 'exclude' => \@rc_exclude_patterns, - 'include' => \@rc_include_patterns, - 'substitute' => \@rc_subst_patterns, - 'omit_lines' => \@rc_omit_patterns, - 'erase_functions' => \@rc_erase_patterns, - 'context_script' => \@rc_contextCallback, - "version_script" => \@rc_version_script, - 'resolve_script' => \@rc_resolveCallback, - 'criteria_callback_data' => - \@CoverageCriteria::criteriaCallbackTypes, - 'criteria_callback_levels' => - \@CoverageCriteria::criteriaCallbackLevels, - 'criteria_script' => \@rc_criteria_script, - 'unreachable_script' => \@rc_excludeCoverpointCallback, - - "checksum" => \$lcovutil::verify_checksum, - 'compute_file_version' => \$lcovutil::compute_file_version, - "case_insensitive" => \$lcovutil::case_insensitive, - "forget_testcase_names" => \$TraceFile::ignore_testcase_name, - "split_char" => \$lcovutil::split_char, - - 'check_existence_before_callback' => - \$check_file_existence_before_callback, - - "demangle_cpp" => \@lcovutil::cpp_demangle, - 'excessive_count_threshold' => \$excessive_count_threshold, - - 'sort_input' => \$lcovutil::sort_inputs, - - "fail_under_lines" => \$fail_under_lines, - "fail_under_branches" => \$fail_under_branches, - 'lcov_filter_parallel' => \$lcovutil::lcov_filter_parallel, - 'lcov_filter_chunk_size' => \$lcovutil::lcov_filter_chunk_size,); + 'filter_blank_aggressive' => \$filter_blank_aggressive, + "profile" => \$lcovutil::profile, + "parallel" => \$lcovutil::maxParallelism, + "memory" => \$lcovutil::maxMemory, + "memory_percentage" => \$lcovutil::memoryPercentage, + "max_fork_fails" => \$lcovutil::max_fork_fails, + "max_tasks_per_core" => \$lcovutil::max_tasks_per_core, + "fork_fail_timeout" => \$lcovutil::fork_fail_timeout, + 'source_directory' => \@rc_source_directories, + 'build_directory' => \@rc_build_dir, + + "no_exception_branch" => \$lcovutil::exclude_exception_branch, + 'filter' => \@rc_filter, + 'exclude' => \@rc_exclude_patterns, + 'include' => \@rc_include_patterns, + 'substitute' => \@rc_subst_patterns, + 'omit_lines' => \@rc_omit_patterns, + 'erase_functions' => \@rc_erase_patterns, + 'context_script' => \@rc_contextCallback, + "version_script" => \@rc_version_script, + 'resolve_script' => \@rc_resolveCallback, + 'criteria_callback_data' => \@CoverageCriteria::criteriaCallbackTypes, + 'criteria_callback_levels' => \@CoverageCriteria::criteriaCallbackLevels, + 'criteria_script' => \@rc_criteria_script, + 'unreachable_script' => \@rc_excludeCoverpointCallback, + + "checksum" => \$lcovutil::verify_checksum, + 'compute_file_version' => \$lcovutil::compute_file_version, + "case_insensitive" => \$lcovutil::case_insensitive, + "forget_testcase_names" => \$TraceFile::ignore_testcase_name, + "split_char" => \$lcovutil::split_char, + + 'check_existence_before_callback' => \$check_file_existence_before_callback, + + "demangle_cpp" => \@lcovutil::cpp_demangle, + 'excessive_count_threshold' => \$excessive_count_threshold, + + 'sort_input' => \$lcovutil::sort_inputs, + + "fail_under_lines" => \$fail_under_lines, + "fail_under_branches" => \$fail_under_branches, + 'lcov_filter_parallel' => \$lcovutil::lcov_filter_parallel, + 'lcov_filter_chunk_size' => \$lcovutil::lcov_filter_chunk_size,); # lcov needs to know the options which might get passed to geninfo in --capture mode our $defaultChunkSize; # for performance tweaking @@ -1234,57 +1232,55 @@ our %geninfo_rc_opts = ( 'geninfo_interval_update' => \$defaultInterval, 'geninfo_capture_all' => \$geninfo_captureAll); -our %argCommon = ("tempdir=s" => \$tempdirname, - "version-script=s" => \@lcovutil::extractVersionScript, - "criteria-script=s" => - \@CoverageCriteria::coverageCriteriaScript, - - "checksum" => \$lcovutil::verify_checksum, - "no-checksum" => \$rc_no_checksum, - "quiet|q+" => \$quiet, - "verbose|v+" => \$lcovutil::verbose, - "debug+" => \$lcovutil::debug, - "help|h|?" => \$help, - "version" => \$version, - 'comment=s' => \@comments, - 'toolname=s' => \$lcovutil::tool_name, - - "function-coverage" => \$lcovutil::func_coverage, - "branch-coverage" => \$lcovutil::br_coverage, - 'mcdc-coverage' => \$lcovutil::mcdc_coverage, - "no-function-coverage" => \$rc_no_func_coverage, - "no-branch-coverage" => \$rc_no_branch_coverage, - - "fail-under-lines=s" => \$fail_under_lines, - "fail-under-branches=s" => \$fail_under_branches, - 'source-directory=s' => - \@ReadCurrentSource::source_directories, - 'build-directory=s' => \@lcovutil::build_directory, - - 'resolve-script=s' => \@lcovutil::resolveCallback, - 'context-script=s' => \@lcovutil::contextCallback, - 'unreachable-script=s' => - \@lcovutil::excludeCoverpointCallback, - "filter=s" => \@opt_filter, - "demangle-cpp:s" => \@lcovutil::cpp_demangle, - "ignore-errors=s" => \@opt_ignore_errors, - "expect-message-count=s" => \@opt_expected_message_counts, - 'msg-log:s' => \$message_log, - "keep-going" => \$keepGoing, - "config-file=s" => \@unsupported_config, - "rc=s%" => \%unsupported_rc, - "profile:s" => \$lcovutil::profile, - 'history-script=s' => \@lcovutil::profileHistoryCallback, - "exclude=s" => \@lcovutil::exclude_file_patterns, - "include=s" => \@lcovutil::include_file_patterns, - "erase-functions=s" => \@lcovutil::exclude_function_patterns, - "omit-lines=s" => \@lcovutil::omit_line_patterns, - "substitute=s" => \@lcovutil::file_subst_patterns, - "parallel|j:i" => \$lcovutil::maxParallelism, - "memory=i" => \$lcovutil::maxMemory, - "forget-test-names" => \$TraceFile::ignore_testcase_name, - "preserve" => \$lcovutil::preserve_intermediates, - 'sort-input' => \$lcovutil::sort_inputs,); +our %argCommon = ( + "tempdir=s" => \$tempdirname, + "version-script=s" => \@lcovutil::extractVersionScript, + "criteria-script=s" => \@CoverageCriteria::coverageCriteriaScript, + + "checksum" => \$lcovutil::verify_checksum, + "no-checksum" => \$rc_no_checksum, + "quiet|q+" => \$quiet, + "verbose|v+" => \$lcovutil::verbose, + "debug+" => \$lcovutil::debug, + "help|h|?" => \$help, + "version" => \$version, + 'comment=s' => \@comments, + 'toolname=s' => \$lcovutil::tool_name, + + "function-coverage" => \$lcovutil::func_coverage, + "branch-coverage" => \$lcovutil::br_coverage, + 'mcdc-coverage' => \$lcovutil::mcdc_coverage, + "no-function-coverage" => \$rc_no_func_coverage, + "no-branch-coverage" => \$rc_no_branch_coverage, + + "fail-under-lines=s" => \$fail_under_lines, + "fail-under-branches=s" => \$fail_under_branches, + 'source-directory=s' => \@ReadCurrentSource::source_directories, + 'build-directory=s' => \@lcovutil::build_directory, + + 'resolve-script=s' => \@lcovutil::resolveCallback, + 'context-script=s' => \@lcovutil::contextCallback, + 'unreachable-script=s' => \@lcovutil::excludeCoverpointCallback, + "filter=s" => \@opt_filter, + "demangle-cpp:s" => \@lcovutil::cpp_demangle, + "ignore-errors=s" => \@opt_ignore_errors, + "expect-message-count=s" => \@opt_expected_message_counts, + 'msg-log:s' => \$message_log, + "keep-going" => \$keepGoing, + "config-file=s" => \@unsupported_config, + "rc=s%" => \%unsupported_rc, + "profile:s" => \$lcovutil::profile, + 'history-script=s' => \@lcovutil::profileHistoryCallback, + "exclude=s" => \@lcovutil::exclude_file_patterns, + "include=s" => \@lcovutil::include_file_patterns, + "erase-functions=s" => \@lcovutil::exclude_function_patterns, + "omit-lines=s" => \@lcovutil::omit_line_patterns, + "substitute=s" => \@lcovutil::file_subst_patterns, + "parallel|j:i" => \$lcovutil::maxParallelism, + "memory=i" => \$lcovutil::maxMemory, + "forget-test-names" => \$TraceFile::ignore_testcase_name, + "preserve" => \$lcovutil::preserve_intermediates, + 'sort-input' => \$lcovutil::sort_inputs,); sub warnDeprecated { @@ -1357,7 +1353,8 @@ sub read_config($$) lcovutil::ignorable_error($lcovutil::ERROR_USAGE, 'config file inclusion loop detected: "' . join('" -> "', @include_stack) . - '" -> "' . $filename . '"'); + '" -> "' . + $filename . '"'); return 0; } $included_config_files{$path} = 1; @@ -1538,8 +1535,7 @@ sub parseOptions $message_log = ( defined($$output_arg) ? substr($$output_arg, 0, rindex($$output_arg, '.')) : - $tool_name) . - ".msg"; + $tool_name) . ".msg"; } $message_filename = $message_log; open(LOG, ">", $message_log) or @@ -1556,7 +1552,8 @@ sub parseOptions [\@lcovutil::include_file_patterns, \@rc_include_patterns], [\@lcovutil::file_subst_patterns, \@rc_subst_patterns], [\@lcovutil::omit_line_patterns, \@rc_omit_patterns], - [\@lcovutil::exclude_function_patterns, \@rc_erase_patterns + [\@lcovutil::exclude_function_patterns, + \@rc_erase_patterns ], [\@lcovutil::extractVersionScript, \@rc_version_script], [\@CoverageCriteria::coverageCriteriaScript, @@ -1947,7 +1944,9 @@ sub summarize_messages next unless $total{$type}; $found = 1; my $leader = - $header . ' ' . $total{$type} . " $type message" . + $header . ' ' . + $total{$type} . + " $type message" . ($total{$type} > 1 ? 's' : '') . ":\n"; my $h = $message_types{$type}; foreach my $k (sort keys %$h) { @@ -1995,7 +1994,8 @@ sub parse_expected_message_counts(@) my $id = $ERROR_ID{lc($1)}; if (defined($expected_message_count[$id])) { my $ignore = $lcovutil::ignore[$lcovutil::ERROR_USAGE]; - lcovutil::ignorable_error($lcovutil::ERROR_USAGE, + lcovutil::ignorable_error( + $lcovutil::ERROR_USAGE, "duplicate 'expected' constraint '$c'" . ($ignore ? ': ignoring.' : '')); next; @@ -2448,7 +2448,9 @@ sub report_fork_failure lcovutil::is_ignored($lcovutil::ERROR_FORK) ? ' (retrying)' : ''; lcovutil::ignorable_error($lcovutil::ERROR_FORK, "fork() syscall failed while trying to $when: " . - $errcode . $retry . $explain); + $errcode . + $retry . + $explain); # if errors were ignored, then we wait for a while (in parent) # before re-trying. sleep($lcovutil::fork_fail_timeout); @@ -2466,8 +2468,8 @@ sub report_exit_status if ($signal) { $explain = "$prefix died due to signal $signal (SIG" . - (split(' ', $Config{sig_name}))[$signal] . - ')' . MessageContext::context() . + (split(' ', $Config{sig_name}))[$signal] . ')' . + MessageContext::context() . ': possibly killed by OS due to out-of-memory'; $explain .= lcovutil::explain_once('out_of_memory', @@ -2608,12 +2610,17 @@ sub summarize_cov_filters my $points = ''; if ($histogram->[-2] != $histogram->[-1]) { $points = - ' ' . $histogram->[-1] . ' coverpoint' . + ' ' . + $histogram->[-1] . + ' coverpoint' . ($histogram->[-1] > 1 ? 's' : '') . "\n"; } info(-1, - "$leader $key:\n " . $histogram->[-2] . " instance" . - ($histogram->[-2] > 1 ? "s" : "") . "\n" . $points); + "$leader $key:\n " . + $histogram->[-2] . + " instance" . + ($histogram->[-2] > 1 ? "s" : "") . "\n" . + $points); $leader = ''; } foreach my $q (['omit-lines', 'line', \@omit_line_patterns], @@ -2897,7 +2904,8 @@ sub checkVersionMatch return 1 unless $status; # match if return code was zero } unless ($silent) { - lcovutil::ignorable_error($ERROR_VERSION, + lcovutil::ignorable_error( + $ERROR_VERSION, (defined($reason) ? ($reason . ' ') : '') . "$filename: revision control version mismatch: " . (defined($me) ? $me : 'undef') . ' <- ' . @@ -3018,10 +3026,11 @@ sub new open(HTML, '<', $name) or die("unable to open $name: $!"); while () { if (/<(a|span) .*id=\"([^\"]+)\"/) { - lcovutil::ignorable_error($lcovutil::ERROR_USAGE, + lcovutil::ignorable_error( + $lcovutil::ERROR_USAGE, "\"$name\":$.: duplicate anchor '$2' original at " . - $self->[ANCHORS]->{$2} . '.') - if exists($self->[ANCHORS]->{$2}); + $self->[ANCHORS]->{$2} . '.' + ) if exists($self->[ANCHORS]->{$2}); $self->[ANCHORS]->{$2} = $.; } elsif (/[0] . '" not head of ("' . + die('unbalanced context "' . + $self->[0] . + '" not head of ("' . join('" "', @message_context) . '")') unless scalar(@message_context) && $self->[0] eq $message_context[-1]; pop(@message_context); @@ -3292,7 +3303,8 @@ sub close if (0 != $? && $checkError) { # $reason: $cmd returned non-zero exit... lcovutil::ignorable_error($lcovutil::ERROR_CALLBACK, - $self->[0] . ' \'' . $self->[1] . + $self->[0] . ' \'' . + $self->[1] . "\' returned non-zero exit code: '$!'"); } pop(@$self); @@ -4264,8 +4276,11 @@ sub merge lcovutil::ignorable_warning($lcovutil::ERROR_MISMATCH, "$filename:$line: attempt to merge incompatible expressions for id" . $self->id() - . ', ' . $that->id() . ": '" . - $self->exprString() . "' -> '" . $that->exprString() . "'.") + . ', ' . + $that->id() . ": '" . + $self->exprString() . + "' -> '" . + $that->exprString() . "'.") if ($self->exprString() ne $that->exprString()); } # LCOV_EXCL_STOP @@ -4275,9 +4290,11 @@ sub merge my $loc = defined($filename) ? "\"$filename\":$line: " : ''; lcovutil::ignorable_error($lcovutil::ERROR_MISMATCH, "${loc}mismatched exception tag for id " . - $self->id() . ", " . $that->id() . - ": '" . $self->is_exception() . - "' -> '" . $that->is_exception() . "'"); + $self->id() . ", " . + $that->id() . ": '" . + $self->is_exception() . + "' -> '" . + $that->is_exception() . "'"); # set 'self' to 'not related to exception' - to give a consistent # answer for the merge operation. Otherwise, we pick whatever # was seen first - which is unpredictable during threaded execution. @@ -4293,11 +4310,14 @@ sub merge # callback is called - so the two expressions will have both be # unset unless we really are trying to compare my $loc = defined($filename) ? "\"$filename\":$line: " : ''; - lcovutil::ignorable_error($lcovutil::ERROR_MISMATCH, + lcovutil::ignorable_error( + $lcovutil::ERROR_MISMATCH, "${loc}mismatched 'unreachable' tag for branch id " . $self->id() . ", " . - $that->id() . ": '" . $self->is_excluded() . - "' -> '" . $that->is_excluded() . "'"); + $that->id() . ": '" . + $self->is_excluded() . + "' -> '" . + $that->is_excluded() . "'"); # set 'self' to 'excluded' $changed = $self->[EXCLUDED] != 1; $self->[EXCLUDED] = 1; @@ -4630,14 +4650,17 @@ sub insertExpr $cond = $group->[$idx]; if ($cond->expression() ne $expr) { lcovutil::ignorable_error($lcovutil::ERROR_INCONSISTENT_DATA, - "\"$filename\":" . $self->line() . + "\"$filename\":" . + $self->line() . ": MC/DC group $groupSize expression $idx changed from '" . - $cond->expression() . "' to '$expr'"); + $cond->expression() . + "' to '$expr'"); } } else { if ($idx != scalar(@$group)) { lcovutil::ignorable_error($lcovutil::ERROR_FORMAT, - "\"$filename\":" . $self->line() . + "\"$filename\":" . + $self->line() . ": MC/DC group $groupSize: non-contiguous expression '$idx' found - should be '" . scalar(@$group) . "'."); @@ -4741,7 +4764,8 @@ sub merge my $e_excl = $e->is_excluded($sense); my $y_excl = $y->is_excluded($sense); lcovutil::ignorable_error($lcovutil::ERROR_MISMATCH, - "$filename:" . $self->line() . + "$filename:" . + $self->line() . ":mismatched 'unreachable' tag for MC/DC element $idx of group $size sense " . ($sense ? 'true' : 'false') . ": '$e_excl' -> '$y_excl'.") @@ -4972,9 +4996,13 @@ sub set_end_line my $suffix = lcovutil::explain_once('derive_end_line', " See lcovrc man entry for 'derive_function_end_line'."); - lcovutil::ignorable_error($lcovutil::ERROR_INCONSISTENT_DATA, - '"' . $self->file() . '":' . $self->line() . - ': function ' . $self->name() . + lcovutil::ignorable_error( + $lcovutil::ERROR_INCONSISTENT_DATA, + '"' . + $self->file() . '":' . + $self->line() . + ': function ' . + $self->name() . " end line $line less than start line " . $self->line() . ". Cannot derive function end line.$suffix" @@ -5043,8 +5071,9 @@ sub merge lcovutil::ignorable_error($lcovutil::ERROR_INCONSISTENT_DATA, $self->name() . " has different location than " . - $that->name() . " during merge") - if ($self->line() != $that->line()); + $that->name() . + " during merge" + ) if ($self->line() != $that->line()); while (my ($name, $count) = each(%{$that->[ALIASES]})) { $self->addAlias($name, $count); } @@ -5196,11 +5225,13 @@ sub define_function ) { $location = '"' . $self->filename() . '":' . $start_line unless defined($location); - lcovutil::ignorable_error($lcovutil::ERROR_INCONSISTENT_DATA, + lcovutil::ignorable_error( + $lcovutil::ERROR_INCONSISTENT_DATA, "$location: duplicate function '$fnName' starts on line \"" . $data->filename() . "\":$start_line but previous definition started on " . - $data->line() . MessageContext::context() . '.') + $data->line() . + MessageContext::context() . '.') unless grep({ $fnName =~ $_ } @lcovutil::suppress_function_patterns); # if ignored, just return the function we already have - @@ -5333,7 +5364,8 @@ sub union my $thisData; if (!exists($myData->{$key})) { $thisData = - $self->define_function($thatData->name(), $thatData->line(), + $self->define_function($thatData->name(), + $thatData->line(), $thatData->end_line()); $changed = 1; # something new... } else { @@ -5344,8 +5376,9 @@ sub union lc($thisData->file()) eq lc($thatData->file()))) )) { lcovutil::ignorable_error($lcovutil::ERROR_INCONSISTENT_DATA, - "function data mismatch at " . - $thatData->file() . ":" . $thatData->line()); + "function data mismatch at " . + $thatData->file() . ":" . + $thatData->line()); next; } } @@ -5588,8 +5621,11 @@ sub _checkCounts $found += $f; $hit += $h; } - die("invalid counts: found:" . $self->[BranchMap::FOUND] . - "->$found, hit:" . $self->[BranchMap::HIT] . "->$hit") + die("invalid counts: found:" . + $self->[BranchMap::FOUND] . + "->$found, hit:" . + $self->[BranchMap::HIT] . + "->$hit") unless ($self->[BranchMap::FOUND] == $found && $self->[BranchMap::HIT] == $hit); } @@ -5930,8 +5966,8 @@ sub removeBranches ++$filter->[-2] if $isMasterData; lcovutil::info(2, "$filename:$line: remove $count exception branch" . - (1 == $count ? '' : 'es') . "\n") - if $isMasterData; + (1 == $count ? '' : 'es') . "\n" + ) if $isMasterData; $filter->[-1] += $count; } my $remaining = $nElems - $count; @@ -6377,8 +6413,7 @@ sub merge } foreach my $name ($info->testcase_mcdc()->keylist()) { - if ( - &$mcdcOp($self->testcase_mcdc($name), $info->testcase_mcdc($name), + if (&$mcdcOp($self->testcase_mcdc($name), $info->testcase_mcdc($name), $filename) ) { $changed = 1; @@ -6584,18 +6619,22 @@ sub parseLines # $d->[5] is the 'stop' string my ($start, $stop, $ref, $reason) = @$d; if ($_ =~ $start) { - lcovutil::ignorable_error($lcovutil::ERROR_MISMATCH, + lcovutil::ignorable_error( + $lcovutil::ERROR_MISMATCH, "$filename: overlapping exclude directives. Found " . $d->[4] . " at line $line - but no matching " . - $d->[5] . - ' for ' . $d->[4] . ' at line ' . $$ref->[0]) - if $$ref; + $d->[5] . ' for ' . + $d->[4] . + ' at line ' . + $$ref->[0]) if $$ref; $$ref = [$line, $reason, $d->[4], $d->[5]]; last; } elsif ($_ =~ $stop) { - lcovutil::ignorable_error($lcovutil::ERROR_MISMATCH, - "$filename: found " . $d->[5] . + lcovutil::ignorable_error( + $lcovutil::ERROR_MISMATCH, + "$filename: found " . + $d->[5] . " directive at line $line without matching " . ($$ref ? $$ref->[2] : $d->[4]) . ' directive') @@ -6663,7 +6702,8 @@ sub parseLines ] ) { my ($key, $start, $stop) = @$t; - lcovutil::ignorable_error($lcovutil::ERROR_MISMATCH, + lcovutil::ignorable_error( + $lcovutil::ERROR_MISMATCH, "$filename: unmatched $start at line " . $key->[0] . " - saw EOF while looking for matching $stop" @@ -6756,8 +6796,10 @@ sub isOutOfRange my $c = ($context eq 'line') ? 'line' : "$context at line"; my $msg = "unknown $c '$lineNo' in " . - $self->filename() . ": there are only " . - scalar(@{$data->[EXCLUDE]}) . " lines in the file."; + $self->filename() . + ": there are only " . + scalar(@{$data->[EXCLUDE]}) . + " lines in the file."; if ($lcovutil::verbose || 0 == lcovutil::message_count($lcovutil::ERROR_RANGE)) { # only print verbose addition on first message @@ -6820,16 +6862,18 @@ sub isExcluded lcovutil::message_count($lcovutil::ERROR_RANGE) == 0 ]); lcovutil::store_deferred_message( - $lcovutil::ERROR_RANGE, - 1, $key, - "unknown line '$lineNo' in " . $self->filename() - . - (defined($data->[EXCLUDE]) ? - (" there are only " . - scalar(@{$data->[EXCLUDE]}) . - " lines in the file.") : - "") . - $suffix + $lcovutil::ERROR_RANGE, + 1, $key, + "unknown line '$lineNo' in " . + $self->filename() + . + ( + defined($data->[EXCLUDE]) ? + (" there are only " . + scalar(@{$data->[EXCLUDE]}) . + " lines in the file.") : + "") . + $suffix ) if lcovutil::warn_once($lcovutil::ERROR_RANGE, $key); return 0; # even though out of range - this is not excluded by filter } @@ -7287,7 +7331,7 @@ sub print_summary )) if ($br_do); lcovutil::info(" conditions..: %s\n", lcovutil::get_overall_line( - $counts[4]->[0], $counts[4]->[1], "condition" + $counts[4]->[0], $counts[4]->[1], "condition" )) if ($mcdc_do); } @@ -7547,7 +7591,8 @@ sub _eraseFunctions lcovutil::info( 1 + (0 == $isMasterList), "exclude FN $name line range $source_file:[" . - $fcn->line() . ":$end_line] due to '" . + $fcn->line() . + ":$end_line] due to '" . $p->[-2] . "'\n"); } _eraseFunction($fcn, $alias, $end_line, @@ -7619,8 +7664,10 @@ sub _deriveFunctionEndLines ); lcovutil::ignorable_error( $lcovutil::ERROR_INCONSISTENT_DATA, - '"' . $traceInfo->filename() . - "\":$first: function " . $func->name() . + '"' . + $traceInfo->filename() . + "\":$first: function " . + $func->name() . " found on line but no corresponding 'line' coverage data point. Cannot derive function end line." . $suffix); } @@ -7651,8 +7698,10 @@ sub _deriveFunctionEndLines ); lcovutil::ignorable_error( $lcovutil::ERROR_INCONSISTENT_DATA, - '"' . $traceInfo->filename() . - "\":$first: function " . $func->name() . + '"' . + $traceInfo->filename() . + "\":$first: function " . + $func->name() . ": last line in file is not last line of function.$suffix" ); next FUNC; @@ -7664,8 +7713,10 @@ sub _deriveFunctionEndLines lcovutil::explain_once('derive_end_line', " See lcovrc man entry for 'derive_function_end_line'."); lcovutil::ignorable_error($lcovutil::ERROR_INCONSISTENT_DATA, - '"' . $traceInfo->filename() . - "\":$first: function " . $func->name() . + '"' . + $traceInfo->filename() . + "\":$first: function " . + $func->name() . " found on line but no corresponding 'line' coverage data point. Cannot derive function end line." . $suffix); @@ -7673,7 +7724,8 @@ sub _deriveFunctionEndLines next FUNC; # warn about them all } lcovutil::info(1, - '"' . $traceInfo->filename() . + '"' . + $traceInfo->filename() . "\":$currentLine: assign end_line " . $func->name() . "\n"); # warn that we are deriving end lines @@ -7688,11 +7740,14 @@ sub _deriveFunctionEndLines my $suffix = lcovutil::explain_once('derive_end_line', " See lcovrc man entry for 'derive_function_end_line'."); - lcovutil::ignorable_error($lcovutil::ERROR_INCONSISTENT_DATA, + lcovutil::ignorable_error( + $lcovutil::ERROR_INCONSISTENT_DATA, '"' . - $func->filename() . '":' . $func->line() . + $func->filename() . '":' . + $func->line() . ': failed to set end line for function ' . - $func->name() . '.' . $suffix); + $func->name() . '.' . + $suffix); next FUNC; } @@ -7709,13 +7764,17 @@ sub _deriveFunctionEndLines } else { if ($f->end_line() != $func->end_line()) { lcovutil::ignorable_error( - $lcovutil::ERROR_INCONSISTENT_DATA, - '"' . $func->file() . - '":' . $first . ': function \'' . - $func->name() . ' last line is ' . - $func->end_line() . ' but is ' . - $f->end_line() . " in testcase '$tn'" - ); + $lcovutil::ERROR_INCONSISTENT_DATA, + '"' . + $func->file() . '":' . + $first . + ': function \'' . + $func->name() . + ' last line is ' . + $func->end_line() . + ' but is ' . + $f->end_line() . + " in testcase '$tn'"); } } } @@ -7784,7 +7843,8 @@ sub _checkConsistency } else { # can only get here with really inconsistent data...would have lcovutil::ignorable_error($lcovutil::ERROR_INCONSISTENT_DATA, - '"' . $func->filename() . + '"' . + $func->filename() . "\":$first: file linecov does not match function cov data - skipping checks." ); last FUNC; @@ -7815,9 +7875,12 @@ sub _checkConsistency $lcovutil::ERROR_INCONSISTENT_DATA) ) ? ": function marked 'hit'" : ''; - lcovutil::ignorable_error($lcovutil::ERROR_INCONSISTENT_DATA, - '"' . $func->filename() . - "\":$first: function '" . $func->name() . + lcovutil::ignorable_error( + $lcovutil::ERROR_INCONSISTENT_DATA, + '"' . + $func->filename() . + "\":$first: function '" . + $func->name() . "' is not hit but line $currentLine is$suffix." . _consistencySuffix()); if ($lcovutil::fix_inconsistency) { @@ -7839,9 +7902,12 @@ sub _checkConsistency lcovutil::is_ignored($lcovutil::ERROR_INCONSISTENT_DATA)) ? ": function marked 'not hit'" : ''; - lcovutil::ignorable_error($lcovutil::ERROR_INCONSISTENT_DATA, - '"' . $traceInfo->filename() . - "\":$first: function '" . $func->name() . + lcovutil::ignorable_error( + $lcovutil::ERROR_INCONSISTENT_DATA, + '"' . + $traceInfo->filename() . + "\":$first: function '" . + $func->name() . "' is hit but no contained lines are hit$suffix." . _consistencySuffix()); if ($lcovutil::fix_inconsistency) { @@ -7867,7 +7933,8 @@ sub _checkConsistency next if defined($lineHit); lcovutil::info(1, - '"' . $traceInfo->filename() . + '"' . + $traceInfo->filename() . "\":$line: generating DA entry for orphan MC/DC\n" ); my $block = $mcdc->value($line); @@ -7897,7 +7964,8 @@ sub _checkConsistency my $lineHit = $lineData->value($line); unless (defined($lineHit)) { lcovutil::ignorable_error($lcovutil::ERROR_INCONSISTENT_DATA, - '"' . $traceInfo->filename() . + '"' . + $traceInfo->filename() . "\":$line: location has branchcov but no linecov data" . _consistencySuffix()); } @@ -7912,13 +7980,15 @@ sub _checkConsistency } if ($lineHit && !$brHit) { lcovutil::ignorable_error($lcovutil::ERROR_INCONSISTENT_DATA, - '"' . $traceInfo->filename() . + '"' . + $traceInfo->filename() . "\":$line: line is hit but no branches on line have been evaluated." . _consistencySuffix()) if $checkBranchConsistency; } elsif (!$lineHit && $brHit) { lcovutil::ignorable_error($lcovutil::ERROR_INCONSISTENT_DATA, - '"' . $traceInfo->filename() . + '"' . + $traceInfo->filename() . "\":$line: line is not hit but at least one branch on line has been evaluated." . _consistencySuffix()); } @@ -8010,12 +8080,15 @@ sub _filterFile foreach my $tn ($lineData->keylist()) { $modified = 1 - if _eraseFunctions( - $source_file, $reader, - $funcData->value($tn), $lineData->value($tn), - $branchData->value($tn), $mcdcData->value($tn), - $checkData->value($tn), $state, - 0); + if _eraseFunctions($source_file, + $reader, + $funcData->value($tn), + $lineData->value($tn), + $branchData->value($tn), + $mcdcData->value($tn), + $checkData->value($tn), + $state, + 0); } $modified = 1 if _eraseFunctions($source_file, $reader, @@ -8056,8 +8129,10 @@ sub _filterFile if ($srcReader->isOutOfRange($line, 'line')) { $remove = 1; lcovutil::info(1, - "filter FN " . $data->name() . - ' ' . $data->file() . ":$line\n"); + "filter FN " . + $data->name() . ' ' . + $data->file() . + ":$line\n"); ++$range->[-2]; # one location where this applied } elsif (0 != ($reason = $srcReader->isExcluded($line))) { # we already warned about this one @@ -8349,7 +8424,8 @@ sub _filterFile $modified = 1; lcovutil::info(2, - 'filter DA (' . $is_filtered->[0] . ') ' + 'filter DA (' . + $is_filtered->[0] . ') ' . ($line < $srcReader->numLines() ? ("'" . $srcReader->getLine($line) . "'") : @@ -8502,7 +8578,8 @@ sub _generate_end_line_message ": attempting to derive function end lines - see lcovrc man entry for 'derive_function_end_line'." ); } else { - lcovutil::ignorable_error($lcovutil::ERROR_UNSUPPORTED, + lcovutil::ignorable_error( + $lcovutil::ERROR_UNSUPPORTED, $msg . ". See lcovrc man entry for 'derive_function_end_line'." ); @@ -8563,7 +8640,8 @@ sub _processParallelChunk lcovutil::info(1, $d->[1] . ' is ' . - ($modified ? '' : 'NOT ') . "modified\n"); + ($modified ? '' : 'NOT ') . + "modified\n"); if ($modified) { push(@updates, [$d->[1], $data]); } @@ -9071,8 +9149,8 @@ sub _read_info # such that two sections alias to the same data. We need to # insert the branch data into a empty map and then merge that # into both the per-testname and summary data - $branchMap = BranchData->new(); - $mcdcMap = $fileData->testcase_mcdc($testname); + $branchMap = BranchData->new(); + $mcdcMap = $fileData->testcase_mcdc($testname); next; } next if $skipCurrentFile; @@ -9372,7 +9450,7 @@ sub _read_info $fileData->testcase_mcdc($testname) ->append_mcdc(Storable::dclone($current_mcdc), - $filename) + $filename) if (defined($testname)); } $current_mcdc = @@ -9399,7 +9477,8 @@ sub _read_info } if ($lcovutil::br_coverage) { if ($branchBlock) { - $branchMap->insertBlock($branchBlock, $currentBlockLine); + $branchMap->insertBlock($branchBlock, + $currentBlockLine); # reset - in case another testcase follows $branchBlock = undef; } @@ -9413,7 +9492,7 @@ sub _read_info $fileData->mcdc()->close_mcdcBlock($current_mcdc); my $mcdc = $fileData->testcase_mcdc($testname); $mcdc->append_mcdc(Storable::dclone($current_mcdc), - $filename) + $filename) if (defined($testname)); $fileData->mcdc()->union($mcdc); $current_mcdc = undef; @@ -9467,7 +9546,8 @@ sub _read_info "no valid records found in tracefile $tracefile"); } if (defined($changed_testname)) { - lcovutil::ignorable_warning($lcovutil::ERROR_FORMAT, + lcovutil::ignorable_warning( + $lcovutil::ERROR_FORMAT, "invalid characters removed from testname in " . "tracefile $tracefile: '$changed_testname'->'$testname'\n" ); @@ -9874,8 +9954,8 @@ sub merge my $save_filters = lcovutil::disable_cov_filters(); my $total_trace = TraceFile->new(); - if (!(defined($lcovutil::maxParallelism) && defined($lcovutil::maxMemory) - )) { + if (!(defined($lcovutil::maxParallelism) && defined($lcovutil::maxMemory))) + { lcovutil::init_parallel_params(); } if (0 != $lcovutil::maxMemory && @@ -9947,7 +10027,8 @@ sub merge } lcovutil::info("Using " . scalar(@segments) . - ' segment' . (scalar(@segments) > 1 ? 's' : '') . + ' segment' . + (scalar(@segments) > 1 ? 's' : '') . " of $testsPerSegment test" . ($testsPerSegment > 1 ? 's' : '') . "\n"); $lcovutil::profileData{config} = {} @@ -10115,7 +10196,8 @@ sub merge $function_mapping->{$key} = [$data->[0], []] unless exists($function_mapping->{$key}); die("mismatched function name '" . - $data->[0] . "' at $key") + $data->[0] . + "' at $key") unless ($data->[0] eq $function_mapping->{$key}->[0]); push(@{$function_mapping->{$key}->[1]}, diff --git a/scripts/analyzeInfoFiles b/scripts/analyzeInfoFiles index 86ba0750..a78974e1 100755 --- a/scripts/analyzeInfoFiles +++ b/scripts/analyzeInfoFiles @@ -303,8 +303,10 @@ sub checkLineCoverageConsistency } else { # we have some disagreement about whether this is code or not # - is the 'in' and 'out' group the same as it was before? - if (!(hashIsSame(\%currentCodeGroup, \%codeGroup) && - hashIsSame(\%currentNonCodeGroup, \%nonCodeGroup))) { + if (!( + hashIsSame(\%currentCodeGroup, \%codeGroup) && + hashIsSame(\%currentNonCodeGroup, \%nonCodeGroup) + )) { if (defined($main::reportAgreeBlocks) || (%currentCodeGroup && %currentNonCodeGroup) @@ -489,8 +491,9 @@ foreach my $f (@infoFileArray) { # versions don't match - so don't bother to check for matching # line coverage data print("Error: version mismatch for $src between:\n\t" . - $traces->[0]->[1] . - ": " . ($v ? $v : 'undef') . "\n\t" . $f . ": " . + $traces->[0]->[1] . ": " . + ($v ? $v : 'undef') . "\n\t" . + $f . ": " . ($fv ? $fv : 'undef') . "\n"); $status = 1; # version mismatch - so don't bother checking data for this file diff --git a/scripts/annotateutil.pm b/scripts/annotateutil.pm index ca03a4a0..5c73dd01 100644 --- a/scripts/annotateutil.pm +++ b/scripts/annotateutil.pm @@ -226,11 +226,13 @@ sub verify_annotation while (my $line = <$debug_fh>) { chomp($line); die('mismatched annotation: local line ' . - ($lineNo + 1) . " does not exist in annotated data") + ($lineNo + 1) . + " does not exist in annotated data") if $lineNo > $#$lines; my $a = $lines->[$lineNo]->[0]; die("mismatched annotation at $filepath:" . - ($lineNo + 1) . ": '$line' -> '$a'") + ($lineNo + 1) . + ": '$line' -> '$a'") unless $line eq $a; ++$lineNo; } diff --git a/scripts/gitblame.pm b/scripts/gitblame.pm index 0f2f39e5..39a877ed 100644 --- a/scripts/gitblame.pm +++ b/scripts/gitblame.pm @@ -131,7 +131,8 @@ sub annotate_callback -r $pathname) { $context = ':' . $context if $context; die($self->[AnnotateBase::SCRIPT] . - $context . ' expected readable file, found \'' . + $context . + ' expected readable file, found \'' . (defined($pathname) ? $pathname : '') . "'"); } diff --git a/scripts/gitversion.pm b/scripts/gitversion.pm index 60cbb289..695ccf7a 100644 --- a/scripts/gitversion.pm +++ b/scripts/gitversion.pm @@ -136,8 +136,7 @@ sub extract_version $log =~ /^(\S+) /) { $version = $1; if ($self->[P4]) { - if ( - open(GITLOG, '-|', 'git', '-C', + if (open(GITLOG, '-|', 'git', '-C', $dir, 'show', '-s', $version) ) { while (my $l = ) { diff --git a/scripts/p4annotate.pm b/scripts/p4annotate.pm index 1ff69a9c..ca175732 100644 --- a/scripts/p4annotate.pm +++ b/scripts/p4annotate.pm @@ -85,10 +85,9 @@ sub new (!$standalone && scalar(@_)) || $help ) { - print(STDERR ($help ? '' : ("unexpected arg: $script " . join(' ', @_)) - ), - "usage: $exe [--log logfile] [--cache dir] [--verify] filename\n" - ); + print + (STDERR ($help ? '' : ("unexpected arg: $script " . join(' ', @_))), + "usage: $exe [--log logfile] [--cache dir] [--verify] filename\n"); exit(scalar(@_) == 0 && $help ? 0 : 1) if $standalone; return undef; } @@ -100,7 +99,8 @@ sub new if (@notset) { die("$exe requires environment variable" . (1 < scalar(@notset) ? 's' : '') . ' ' . - join(' ', @notset) . " to be set."); + join(' ', @notset) . + " to be set."); } return $class->SUPER::new($exe, $cache_dir, $logfile, $verify); @@ -126,9 +126,9 @@ sub annotate_callback my $null = File::Spec->devnull(); # more portable my @lines; my $status; - if (0 == system( - "p4 files $pathname 2>$null|grep -qv -- '- no such file' >$null") - ) { + if (0 == + system("p4 files $pathname 2>$null|grep -qv -- '- no such file' >$null")) + { # this file is in p4.. my $version; my $have = `p4 have $pathname`; diff --git a/scripts/select.pm b/scripts/select.pm index 79d6fa79..e51aebbb 100644 --- a/scripts/select.pm +++ b/scripts/select.pm @@ -189,8 +189,7 @@ EOF "Will never see '" . join("', '", @intersect2) . "' " . ($#intersect2 ? 'categories' : 'category') . - ' without --diff-file data') - if (@intersect2); + ' without --diff-file data') if (@intersect2); my $self = [\@range, \@owner, @@ -292,7 +291,8 @@ sub finalize my $self = shift; lcovutil::info(-1, "select.pm criteria match counts:\n saw " . - $self->[TOTAL] . ' coverpoint' . + $self->[TOTAL] . + ' coverpoint' . (1 == $self->[TOTAL] ? '' : 's') . "\n"); foreach my $d (['tla', TLA, $self->[TLA]], ['range', AGE, $self->[PLAINTEXT]->[AGE]], diff --git a/scripts/simplify.pm b/scripts/simplify.pm index fecfe60d..500b59e7 100644 --- a/scripts/simplify.pm +++ b/scripts/simplify.pm @@ -148,7 +148,8 @@ sub restore { my ($self, $data) = @_; die("unexpected restore: (" . - join(' ', @$self) . ") <- [" . + join(' ', @$self) . + ") <- [" . join(' ', @$data) . "]\n") unless $#$self == $#$data; for (my $i = 0; $i <= $#$self; ++$i) { diff --git a/scripts/unreach.pm b/scripts/unreach.pm index e4865573..91491d1b 100755 --- a/scripts/unreach.pm +++ b/scripts/unreach.pm @@ -306,7 +306,10 @@ sub finalize my $pt = $count->[0] != 1 ? ($type eq 'branch' ? 'es' : 's') : ''; my $pl = $count->[1] != 1 ? 's' : ''; lcovutil::info("Excluded " . - $count->[0] . " $type$pt from " . $count->[1] . " line$pl.\n"); + $count->[0] . + " $type$pt from " . + $count->[1] . + " line$pl.\n"); } } diff --git a/tests/bin/mkinfo b/tests/bin/mkinfo index df4588cd..a4e17b8f 100755 --- a/tests/bin/mkinfo +++ b/tests/bin/mkinfo @@ -869,9 +869,12 @@ sub print_intro($) $numtests = 1 if ($numtests < 1); - print($BOLD. "Creating coverage files ($numtests " . - plural($numtests, "test", "tests") . ", $numfiles " . - plural($numfiles, "source file", "source files") . ")\n" . $RESET); + print($BOLD. + "Creating coverage files ($numtests " . + plural($numtests, "test", "tests") . + ", $numfiles " . + plural($numfiles, "source file", "source files") . ")\n" . + $RESET); } sub main() diff --git a/tests/genhtml/filter/filter.pl b/tests/genhtml/filter/filter.pl index a45d116c..fbeb9b3b 100755 --- a/tests/genhtml/filter/filter.pl +++ b/tests/genhtml/filter/filter.pl @@ -26,7 +26,8 @@ $lcovutil::source_filter_lookahead = 5; print("checking conditional in expr1.c with lookahead " . - $lcovutil::source_filter_lookahead . " and bitwise " . + $lcovutil::source_filter_lookahead . + " and bitwise " . $lcovutil::source_filter_bitwise_are_conditional . "\n"); die("source_filter_lookahad had no effect") unless $length->containsConditional(1); @@ -34,7 +35,8 @@ $lcovutil::source_filter_lookahead = 10; $lcovutil::source_filter_bitwise_are_conditional = 1; print("checking conditional in expr1.c with lookahead " . - $lcovutil::source_filter_lookahead . " and bitwise " . + $lcovutil::source_filter_lookahead . + " and bitwise " . $lcovutil::source_filter_bitwise_are_conditional . "\n"); die("source_filter_lookahad had no effect") unless $length->containsConditional(1); From e8be9d23bace41243861e4d0542e27524e23c4e5 Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Fri, 10 Jul 2026 21:36:31 +0200 Subject: [PATCH 3/3] Make the CI enforce `make checkstyle` clean code --- .github/workflows/checkstyle.yml | 54 ++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 .github/workflows/checkstyle.yml diff --git a/.github/workflows/checkstyle.yml b/.github/workflows/checkstyle.yml new file mode 100644 index 00000000..3460b31b --- /dev/null +++ b/.github/workflows/checkstyle.yml @@ -0,0 +1,54 @@ +# +# Copyright (c) 2026 Sebastian Pipping +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, see +# . +# +name: Enforce checkstyle-clean code + +on: + pull_request: + push: + schedule: + - cron: '0 14 * * 5' # Every Friday 2pm + workflow_dispatch: + +# Drop permissions to minimum for security +permissions: + contents: read + +jobs: + checkstyle: + name: Enforce checkstyle-clean code + runs-on: ubuntu-24.04 + steps: + - name: Install perltidy + run: |- + set -x + sudo apt-get update + sudo apt-get install --yes -V --no-install-recommends \ + cpanminus + + # NOTE: We install a pinned version to ensure robust CI + sudo cpanm --notest \ + https://github.com/perltidy/perltidy/archive/refs/tags/20260705.01.tar.gz + + - uses: actions/checkout@v7 + + - name: Enforce "make checkstyle" + run: |- + set -x + perltidy --version | grep -o 'v2.*' + + MODE=full make checkstyle