Skip to content

Allowed test.desc to pass flags to the grep command #353

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 22, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test.pl does have --help output explaining the format it consumes - could you please amend that as well to include information about your added feature?

$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