From: Mateusz Kijowski Date: Fri, 6 Jan 2017 00:22:36 +0100 Subject: autodetect mysql version in test_sandbox --- bin/test_sandbox | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) --- a/bin/test_sandbox +++ b/bin/test_sandbox @@ -50,7 +50,7 @@ if ($@) { # defaults # # my @versions = ( '5.0.51', '5.0.64', '5.1.23', '5.1.24', '5.1.25', '5.1.26', '6.0.6' ); -my @versions = ( '5.0.91', '5.1.72'); +my @versions = ( ); my $verbose = $DEBUG || $ENV{'VERBOSE'} || 0; my %tests = ( @@ -112,6 +112,18 @@ GetOptions( help() if $get_help; +my $detected_mysql_version; +my @mysql_config_locations = ( $ENV{"HOME"} . '/bin/mysql_config', '/usr/local/bin/mysql_config', '/usr/bin/mysql_config' ); +for my $mysql_config_location (@mysql_config_locations) { + $detected_mysql_version = qx(mysql_config --version) if -x '/usr/bin/mysql_config'; + if ($detected_mysql_version) { + chomp $detected_mysql_version; + print "autodetected version $detected_mysql_version from $mysql_config_location\n"; + push @versions, $detected_mysql_version; + last; + } +} + if ($user_versions) { my @new_versions = grep {$_} split /,/, $user_versions; die "at least one version is required\n" unless @new_versions; @@ -127,7 +139,9 @@ if ($user_versions) { push @versions, $ver; } } +die "at least one version is required\n" unless @versions; for my $ver (@versions) { + print "using version $ver\n"; $ver =~ s/^~/$ENV{'HOME'}/; unless (( -d "/opt/mysql/$ver") or ( -d "$ENV{'HOME'}/opt/mysql/$ver")