Problem with Perl DBD::Mysql module tests
am 23.07.2007 03:09:48 von Paul Wayper
Hi there!
I recently had to install the Perl DBD::Mysql module from CPAN (using
perl -MCPAN -e shell). As a good administrator I have changed the root
MySQL password, and this causes the make tests to fail. With a little
digging around in t/lib.pm I found that if I set the environment
variable DBI_PASS and run the tests it would import it. However, this
did not work and the $::test_password variable remained blank. Further
digging around found that, in the import of t/mysql.mtest it overwrites
all the variables that have been previously set. I made a couple of
changes to the mtest file to preserve any previously set variables and
include the diff here:
--- ../DBD-mysql-4.005-MXzdoi/t/mysql.mtest 2007-07-20
17:31:37.000000000 +1000
+++ t/mysql.mtest 2007-07-23 10:53:54.000000000 +1000
@@ -12,13 +12,13 @@
'testpassword' => '',
'testsocket' => ''
};
-$::test_host = $opt->{'testhost'};
-$::test_port = $opt->{'testport'};
-$::test_user = $opt->{'testuser'};
-$::test_socket = $opt->{'testsocket'};
-$::test_password = $opt->{'testpassword'};
-$::test_db = $opt->{'testdb'};
-$::test_dsn = "DBI:mysql:$::test_db";
+$::test_host = $::test_host || $opt->{'testhost'};
+$::test_port = $::test_port || $opt->{'testport'};
+$::test_user = $::test_user || $opt->{'testuser'};
+$::test_socket = $::test_socket || $opt->{'testsocket'};
+$::test_password = $::test_password || $opt->{'testpassword'};
+$::test_db = $::test_db || $opt->{'testdb'};
+$::test_dsn = $::test_dsn || "DBI:mysql:$::test_db";
$::test_dsn .= ";mysql_socket=$::test_socket" if $::test_socket;
$::test_dsn .= ":$::test_host" if $::test_host;
$::test_dsn .= ":$::test_port" if $::test_port;
While it may make sense for standalone builds with non-default security
to pass the required environment by altering the mysql.mtest file, for
CPAN builds it makes more sense to allow the user to set the DBI_xxxx
environment variables.
Please let me know if there is a more appropriate place to submit this
patch, or any feedback on it.
Hope this helps,
Paul
--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=gcdmp-msql-mysql-modules@m .gmane.org
Re: Problem with Perl DBD::Mysql module tests
am 20.08.2007 12:39:52 von Patrick Galbraith
Paul,
Thanks much! I will test this out, and can include this in the next
release if it helps the situation you describe, which is something I've
wanted to deal with for some time.
regards,
Patrick
Paul Wayper wrote:
>Hi there!
>
>I recently had to install the Perl DBD::Mysql module from CPAN (using
>perl -MCPAN -e shell). As a good administrator I have changed the root
>MySQL password, and this causes the make tests to fail. With a little
>digging around in t/lib.pm I found that if I set the environment
>variable DBI_PASS and run the tests it would import it. However, this
>did not work and the $::test_password variable remained blank. Further
>digging around found that, in the import of t/mysql.mtest it overwrites
>all the variables that have been previously set. I made a couple of
>changes to the mtest file to preserve any previously set variables and
>include the diff here:
>
>--- ../DBD-mysql-4.005-MXzdoi/t/mysql.mtest 2007-07-20
>17:31:37.000000000 +1000
>+++ t/mysql.mtest 2007-07-23 10:53:54.000000000 +1000
>@@ -12,13 +12,13 @@
> 'testpassword' => '',
> 'testsocket' => ''
> };
>-$::test_host = $opt->{'testhost'};
>-$::test_port = $opt->{'testport'};
>-$::test_user = $opt->{'testuser'};
>-$::test_socket = $opt->{'testsocket'};
>-$::test_password = $opt->{'testpassword'};
>-$::test_db = $opt->{'testdb'};
>-$::test_dsn = "DBI:mysql:$::test_db";
>+$::test_host = $::test_host || $opt->{'testhost'};
>+$::test_port = $::test_port || $opt->{'testport'};
>+$::test_user = $::test_user || $opt->{'testuser'};
>+$::test_socket = $::test_socket || $opt->{'testsocket'};
>+$::test_password = $::test_password || $opt->{'testpassword'};
>+$::test_db = $::test_db || $opt->{'testdb'};
>+$::test_dsn = $::test_dsn || "DBI:mysql:$::test_db";
> $::test_dsn .= ";mysql_socket=$::test_socket" if $::test_socket;
> $::test_dsn .= ":$::test_host" if $::test_host;
> $::test_dsn .= ":$::test_port" if $::test_port;
>
>While it may make sense for standalone builds with non-default security
>to pass the required environment by altering the mysql.mtest file, for
>CPAN builds it makes more sense to allow the user to set the DBI_xxxx
>environment variables.
>
>Please let me know if there is a more appropriate place to submit this
>patch, or any feedback on it.
>
>Hope this helps,
>
>Paul
>
>
>
--
Patrick Galbraith, Senior Programmer
Grazr - Easy feed grazing and sharing
http://www.grazr.com
Satyam Eva Jayate - Truth Alone Triumphs
Mundaka Upanishad
--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=gcdmp-msql-mysql-modules@m .gmane.org