t/data/trivial/migrate-1.pl

filter: Statementstmt 86.6% 13 / 15 Branchbran 50.0% 2 / 4 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 2 / 2 Podpod n/a totaltotal 69.2% 18 / 26 CC 1 SCAR 0.0
CC
1
Cov
73%
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« t/data/trivial/migrate-02.pl ↑ Summary t/data/trivial/migrate-03.pl »
1 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use DBI ();
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 # Locate the SQLite database
5 1 my $file = <STDIN>;
6 1 chomp($file);
7 1 ▶unless ( -f $file and -w $file ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-f $file and -w $file) 0 1 1
Condition33%1/3
-f $file and -w $file
!ll&&!rl&&r
001
MC/DC0%0/2
-f $file and -w $file
-f $file -w $file
Truth table33%1/3
A and B
A= -f $fileB= -w $file
ABresult
0X0
100
111
8 0 die "SQLite file $file does not exist";
9 }
10  
11 # Connect to the SQLite database
12 1 my $dbh = DBI->connect("dbi:SQLite(RaiseError=>1):$file");
13 1 ▶unless ( $dbh ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($dbh) 0 1 1
14 0 die "Failed to connect to $file";
15 }
16  
17  
18  
19  
20  
21 #####################################################################
22 # Migration
23  
24 1 foreach ( split /;\s+/, <<'END_SQL' ) { $dbh->do( $_ ) }
25  
26 create table foo (
27 id integer not null primary key,
28 name varchar(32) not null
29 );
30  
31 insert into foo values ( 1, 'foo' )
32  
33 END_SQL
« t/data/trivial/migrate-02.pl ↑ Summary t/data/trivial/migrate-03.pl »