Skip to content

Commit d90a14a

Browse files
authored
Merge pull request #353 from thk123/feature/multi-line-regression
Allowed test.desc to pass flags to the grep command
2 parents 1029635 + 4437682 commit d90a14a

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

regression/test.pl

+20-3
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,19 @@ ($)
5959

6060
sub test($$$$$) {
6161
my ($name, $test, $t_level, $cmd, $ign) = @_;
62-
my ($level, $input, $options, @results) = load("$test");
62+
my ($level, $input, $options, $grep_options, @results) = load("$test");
63+
64+
# If the 4th line starts with a '-' we use that line as options to pass to
65+
# grep when matching all lines in this test
66+
if($grep_options =~ /^-/) {
67+
print "\nActivating perl flags: $grep_options\n";
68+
}
69+
else {
70+
# No grep options so stick this back into the results array
71+
unshift @results, $grep_options;
72+
$grep_options = "";
73+
}
74+
6375
$options =~ s/$ign//g if(defined($ign));
6476

6577
my $output = $input;
@@ -107,7 +119,7 @@ ($$$$$)
107119
my $r;
108120
$result =~ s/\\/\\\\/g;
109121
$result =~ s/([^\\])\$/$1\\r\\\\?\$/;
110-
system("bash", "-c", "grep \$'$result' \"$name/$output\" >/dev/null");
122+
system("bash", "-c", "grep $grep_options \$'$result' \"$name/$output\" >/dev/null");
111123
$r = ($included ? $? != 0 : $? == 0);
112124
if($r) {
113125
print LOG "$result [FAILED]\n";
@@ -173,6 +185,7 @@ ($$$$)
173185
<level>
174186
<main source>
175187
<options>
188+
<grep_options>
176189
<required patterns>
177190
--
178191
<disallowed patterns>
@@ -181,8 +194,12 @@ ($$$$)
181194
182195
where
183196
<level> is one of CORE, THOROUGH, FUTURE or KNOWNBUG
184-
<main source> is a file with extension .c/.i/.cpp/.ii/.xml/.class/.jar
197+
<main source> is a file with extension .c/.i/.gb/.cpp/.ii/.xml/.class/.jar
185198
<options> additional options to be passed to CMD
199+
<grep_options> additional flags to be passed to grep when checking required
200+
patterns (this is optional, if the line stats with a `-'
201+
it will be used as grep options. Otherwise, it will be
202+
considered part of the required patterns)
186203
<required patterns> one or more lines of regualar expressions that must occur in the output
187204
<disallowed patterns> one or more lines of expressions that must not occur in output
188205
<comment text> free form text

0 commit comments

Comments
 (0)