Commit 59d3c6f4 authored by unknown's avatar unknown

Update function 'mtr_options_from_file' after review (and some help)

parent 50941b92
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
# same name. # same name.
use File::Basename; use File::Basename;
use IO::File();
use strict; use strict;
sub collect_test_cases ($); sub collect_test_cases ($);
...@@ -505,8 +506,6 @@ sub collect_one_test_case($$$$$$$) { ...@@ -505,8 +506,6 @@ sub collect_one_test_case($$$$$$$) {
} }
use IO::File;
# List of tags in the .test files that if found should set # List of tags in the .test files that if found should set
# the specified value in "tinfo" # the specified value in "tinfo"
our @tags= our @tags=
...@@ -526,17 +525,16 @@ sub mtr_options_from_test_file($$) { ...@@ -526,17 +525,16 @@ sub mtr_options_from_test_file($$) {
#mtr_verbose("$file"); #mtr_verbose("$file");
my $F= IO::File->new($file) or mtr_error("can't open file \"$file\": $!"); my $F= IO::File->new($file) or mtr_error("can't open file \"$file\": $!");
while ( <$F> ) while ( my $line= <$F> )
{ {
chomp; chomp;
# Skip all lines not starting with "--" next if ( $line !~ /^--/ );
next if ( ! /^--/ );
# Match this line against tag in "tags" array # Match this line against tag in "tags" array
foreach my $tag (@tags) foreach my $tag (@tags)
{ {
if ( $_ =~ /(.*)\Q$tag->[0]\E(.*)$/ ) if ( index($line, $tag->[0]) >= 0 )
{ {
# Tag matched, assign value to "tinfo" # Tag matched, assign value to "tinfo"
$tinfo->{"$tag->[1]"}= $tag->[2]; $tinfo->{"$tag->[1]"}= $tag->[2];
...@@ -544,11 +542,11 @@ sub mtr_options_from_test_file($$) { ...@@ -544,11 +542,11 @@ sub mtr_options_from_test_file($$) {
} }
# If test sources another file, open it as well # If test sources another file, open it as well
if ( /^--([[:space:]]*)source/ ) if ( $line =~ /^\-\-([[:space:]]*)source(.*)$/ )
{ {
my $value= $'; my $value= $2;
$value =~ s/^\s+//; # Remove leading space $value =~ s/^\s+//; # Remove leading space
$value =~ s/\s+$//; # Remove ending space $value =~ s/[[:space:]]+$//; # Remove ending space
my $sourced_file= "$::glob_mysql_test_dir/$value"; my $sourced_file= "$::glob_mysql_test_dir/$value";
mtr_options_from_test_file($tinfo, $sourced_file); mtr_options_from_test_file($tinfo, $sourced_file);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment