66
66
return @data ;
67
67
}
68
68
69
- sub test ($$$$$$$) {
70
- my ($name , $test , $t_level , $cmd , $ign , $dry_run , $defines ) = @_ ;
71
- my ($level , $input , $options , $grep_options , @results ) = load(" $test " );
69
+ sub test ($$$$$$$$$ ) {
70
+ my ($name , $test , $t_level , $cmd , $ign , $dry_run , $defines , $include_tags , $exclude_tags ) = @_ ;
71
+ my ($level_and_tags , $input , $options , $grep_options , @results ) = load(" $test " );
72
72
my @keys = keys %{$defines };
73
73
foreach my $key (@keys ) {
74
74
my $value = $defines -> {$key };
@@ -82,6 +82,28 @@ ($$$$$$$)
82
82
}
83
83
}
84
84
85
+ my @tags = split (/ \s / , $level_and_tags );
86
+ my $level = shift @tags ;
87
+ my %tags_set = map { $_ => 1 } @tags ;
88
+
89
+ # If the user has passes -I (include-tag) or -X (exclude-tag) options, then
90
+ # run the test only if it matches no exclude-tags and either include-tags is
91
+ # not given (implying run all tests) or it matches at least one include-tag.
92
+
93
+ my $include_tags_length = @$include_tags ;
94
+ my $passes_tag_tests = ($include_tags_length == 0);
95
+ foreach my $include_tag (@$include_tags ) {
96
+ if (exists ($tags_set {$include_tag })) {
97
+ $passes_tag_tests = 1;
98
+ }
99
+ }
100
+
101
+ foreach my $exclude_tag (@$exclude_tags ) {
102
+ if (exists ($tags_set {$exclude_tag })) {
103
+ $passes_tag_tests = 0;
104
+ }
105
+ }
106
+
85
107
# If the 4th line is activate-multi-line-match we enable multi-line checks
86
108
if ($grep_options ne " activate-multi-line-match" ) {
87
109
# No such flag, so we add it back in
@@ -124,7 +146,7 @@ ($$$$$$$)
124
146
}
125
147
126
148
my $failed = 2;
127
- if ($level & $t_level ) {
149
+ if (( $level & $t_level ) && $passes_tag_tests ) {
128
150
129
151
if ($dry_run ) {
130
152
return 0;
@@ -244,12 +266,14 @@ ($$$$)
244
266
-K known: run tests associated with known bugs
245
267
-D <key=value> Define - replace \$ key string with "value" string in
246
268
test descriptors
269
+ -I <tag> run only tests that have the given secondary tag. Can be repeated.
270
+ -X <tag> exclude tests that have the given secondary tag. Can be repeated.
247
271
248
272
249
273
test.pl expects a test.desc file in each subdirectory. The file test.desc
250
274
follows the format specified below. Any line starting with // will be ignored.
251
275
252
- <level>
276
+ <level> [<tag1> [<tag2>...]]
253
277
<main source>
254
278
<options>
255
279
<activate-multi-line-match>
@@ -261,6 +285,7 @@ ($$$$)
261
285
262
286
where
263
287
<level> is one of CORE, THOROUGH, FUTURE or KNOWNBUG
288
+ <tag1>, <tag2> ... <tagn> are zero or more space-separated secondary tags, for use with the -I and -X parameters
264
289
<main source> is a file with extension .c/.i/.gb/.cpp/.ii/.xml/.class/.jar
265
290
<options> additional options to be passed to CMD
266
291
<activate-multi-line-match> The fourth line can optionally be activate-multi-line-match, if this is the
@@ -278,9 +303,9 @@ ($$$$)
278
303
use Getopt::Long qw( :config pass_through bundling) ;
279
304
$main::VERSION = 0.1;
280
305
$Getopt::Std::STANDARD_HELP_VERSION = 1;
281
- our ($opt_c , $opt_i , $opt_j , $opt_n , $opt_p , $opt_h , $opt_C , $opt_T , $opt_F , $opt_K , %defines ); # the variables for getopt
306
+ our ($opt_c , $opt_i , $opt_j , $opt_n , $opt_p , $opt_h , $opt_C , $opt_T , $opt_F , $opt_K , %defines , @include_tags , @exclude_tags ); # the variables for getopt
282
307
$opt_j = 0;
283
- GetOptions(" D=s" , \%defines );
308
+ GetOptions(" D=s" => \%defines , " X=s " => \ @exclude_tags , " I=s " => \ @include_tags );
284
309
getopts(' c:i:j:nphCTFK' ) or &main::HELP_MESSAGE(\*STDOUT , " " , $main::VERSION , " " );
285
310
$opt_c or &main::HELP_MESSAGE(\*STDOUT , " " , $main::VERSION , " " );
286
311
(!$opt_j || $has_thread_pool ) or &main::HELP_MESSAGE(\*STDOUT , " " , $main::VERSION , " " );
319
344
defined ($pool ) or print " Running $files [$_ ]" ;
320
345
my $start_time = time ();
321
346
$failed_skipped = test(
322
- $test , $files [$_ ], $t_level , $opt_c , $opt_i , $dry_run , \%defines );
347
+ $test , $files [$_ ], $t_level , $opt_c , $opt_i , $dry_run , \%defines , \ @include_tags , \ @exclude_tags );
323
348
my $runtime = time () - $start_time ;
324
349
325
350
lock($skips );
0 commit comments