line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Tapper::Schema::TestTools; |
2
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:TAPPER'; |
3
|
|
|
|
|
|
|
$Tapper::Schema::TestTools::VERSION = '5.0.11'; |
4
|
|
|
|
|
|
|
# inspired by Test::Fixture::DBIC::Schema |
5
|
|
|
|
|
|
|
|
6
|
7
|
|
|
7
|
|
282951
|
use strict; |
|
7
|
|
|
|
|
46
|
|
|
7
|
|
|
|
|
174
|
|
7
|
7
|
|
|
7
|
|
29
|
use warnings; |
|
7
|
|
|
|
|
12
|
|
|
7
|
|
|
|
|
190
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
BEGIN { |
10
|
7
|
|
|
7
|
|
2108
|
use Class::C3; |
|
7
|
|
|
|
|
15417
|
|
|
7
|
|
|
|
|
41
|
|
11
|
7
|
|
|
7
|
|
2225
|
use MRO::Compat; |
|
7
|
|
|
|
|
7022
|
|
|
7
|
|
|
|
|
232
|
|
12
|
7
|
|
|
7
|
|
120
|
$DBD::SQLite::sqlite_version; # fix "used only once" warning |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
7
|
|
|
7
|
|
1493
|
use Tapper::Config; |
|
7
|
|
|
|
|
281125
|
|
|
7
|
|
|
|
|
241
|
|
16
|
7
|
|
|
7
|
|
2795
|
use Tapper::Schema::TestrunDB; |
|
7
|
|
|
|
|
26
|
|
|
7
|
|
|
|
|
1837
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my $testrundb_schema; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub setup_db |
22
|
|
|
|
|
|
|
{ |
23
|
|
|
|
|
|
|
# explicitely prefix into {test} subhash of the config file, |
24
|
|
|
|
|
|
|
# to avoid painful mistakes with deploy |
25
|
|
|
|
|
|
|
|
26
|
7
|
|
|
7
|
1
|
50
|
my ($db, $cfgbase) = @_; |
27
|
|
|
|
|
|
|
|
28
|
7
|
|
|
|
|
18
|
my $cfg = $cfgbase->{$db}; |
29
|
7
|
|
|
|
|
17
|
my $dsn = $cfg->{dsn}; |
30
|
7
|
|
|
|
|
42
|
my ($tmpfname) = $dsn =~ m,dbi:SQLite:dbname=([\w./]+),i; |
31
|
7
|
|
|
|
|
1773
|
unlink $tmpfname; |
32
|
7
|
|
|
|
|
110
|
my $schema = Tapper::Schema::TestrunDB->connect($dsn, $cfg->{username}, $cfg->{password}, { ignore_version => 1 }); |
33
|
7
|
|
|
|
|
551141
|
$schema->deploy; |
34
|
|
|
|
|
|
|
# $schema->upgrade if $schema->schema_version > $schema->get_db_version; |
35
|
7
|
|
|
|
|
25872226
|
return $schema; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub setup_testrundb { |
40
|
7
|
|
|
7
|
1
|
57
|
$testrundb_schema = setup_db("TestrunDB", Tapper::Config->subconfig->{test}{database}); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub import { |
45
|
7
|
|
|
7
|
|
281
|
my $pkg = caller(0); |
46
|
7
|
|
|
7
|
|
62
|
no strict 'refs'; ## no critic. |
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
601
|
|
47
|
7
|
|
|
62
|
|
54
|
*{"$pkg\::testrundb_schema"} = sub () { $testrundb_schema }; |
|
7
|
|
|
|
|
7762
|
|
|
62
|
|
|
|
|
697627
|
|
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
setup_testrundb; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
1; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
__END__ |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=pod |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=encoding UTF-8 |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 NAME |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Tapper::Schema::TestTools |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head2 setup_db |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Setup and connect a test database using SQLite. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head2 setup_testrundb |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Setup and connect a test TestrunDB using SQLite. |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 AUTHORS |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=over 4 |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=item * |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
AMD OSRC Tapper Team <tapper@amd64.org> |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=item * |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Tapper Team <tapper-ops@amazon.com> |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=back |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
This software is Copyright (c) 2019 by Advanced Micro Devices, Inc.. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
This is free software, licensed under: |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
The (two-clause) FreeBSD License |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=cut |