I have this script:
#!/var/home/cherry/opt/perl
use Test::More;
use DBI;
use Test::mysqld;
use Data::Dumper;
my $mysqld = Test::mysqld->new(
base_dir => '/tmp/test_mysqls',
my_cnf => {
'skip-networking' => '', # no TCP socket
}
) or plan skip_all => $Test::mysqld::errstr;
my $dbh = DBI->connect(
$mysqld->dsn(dbname => 'test'),
);
warn Dumper($mysqld);
done_testing();
When I run this, here’s the output I get:
prove -lv t/test.t
t/test.t .. $VAR1 = bless( {
'_owner_pid' => 21854,
'base_dir' => '/tmp/test_mysqls',
'pid' => 21918,
'mysql_install_db' => '/usr/bin/mysql_install_db',
'auto_start' => 2,
'my_cnf' => {
'tmpdir' => '/tmp/test_mysqls/tmp',
'pid-file' => '/tmp/test_mysqls/tmp/mysqld.pid',
'skip-networking' => '',
'datadir' => '/tmp/test_mysqls/var',
'socket' => '/tmp/test_mysqls/tmp/mysql.sock'
},
'mysqld' => '/usr/sbin/mysqld'
}, 'Test::mysqld' );
1..0
The test never completes. The script waits on a newline for ever and never exits — when I do ps aux, I can see the instance of mysqld running even after I do ctrl + c. I don’t even know where to begin to troubleshoot this issue. Any hints?
Try adding a do {} and invoking $mysqld->stop inside an eval {} to shut down the mysqld.