Skip to content

Commit d9b3c6b

Browse files
committed
Enable comma-separated callback parameters as well ass gcov-tool spec.
Can simplify user's Jenkins scripts. Signed-off-by: Henry Cox <[email protected]>
1 parent 417448c commit d9b3c6b

File tree

5 files changed

+61
-18
lines changed

5 files changed

+61
-18
lines changed

bin/geninfo

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,8 @@ if (0 == scalar(@gcov_tool)) {
323323
# not specified - use gcov by default - expected to be in user's path
324324
push(@gcov_tool, 'gcov');
325325
} else {
326+
@gcov_tool =
327+
split($lcovutil::split_char, join($lcovutil::split_char, @gcov_tool));
326328
my $tool = $gcov_tool[0];
327329
my (undef, $dir, $file) = splitpath($tool);
328330

lib/lcovutil.pm

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,8 @@ sub do_mangle_check
864864

865865
sub configure_callback
866866
{
867-
my $script = $_[0];
867+
my @args = split($lcovutil::split_char, join($lcovutil::split_char, @_));
868+
my $script = $args[0];
868869
my $rtn;
869870
if ($script =~ /\.pm$/) {
870871
my $dir = File::Basename::dirname($script);
@@ -876,7 +877,7 @@ sub configure_callback
876877
require $package;
877878
#$package->import(qw(new));
878879
# the first value in @_ is the script name
879-
$rtn = $class->new(@_);
880+
$rtn = $class->new(@args);
880881
};
881882
if ($@ ||
882883
!defined($rtn)) {
@@ -887,7 +888,7 @@ sub configure_callback
887888
shift(@INC);
888889
} else {
889890
# not module
890-
$rtn = ScriptCaller->new(@_);
891+
$rtn = ScriptCaller->new(@args);
891892
}
892893
return $rtn;
893894
}

man/genhtml.1

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -532,25 +532,20 @@ if the source file is not found by the callback.
532532
.RE
533533

534534
.IP 2. 3
535-
If an option is specified only once, the argument specifies the full command
536-
line that
537-
.B genhtml
538-
passes to a shell interpreter to run the script.
535+
The option may be specified as a
536+
.I split_char
537+
separated string (see
538+
.B man lcovrc(5)
539+
) - which is divied into words. The resulting command line is passed
540+
to a shell interpreter to run the script.
539541
This includes the script path followed by optional additional parameters
540542
separated by spaces. Care must be taken to provide proper quoting if script
541543
path or any parameter contains spaces or shell special characters.
542-
.br
543-
If your callback command contains spaces which are not option separator, then
544-
the callback and arguments must be specified as described in
545-
.B 3.,
546-
below.
547544
.PP
548545

549546
.IP 3. 3
550-
If an option is specified multiple times, the first invocation specifies the
551-
script path and any further invocation specifies one additional parameter.
552-
In this case, genhtml takes care of quoting of spaces contained in
553-
script location and additional parameters.
547+
If an option is specified multiple times, all of the parameters are
548+
split as described above, then concatentated to form the command line.
554549
.br
555550
.PP
556551

@@ -576,7 +571,13 @@ results in the same callback as
576571
genhtml --annotate-script "/bin/script.sh full" ...
577572
.br
578573

579-
Note that the former is preferred.
574+
or
575+
576+
.br
577+
genhtml --annotate-script /bin/script.sh,full ...
578+
.br
579+
580+
Note that the first form is preferred.
580581

581582
.RE
582583

@@ -599,10 +600,17 @@ genhtml --annotate-script
599600
.br
600601
--annotate-script "full" ...
601602
.br
603+
604+
or
605+
.br
606+
genhtml --annotate-script
607+
.I /bin/myMoodule.pm,full
608+
.br
609+
602610
.br
603611
.RE
604612

605-
results in
613+
result in
606614
.B genhtml
607615
executing
608616
.br

man/geninfo.1

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,11 +584,20 @@ In that case, your callback will be executed as:
584584
Note that the second and subsequent arguments are quoted when passed to
585585
the shell, in order to handle parameters which contain spaces.
586586

587+
The
588+
.B \-\-gcov\-tool
589+
argument may be a
590+
.I split_char
591+
separated string - see
592+
.B man(4) lcovrc.
593+
587594
A common use for this option is to enable LLVM:
588595
.br
589596

590597
.RS
591598
.BR "geninfo \-\-gcov-tool " "llvm-cov " "\-\-gcov-tool " "gcov ..."
599+
.br
600+
.BR "geninfo \-\-gcov-tool " "llvm-cov,gcov ..."
592601
.RE
593602
.br
594603

tests/gendiffcov/errs/msgtest.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ else
110110
fi
111111
GET_VERSION=$SCRIPTS_DIR/getp4version
112112
SELECT_SCRIPT=$SCRIPTS_DIR/select.pm
113+
CRITERIA_SCRIPT=$SCRIPTS_DIR/criteria.pm
114+
ANNOTATE_SCRIPT=$SCRIPTS_DIR/p4annotate.pm
113115

114116

115117
# filter out the compiler-generated _GLOBAL__sub_... symbol
@@ -313,6 +315,27 @@ if [ 0 != $? ] ; then
313315
fi
314316
fi
315317
318+
for arg in "--select-script $SELECT_SCRIPT" \
319+
"--criteria-script $CRITERIA_SCRIPT" \
320+
"--annotate-script $ANNOTATE_SCRIPT" \
321+
; do
322+
echo genhtml $DIFCOV_OPTS initial.info -o scriptErr ${arg},-x
323+
$COVER $GENHTML_TOOL $DIFFCOV_OPTS initial.info -o scriptErr ${arg},-x 2>&1 | tee script_err.log
324+
if [ 0 == ${PIPESTATUS[0]} ] ; then
325+
echo "ERROR: genhtml scriptErr passed by accident"
326+
if [ 0 == $KEEP_GOING ] ; then
327+
exit 1
328+
fi
329+
fi
330+
grep "unable to create callback from" script_err.log
331+
if [ 0 != $? ] ; then
332+
echo "ERROR: missing script message"
333+
if [ 0 == $KEEP_GOING ] ; then
334+
exit 1
335+
fi
336+
fi
337+
done
338+
316339
echo genhtml $DIFCOV_OPTS initial.info -o select --select-script ./select.sh --rc compute_file_version=1
317340
$COVER $GENHTML_TOOL $DIFFCOV_OPTS initial.info -o select --select-script ./select.sh --rc compute_file_version=1 2>&1 | tee select_scr.log
318341
if [ 0 != ${PIPESTATUS[0]} ] ; then

0 commit comments

Comments
 (0)