diff --git a/mysql-test/include/search_pattern_in_file.inc b/mysql-test/include/search_pattern_in_file.inc index d26495ca3ed..c229ddab55a 100644 --- a/mysql-test/include/search_pattern_in_file.inc +++ b/mysql-test/include/search_pattern_in_file.inc @@ -48,15 +48,12 @@ # Created: 2011-11-11 mleich # ---error 0,1 perl; use strict; die "SEARCH_FILE not set" unless $ENV{SEARCH_FILE}; my @search_files= glob($ENV{SEARCH_FILE}); my $search_pattern= $ENV{SEARCH_PATTERN} or die "SEARCH_PATTERN not set"; my $search_range= $ENV{SEARCH_RANGE}; - my $silent= $ENV{SEARCH_SILENT}; - my $search_result= 0; my $content; foreach my $search_file (@search_files) { open(FILE, '<', $search_file) || die("Can't open file $search_file: $!"); @@ -81,39 +78,18 @@ perl; $content.= $file_content; } my @matches= ($content =~ /$search_pattern/gs); - my $res; - if (@matches) - { - $res="FOUND " . scalar(@matches); - $search_result= 1; - } - else - { - $res= "NOT FOUND"; - } + my $res=@matches ? "FOUND " . scalar(@matches) : "NOT FOUND"; + $ENV{SEARCH_FILE} =~ s{^.*?([^/\\]+)$}{$1}; - if (!$silent || $search_result) - { - if ($ENV{SEARCH_OUTPUT} eq "matches") - { - foreach (@matches) - { - print $_ . "\n"; - } - } - else - { - print "$res /$search_pattern/ in $ENV{SEARCH_FILE}\n"; + if ($ENV{SEARCH_OUTPUT} eq "matches") { + foreach (@matches) { + print $_ . "\n"; } } - die "$ENV{SEARCH_ABORT}\n" - if $ENV{SEARCH_ABORT} && $res =~ /^$ENV{SEARCH_ABORT}/; - exit($search_result != 1); + elsif ($ENV{SEARCH_ABORT} and $res =~ /^$ENV{SEARCH_ABORT}/) { + die "$res /$search_pattern/ in $ENV{SEARCH_FILE}\n"; + } else { + print "$res /$search_pattern/ in $ENV{SEARCH_FILE}\n"; + } EOF - -let $SEARCH_RESULT= 1; # Found pattern -if ($errno) -{ - let $SEARCH_RESULT= 0; # Did not find pattern -} diff --git a/mysql-test/include/wait_for_pattern_in_file.inc b/mysql-test/include/wait_for_pattern_in_file.inc index 52226acd2da..a551761012f 100644 --- a/mysql-test/include/wait_for_pattern_in_file.inc +++ b/mysql-test/include/wait_for_pattern_in_file.inc @@ -25,23 +25,23 @@ if (!$_timeout) } let $_timeout_counter=`SELECT $_timeout * 10`; -let SEARCH_SILENT=1; - +let SEARCH_ABORT=NOT FOUND; let $_continue= 1; +disable_abort_on_error; while ($_continue) { source include/search_pattern_in_file.inc; - if ($SEARCH_RESULT) + if (!$errno) { # Found match let $_continue= 0; } - if (!$SEARCH_RESULT) + if ($errno) { dec $_timeout_counter; if ($_timeout_counter == 1) { - let $SEARCH_SILENT= 0; + enable_abort_on_error; } if (!$_timeout_counter) { @@ -49,8 +49,7 @@ while ($_continue) } } } - -let SEARCH_SILENT=0; +enable_abort_on_error; --source include/end_include_file.inc --let $keep_include_silent=$wait_save_keep_include_silent