Skip to content

Commit d185f1d

Browse files
committed
Fix use of require in mysql-test-run.
The motivation for this is that Perl is moving towards not having current directory ./ in @inc by default. This is causing mysql-test-run.pl to fail in latest Debian Unstable: https://lists.debian.org/debian-devel-announce/2016/08/msg00013.html However, we have `use "lib"`, there is no need for current directory in @inc, except for a gross hack. In mtr_cases.pm, there is a `require "mtr_misc.pl"`, which hides mtr_misc.pl away in mtr_cases namespace. And things only work because mysql-test-run.pl loads it with a different name, `require "lib/mtr_misc.pl"`! (Perl will `require` only once for each unique filename). Fix this by only using `require` in main program, and referencing functions with :: scope from other namespaces. For multi-use in different namespaces, proper `use` modules should be used. Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
1 parent d53b541 commit d185f1d

File tree

3 files changed

+7
-10
lines changed

3 files changed

+7
-10
lines changed

mysql-test/lib/mtr_cases.pm

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ use My::Test;
6060
use My::Find;
6161
use My::Suite;
6262

63-
require "mtr_misc.pl";
64-
6563
# locate plugin suites, depending on whether it's a build tree or installed
6664
my @plugin_suitedirs;
6765
my $plugin_suitedir_regex;
@@ -1098,7 +1096,7 @@ sub get_tags_from_file($$) {
10981096
$file_to_tags{$file}= $tags;
10991097
$file_to_master_opts{$file}= $master_opts;
11001098
$file_to_slave_opts{$file}= $slave_opts;
1101-
$file_combinations{$file}= [ uniq(@combinations) ];
1099+
$file_combinations{$file}= [ ::uniq(@combinations) ];
11021100
$file_in_overlay{$file} = 1 if $in_overlay;
11031101
return @{$tags};
11041102
}

mysql-test/lib/mtr_report.pm

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ use mtr_match;
3434
use My::Platform;
3535
use POSIX qw[ _exit ];
3636
use IO::Handle qw[ flush ];
37-
require "mtr_io.pl";
3837
use mtr_results;
3938

4039
my $tot_real_time= 0;
@@ -92,7 +91,7 @@ sub mtr_report_test_passed ($) {
9291
my $timer_str= "";
9392
if ( $timer and -f "$::opt_vardir/log/timer" )
9493
{
95-
$timer_str= mtr_fromfile("$::opt_vardir/log/timer");
94+
$timer_str= ::mtr_fromfile("$::opt_vardir/log/timer");
9695
$tinfo->{timer}= $timer_str;
9796
resfile_test_info('duration', $timer_str) if $::opt_resfile;
9897
}

mysql-test/mysql-test-run.pl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,11 @@ BEGIN
102102
use IO::Socket::INET;
103103
use IO::Select;
104104

105-
require "lib/mtr_process.pl";
106-
require "lib/mtr_io.pl";
107-
require "lib/mtr_gcov.pl";
108-
require "lib/mtr_gprof.pl";
109-
require "lib/mtr_misc.pl";
105+
require "mtr_process.pl";
106+
require "mtr_io.pl";
107+
require "mtr_gcov.pl";
108+
require "mtr_gprof.pl";
109+
require "mtr_misc.pl";
110110

111111
$SIG{INT}= sub { mtr_error("Got ^C signal"); };
112112
$SIG{HUP}= sub { mtr_error("Hangup detected on controlling terminal"); };

0 commit comments

Comments
 (0)