line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::mysqld::DatadirDumper; |
2
|
2
|
|
|
2
|
|
44231
|
use 5.008001; |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
82
|
|
3
|
2
|
|
|
2
|
|
12
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
75
|
|
4
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
13
|
|
|
2
|
|
|
|
|
105
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = "0.01"; |
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
12
|
use Carp qw/croak/; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
140
|
|
9
|
2
|
|
|
2
|
|
6750
|
use DBI; |
|
2
|
|
|
|
|
41391
|
|
|
2
|
|
|
|
|
154
|
|
10
|
2
|
|
|
2
|
|
1815
|
use DBIx::FixtureLoader; |
|
2
|
|
|
|
|
168055
|
|
|
2
|
|
|
|
|
119
|
|
11
|
2
|
|
|
2
|
|
18
|
use File::Spec; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
52
|
|
12
|
2
|
|
|
2
|
|
2667
|
use Test::mysqld; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
use Class::Accessor::Lite ( |
15
|
|
|
|
|
|
|
new => 1, |
16
|
|
|
|
|
|
|
ro => [qw/ddl_file datadir fixtures/], |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub dump { |
20
|
|
|
|
|
|
|
my $self = shift; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
my $datadir = $self->datadir; |
23
|
|
|
|
|
|
|
unless ( File::Spec->file_name_is_absolute($datadir) ) { |
24
|
|
|
|
|
|
|
$datadir = File::Spec->rel2abs($datadir), |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my $mysqld = Test::mysqld->new( |
28
|
|
|
|
|
|
|
my_cnf => { |
29
|
|
|
|
|
|
|
'skip-networking' => '', |
30
|
|
|
|
|
|
|
datadir => $datadir, |
31
|
|
|
|
|
|
|
}, |
32
|
|
|
|
|
|
|
) or die $Test::mysqld::errstr; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
my $dsn = $mysqld->dsn; |
35
|
|
|
|
|
|
|
my $dbh = DBI->connect($dsn, '', '', { |
36
|
|
|
|
|
|
|
RaiseError => 1, |
37
|
|
|
|
|
|
|
PrintError => 0, |
38
|
|
|
|
|
|
|
ShowErrorStatement => 1, |
39
|
|
|
|
|
|
|
AutoInactiveDestroy => 1, |
40
|
|
|
|
|
|
|
mysql_enable_utf8 => 1, |
41
|
|
|
|
|
|
|
}); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
my $source = do { |
44
|
|
|
|
|
|
|
local $/; |
45
|
|
|
|
|
|
|
open my $fh, '<', $self->ddl_file or die $!; |
46
|
|
|
|
|
|
|
<$fh> |
47
|
|
|
|
|
|
|
}; |
48
|
|
|
|
|
|
|
my @statements = map { "$_;" } grep { /\S+/ } split ';', $source; |
49
|
|
|
|
|
|
|
for my $statement (@statements) { |
50
|
|
|
|
|
|
|
$dbh->do($statement) or croak $dbh->errstr; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
if (my @fixtures = @{ $self->fixtures || [] }) { |
54
|
|
|
|
|
|
|
my $loader = DBIx::FixtureLoader->new(dbh => $dbh); |
55
|
|
|
|
|
|
|
$loader->load_fixture($_) for @fixtures; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
1; |
60
|
|
|
|
|
|
|
__END__ |