Skip to content

Commit

Permalink
Fix use of require in mysql-test-run.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
knielsen committed Sep 10, 2016
1 parent 6c74ef8 commit 577f3c1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
4 changes: 1 addition & 3 deletions mysql-test/lib/mtr_cases.pm
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ use My::Test;
use My::Find;
use My::Suite;

require "mtr_misc.pl";

# locate plugin suites, depending on whether it's a build tree or installed
my @plugin_suitedirs;
my $plugin_suitedir_regex;
Expand Down Expand Up @@ -1122,7 +1120,7 @@ sub get_tags_from_file($$) {
$file_to_tags{$file}= $tags;
$file_to_master_opts{$file}= $master_opts;
$file_to_slave_opts{$file}= $slave_opts;
$file_combinations{$file}= [ uniq(@combinations) ];
$file_combinations{$file}= [ ::uniq(@combinations) ];
$file_in_overlay{$file} = 1 if $in_overlay;
return @{$tags};
}
Expand Down
3 changes: 1 addition & 2 deletions mysql-test/lib/mtr_report.pm
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ use mtr_match;
use My::Platform;
use POSIX qw[ _exit ];
use IO::Handle qw[ flush ];
require "mtr_io.pl";
use mtr_results;

my $tot_real_time= 0;
Expand Down Expand Up @@ -92,7 +91,7 @@ sub mtr_report_test_passed ($) {
my $timer_str= "";
if ( $timer and -f "$::opt_vardir/log/timer" )
{
$timer_str= mtr_fromfile("$::opt_vardir/log/timer");
$timer_str= ::mtr_fromfile("$::opt_vardir/log/timer");
$tinfo->{timer}= $timer_str;
resfile_test_info('duration', $timer_str) if $::opt_resfile;
}
Expand Down
10 changes: 5 additions & 5 deletions mysql-test/mysql-test-run.pl
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ BEGIN
use IO::Socket::INET;
use IO::Select;

require "lib/mtr_process.pl";
require "lib/mtr_io.pl";
require "lib/mtr_gcov.pl";
require "lib/mtr_gprof.pl";
require "lib/mtr_misc.pl";
require "mtr_process.pl";
require "mtr_io.pl";
require "mtr_gcov.pl";
require "mtr_gprof.pl";
require "mtr_misc.pl";

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

0 comments on commit 577f3c1

Please sign in to comment.