line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Class::Inflate::Builder; |
2
|
2
|
|
|
2
|
|
189868
|
use Module::Build; |
|
2
|
|
|
|
|
38
|
|
|
2
|
|
|
|
|
5255
|
|
3
|
|
|
|
|
|
|
@ISA = qw(Module::Build); |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# Generated automatically from Build.PL |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
my $dbfile = 'dbfile'; |
8
|
|
|
|
|
|
|
my $dsn = "dbi:SQLite:dbname=$dbfile"; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
my @setup = ( |
11
|
|
|
|
|
|
|
'create table person (id number(2), first varchar(20), last varchar(20))', |
12
|
|
|
|
|
|
|
'create table bio (id number(2), hometown varchar(20))', |
13
|
|
|
|
|
|
|
'create table location (id number(2), state varchar(2))', |
14
|
|
|
|
|
|
|
'create table organization (org_id number(2), org_name varchar(50))', |
15
|
|
|
|
|
|
|
'create table department (org_id number(2), dept_id number(2), dept_name varchar(50))', |
16
|
|
|
|
|
|
|
'create table staff (org_id number(2), dept_id number(2), id number(2), title varchar(20))', |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
my %data = ( |
20
|
|
|
|
|
|
|
'person' => [ |
21
|
|
|
|
|
|
|
[10, 'Nathan', 'Gray'], |
22
|
|
|
|
|
|
|
[11, 'One', 'Schmo'], |
23
|
|
|
|
|
|
|
], |
24
|
|
|
|
|
|
|
'bio' => [ |
25
|
|
|
|
|
|
|
[11, 'Vienna'], |
26
|
|
|
|
|
|
|
[10, 'Fairfax'], |
27
|
|
|
|
|
|
|
], |
28
|
|
|
|
|
|
|
'location' => [ |
29
|
|
|
|
|
|
|
[11, 'PA'], |
30
|
|
|
|
|
|
|
[10, 'VA'], |
31
|
|
|
|
|
|
|
[10, 'DC'], |
32
|
|
|
|
|
|
|
], |
33
|
|
|
|
|
|
|
'organization' => [ |
34
|
|
|
|
|
|
|
[1, 'First Organization'], |
35
|
|
|
|
|
|
|
[2, '2nd Organization'], |
36
|
|
|
|
|
|
|
], |
37
|
|
|
|
|
|
|
'department' => [ |
38
|
|
|
|
|
|
|
[1, 1, 'First Department'], |
39
|
|
|
|
|
|
|
[1, 2, 'Second Department'], |
40
|
|
|
|
|
|
|
[2, 1, '1st Department'], |
41
|
|
|
|
|
|
|
[2, 2, '2nd Department'], |
42
|
|
|
|
|
|
|
], |
43
|
|
|
|
|
|
|
'staff' => [ |
44
|
|
|
|
|
|
|
[2, 1, 10, 'Programmer'], |
45
|
|
|
|
|
|
|
[2, 1, 11, 'Tech Support'], |
46
|
|
|
|
|
|
|
], |
47
|
|
|
|
|
|
|
); |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub ACTION_test { |
50
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
51
|
0
|
|
|
|
|
|
$self->notes('dsn' => $dsn); |
52
|
0
|
|
|
|
|
|
eval { require DBI }; |
|
0
|
|
|
|
|
|
|
53
|
0
|
0
|
|
|
|
|
if ($@) { |
54
|
0
|
|
|
|
|
|
warn "Cannot run tests without DBI: $!\n"; |
55
|
0
|
|
|
|
|
|
return; |
56
|
|
|
|
|
|
|
} |
57
|
0
|
|
|
|
|
|
print "Generating test database\n"; |
58
|
0
|
|
|
|
|
|
my $dbh = DBI->connect($dsn, '', ''); |
59
|
0
|
|
|
|
|
|
foreach my $query (@setup) { |
60
|
0
|
|
|
|
|
|
$dbh->do($query); |
61
|
|
|
|
|
|
|
} |
62
|
0
|
|
|
|
|
|
foreach my $table (keys %data) { |
63
|
0
|
|
|
|
|
|
my $sth; |
64
|
0
|
|
|
|
|
|
foreach my $bind (@{$data{$table}}) { |
|
0
|
|
|
|
|
|
|
65
|
0
|
|
0
|
|
|
|
$sth ||= $dbh->prepare("insert into $table values (" . join(', ', map { '?' } @$bind) . ")"); |
|
0
|
|
|
|
|
|
|
66
|
0
|
|
|
|
|
|
$sth->execute(@$bind); |
67
|
|
|
|
|
|
|
} |
68
|
0
|
|
|
|
|
|
$sth->finish; |
69
|
|
|
|
|
|
|
} |
70
|
0
|
|
|
|
|
|
$self->SUPER::ACTION_test; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub ACTION_clean { |
74
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
75
|
0
|
|
|
|
|
|
eval { require DBI }; |
|
0
|
|
|
|
|
|
|
76
|
0
|
0
|
|
|
|
|
unless ($@) { |
77
|
0
|
|
|
|
|
|
print "Removing test database\n"; |
78
|
0
|
|
|
|
|
|
my $dbh = DBI->connect($dsn, '', ''); |
79
|
0
|
|
|
|
|
|
foreach my $table (keys %data) { |
80
|
0
|
|
|
|
|
|
$dbh->do("drop table $table"); |
81
|
|
|
|
|
|
|
} |
82
|
0
|
0
|
|
|
|
|
$self->add_to_cleanup($dbfile) if $dbfile; |
83
|
|
|
|
|
|
|
} |
84
|
0
|
|
|
|
|
|
$self->SUPER::ACTION_clean; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
1; |