Skip to content

Commit

Permalink
Merge pull request #353 from thk123/feature/multi-line-regression
Browse files Browse the repository at this point in the history
Allowed test.desc to pass flags to the grep command
  • Loading branch information
forejtv authored Dec 22, 2016
2 parents 1029635 + 4437682 commit d90a14a
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions regression/test.pl
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,19 @@ ($)

sub test($$$$$) {
my ($name, $test, $t_level, $cmd, $ign) = @_;
my ($level, $input, $options, @results) = load("$test");
my ($level, $input, $options, $grep_options, @results) = load("$test");

# If the 4th line starts with a '-' we use that line as options to pass to
# grep when matching all lines in this test
if($grep_options =~ /^-/) {
print "\nActivating perl flags: $grep_options\n";
}
else {
# No grep options so stick this back into the results array
unshift @results, $grep_options;
$grep_options = "";
}

$options =~ s/$ign//g if(defined($ign));

my $output = $input;
Expand Down Expand Up @@ -107,7 +119,7 @@ ($$$$$)
my $r;
$result =~ s/\\/\\\\/g;
$result =~ s/([^\\])\$/$1\\r\\\\?\$/;
system("bash", "-c", "grep \$'$result' \"$name/$output\" >/dev/null");
system("bash", "-c", "grep $grep_options \$'$result' \"$name/$output\" >/dev/null");
$r = ($included ? $? != 0 : $? == 0);
if($r) {
print LOG "$result [FAILED]\n";
Expand Down Expand Up @@ -173,6 +185,7 @@ ($$$$)
<level>
<main source>
<options>
<grep_options>
<required patterns>
--
<disallowed patterns>
Expand All @@ -181,8 +194,12 @@ ($$$$)
where
<level> is one of CORE, THOROUGH, FUTURE or KNOWNBUG
<main source> is a file with extension .c/.i/.cpp/.ii/.xml/.class/.jar
<main source> is a file with extension .c/.i/.gb/.cpp/.ii/.xml/.class/.jar
<options> additional options to be passed to CMD
<grep_options> additional flags to be passed to grep when checking required
patterns (this is optional, if the line stats with a `-'
it will be used as grep options. Otherwise, it will be
considered part of the required patterns)
<required patterns> one or more lines of regualar expressions that must occur in the output
<disallowed patterns> one or more lines of expressions that must not occur in output
<comment text> free form text
Expand Down

0 comments on commit d90a14a

Please sign in to comment.