4242# --owner: is a regular expression. A coverpoint is retained if its
4343# "full name" field matches the regexp.
4444#
45+ # --separator: is a character/regexp used to split 'list' arguments
46+ # (such as '--tla ..', '--sha ...', etc.
47+ # This may be useful to pass a delimited list to select.pm arguments
48+ # in a comma-separated list of genhaml arguments - for example:
49+ # genhtml ... --select-script select,pm,--sep,;,--tla,LBC;UNC
50+ #
4551# When multiple selection criteria are applied (e.g., both age and owner),
4652# then The coverpoint is retained if any of criteria match.
4753#
@@ -67,6 +73,17 @@ use constant {
6773 SHA => 3,
6874};
6975
76+ sub intersect
77+ {
78+ my $l = shift ;
79+ my $m = shift ;
80+
81+ my %contains ;
82+ @contains {@$l } = (1) x @$l ;
83+
84+ return grep { $contains {$_ } } @$m ;
85+ }
86+
7087sub new
7188{
7289 my $class = shift ;
@@ -77,12 +94,14 @@ sub new
7794 my $exe = basename($script ? $script : $0 );
7895 my $standalone = $script eq $0 ;
7996 my $help ;
97+ my $delim = ' ,' ;
8098 if (!GetOptionsFromArray(\@_ ,
81- (" range:s" => \@range ,
82- ' tla:s' => \@tla ,
83- ' owner:s' => \@owner ,
84- ' sha|cl:s' => \@sha ,
85- ' help' => \$help )) ||
99+ (" range:s" => \@range ,
100+ ' tla:s' => \@tla ,
101+ ' owner:s' => \@owner ,
102+ ' sha|cl:s' => \@sha ,
103+ ' separator:s' => \$delim ,
104+ ' help' => \$help )) ||
86105 $help ||
87106 (!$standalone && 0 != scalar (@_ )) ||
88107 0 == scalar (@args ) # expect at least one selection criteria
@@ -94,6 +113,7 @@ usage: $exe
94113 [--tla tla]*
95114 [--sha sha]*
96115 [--cl changelist]*
116+ [--separagor char]
97117
98118Line is selected (return true) if any of the criteria match
99119EOF
109129 join (' ' , @args ) . ' "' );
110130 }
111131 }
112- @sha = split (' ,' , join (' ,' , @sha ));
113- @tla = split (' ,' , join (' ,' , @tla ));
132+ @sha = split ($delim , join ($delim , @sha ));
133+ @tla = split ($delim , join ($delim , @tla ));
134+ @range = split ($delim , join ($delim , @range ));
114135 foreach my $tla (@tla ) {
115136 die (" invalid tla '$tla ' in \" $exe " . join (' ' , @args ) . ' "' )
116137 unless grep (/ $tla / , keys (%lcovutil::tlaColor ));
126147 unless $min <= $max ;
127148 $range = [$min , $max ];
128149 }
150+ # some error checking:
151+ # - can't look for date range, CL/SHA, or owner if there are no
152+ # annotations (so verify that there is an annotation script).
153+ # - without baseline data, there will be no coverage data other
154+ # than GNC, UNC.
155+ # - without 'diff' data, there will be no coverage data in
156+ # GNC, UNC, DUB, or DCB categories
157+ if (!@SourceFile::annotateScript && (@range || @owner || @sha )) {
158+ lcovutil::ignorable_error($lcovutil::ERROR_USAGE ,
159+ " cannot select date/owner/SHA without '--annotate-script'" );
160+ }
161+ my @intersect = intersect([' UBC' , ' GBC' , ' LBC' , ' CBC' , ' ECB' , ' EUB' ,
162+ ' GIC' , ' UIC' , ' DCB' , ' DUB'
163+ ],
164+ \@tla ) unless @main::base_filenames ;
165+ lcovutil::ignorable_error($lcovutil::ERROR_USAGE ,
166+ " Will never see TLA other than 'UNC', 'GNC' without 'baseline' coverage data"
167+ ) if (@intersect );
168+
169+ my @intersect2 = intersect([' GNC' , ' UNC' , ' DCB' , ' DUB' ], \@tla )
170+ unless $main::diff_filename ;
171+ lcovutil::ignorable_error($lcovutil::ERROR_USAGE ,
172+ " Will never see '" .
173+ join (" ', '" , @intersect2 ) . " ' " .
174+ ($#intersect2 ? ' categories' : ' category' ) .
175+ ' without --diff-file data' )
176+ if (@intersect2 );
177+
129178 my $self = [\@range , \@tla , \@owner , \@sha ];
130179 return bless $self , $class ;
131180}
0 commit comments