Skip to content

Commit 7cdc141

Browse files
author
thk123
committed
If not multi line, use old grep system
To ensure existing tests continue to behave consistently, we continue to use the external grep if the multi-line flag is not present.
1 parent eba97a0 commit 7cdc141

File tree

1 file changed

+9
-25
lines changed

1 file changed

+9
-25
lines changed

regression/test.pl

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -116,42 +116,26 @@ ($$$$$)
116116
} else {
117117
my $r;
118118

119-
my $dir = getcwd();
120-
my $abs_path = "$dir/$name/$output";
121-
open(my $fh => $abs_path) || die "Cannot open '$name/$output': $!";
122-
123119
# Multi line therefore we run each check across the whole output
124120
if($grep_options eq "activate-multi-line-match") {
121+
my $dir = getcwd();
122+
my $abs_path = "$dir/$name/$output";
123+
open(my $fh => $abs_path) || die "Cannot open '$name/$output': $!";
124+
125125
local $/ = undef;
126126
binmode $fh;
127127
my $whole_file = <$fh>;
128128
my $is_match = $whole_file =~ /$result/;
129129
$r = ($included ? !$is_match : $is_match);
130+
close($fh);
130131
}
131132
else
132133
{
133-
my $found_line = 0;
134-
while(my $line = <$fh>) {
135-
if($line =~ /$result/) {
136-
# We've found the line, therefore if it is included we set
137-
# the result to 0 (OK) If it is excluded, we set the result
138-
# to 1 (FAILED)
139-
$r = !$included;
140-
$found_line = 1;
141-
last;
142-
}
143-
}
144-
145-
if($found_line == 0) {
146-
# None of the lines matched, therefore the result is set to
147-
# 0 (OK) if and only if the line was not meant to be included
148-
$r = $included;
149-
}
150-
134+
$result =~ s/\\/\\\\/g;
135+
$result =~ s/([^\\])\$/$1\\r\\\\?\$/;
136+
system("bash", "-c", "grep \$'$result' '$name/$output' >/dev/null");
137+
$r = ($included ? $? != 0 : $? == 0);
151138
}
152-
close($fh);
153-
154-
155139
if($r) {
156140
print LOG "$result [FAILED]\n";
157141
$failed = 1;

0 commit comments

Comments
 (0)