line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Wiki::Toolkit::TestConfig::Utilities; |
2
|
|
|
|
|
|
|
|
3
|
8
|
|
|
8
|
|
3208
|
use strict; |
|
8
|
|
|
|
|
11
|
|
|
8
|
|
|
|
|
186
|
|
4
|
|
|
|
|
|
|
|
5
|
8
|
|
|
8
|
|
2643
|
use Wiki::Toolkit::TestConfig; |
|
8
|
|
|
|
|
32
|
|
|
8
|
|
|
|
|
227
|
|
6
|
|
|
|
|
|
|
|
7
|
8
|
|
|
8
|
|
27
|
use vars qw( $num_stores $num_combinations $VERSION ); |
|
8
|
|
|
|
|
11
|
|
|
8
|
|
|
|
|
4428
|
|
8
|
|
|
|
|
|
|
$VERSION = '0.06'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Wiki::Toolkit::TestConfig::Utilities - Utilities for testing Wiki::Toolkit things (deprecated). |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 DESCRIPTION |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Deprecated - use L instead. |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=cut |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my %stores; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
foreach my $dbtype (qw( MySQL Pg SQLite )) { |
23
|
|
|
|
|
|
|
if ($Wiki::Toolkit::TestConfig::config{$dbtype}->{dbname}) { |
24
|
|
|
|
|
|
|
my %config = %{$Wiki::Toolkit::TestConfig::config{$dbtype}}; |
25
|
|
|
|
|
|
|
my $store_class = "Wiki::Toolkit::Store::$dbtype"; |
26
|
|
|
|
|
|
|
eval "require $store_class"; |
27
|
|
|
|
|
|
|
my $store = $store_class->new( dbname => $config{dbname}, |
28
|
|
|
|
|
|
|
dbuser => $config{dbuser}, |
29
|
|
|
|
|
|
|
dbpass => $config{dbpass}, |
30
|
|
|
|
|
|
|
dbhost => $config{dbhost} ); |
31
|
|
|
|
|
|
|
$stores{$dbtype} = $store; |
32
|
|
|
|
|
|
|
} else { |
33
|
|
|
|
|
|
|
$stores{$dbtype} = undef; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
$num_stores = scalar keys %stores; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
my %searches; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# DBIxFTS only works with MySQL. |
42
|
|
|
|
|
|
|
if ( $Wiki::Toolkit::TestConfig::config{dbixfts} && $stores{MySQL} ) { |
43
|
|
|
|
|
|
|
require Wiki::Toolkit::Search::DBIxFTS; |
44
|
|
|
|
|
|
|
my $dbh = $stores{MySQL}->dbh; |
45
|
|
|
|
|
|
|
$searches{DBIxFTSMySQL} = Wiki::Toolkit::Search::DBIxFTS->new( dbh => $dbh ); |
46
|
|
|
|
|
|
|
} else { |
47
|
|
|
|
|
|
|
$searches{DBIxFTSMySQL} = undef; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# Test the MySQL SII backend, if we can. |
51
|
|
|
|
|
|
|
if ( $Wiki::Toolkit::TestConfig::config{search_invertedindex} && $stores{MySQL} ) { |
52
|
|
|
|
|
|
|
require Search::InvertedIndex::DB::Mysql; |
53
|
|
|
|
|
|
|
require Wiki::Toolkit::Search::SII; |
54
|
|
|
|
|
|
|
my %dbconfig = %{$Wiki::Toolkit::TestConfig::config{MySQL}}; |
55
|
|
|
|
|
|
|
my $indexdb = Search::InvertedIndex::DB::Mysql->new( |
56
|
|
|
|
|
|
|
-db_name => $dbconfig{dbname}, |
57
|
|
|
|
|
|
|
-username => $dbconfig{dbuser}, |
58
|
|
|
|
|
|
|
-password => $dbconfig{dbpass}, |
59
|
|
|
|
|
|
|
-hostname => $dbconfig{dbhost} || "", |
60
|
|
|
|
|
|
|
-table_name => 'siindex', |
61
|
|
|
|
|
|
|
-lock_mode => 'EX' ); |
62
|
|
|
|
|
|
|
$searches{SIIMySQL} = Wiki::Toolkit::Search::SII->new( indexdb => $indexdb ); |
63
|
|
|
|
|
|
|
} else { |
64
|
|
|
|
|
|
|
$searches{SIIMySQL} = undef; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# Test the Pg SII backend, if we can. |
68
|
|
|
|
|
|
|
eval { require Search::InvertedIndex::DB::Pg; }; |
69
|
|
|
|
|
|
|
my $sii_pg = $@ ? 0 : 1; |
70
|
|
|
|
|
|
|
if ( $Wiki::Toolkit::TestConfig::config{search_invertedindex} && $stores{Pg} |
71
|
|
|
|
|
|
|
&& $sii_pg ) { |
72
|
|
|
|
|
|
|
require Search::InvertedIndex::DB::Pg; |
73
|
|
|
|
|
|
|
require Wiki::Toolkit::Search::SII; |
74
|
|
|
|
|
|
|
my %dbconfig = %{$Wiki::Toolkit::TestConfig::config{Pg}}; |
75
|
|
|
|
|
|
|
my $indexdb = Search::InvertedIndex::DB::Pg->new( |
76
|
|
|
|
|
|
|
-db_name => $dbconfig{dbname}, |
77
|
|
|
|
|
|
|
-username => $dbconfig{dbuser}, |
78
|
|
|
|
|
|
|
-password => $dbconfig{dbpass}, |
79
|
|
|
|
|
|
|
-hostname => $dbconfig{dbhost}, |
80
|
|
|
|
|
|
|
-table_name => 'siindex', |
81
|
|
|
|
|
|
|
-lock_mode => 'EX' ); |
82
|
|
|
|
|
|
|
$searches{SIIPg} = Wiki::Toolkit::Search::SII->new( indexdb => $indexdb ); |
83
|
|
|
|
|
|
|
} else { |
84
|
|
|
|
|
|
|
$searches{SIIPg} = undef; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
# Also test the default DB_File backend, if we have S::II installed at all. |
88
|
|
|
|
|
|
|
if ( $Wiki::Toolkit::TestConfig::config{search_invertedindex} ) { |
89
|
|
|
|
|
|
|
require Search::InvertedIndex; |
90
|
|
|
|
|
|
|
require Wiki::Toolkit::Search::SII; |
91
|
|
|
|
|
|
|
my $indexdb = Search::InvertedIndex::DB::DB_File_SplitHash->new( |
92
|
|
|
|
|
|
|
-map_name => 't/sii-db-file-test.db', |
93
|
|
|
|
|
|
|
-lock_mode => 'EX' ); |
94
|
|
|
|
|
|
|
$searches{SII} = Wiki::Toolkit::Search::SII->new( indexdb => $indexdb ); |
95
|
|
|
|
|
|
|
} else { |
96
|
|
|
|
|
|
|
$searches{SII} = undef; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
my @combinations; # which searches work with which stores. |
100
|
|
|
|
|
|
|
push @combinations, { store_name => "MySQL", |
101
|
|
|
|
|
|
|
store => $stores{MySQL}, |
102
|
|
|
|
|
|
|
search_name => "DBIxFTSMySQL", |
103
|
|
|
|
|
|
|
search => $searches{DBIxFTSMySQL} }; |
104
|
|
|
|
|
|
|
push @combinations, { store_name => "MySQL", |
105
|
|
|
|
|
|
|
store => $stores{MySQL}, |
106
|
|
|
|
|
|
|
search_name => "SIIMySQL", |
107
|
|
|
|
|
|
|
search => $searches{SIIMySQL} }; |
108
|
|
|
|
|
|
|
push @combinations, { store_name => "Pg", |
109
|
|
|
|
|
|
|
store => $stores{Pg}, |
110
|
|
|
|
|
|
|
search_name => "SIIPg", |
111
|
|
|
|
|
|
|
search => $searches{SIIPg} }; |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
# All stores are compatible with the default S::II search, and with no search. |
114
|
|
|
|
|
|
|
foreach my $store_name ( keys %stores ) { |
115
|
|
|
|
|
|
|
push @combinations, { store_name => $store_name, |
116
|
|
|
|
|
|
|
store => $stores{$store_name}, |
117
|
|
|
|
|
|
|
search_name => "SII", |
118
|
|
|
|
|
|
|
search => $searches{SII} }; |
119
|
|
|
|
|
|
|
push @combinations, { store_name => $store_name, |
120
|
|
|
|
|
|
|
store => $stores{$store_name}, |
121
|
|
|
|
|
|
|
search_name => "undef", |
122
|
|
|
|
|
|
|
search => undef }; |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
foreach my $comb ( @combinations ) { |
126
|
|
|
|
|
|
|
# There must be a store configured for us to test, but a search is optional |
127
|
|
|
|
|
|
|
$comb->{configured} = $comb->{store} ? 1 : 0; |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
$num_combinations = scalar @combinations; |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
sub reinitialise_stores { |
133
|
1
|
|
|
1
|
0
|
10
|
my $class = shift; |
134
|
1
|
|
|
|
|
3
|
my %stores = $class->stores; |
135
|
|
|
|
|
|
|
|
136
|
1
|
|
|
|
|
1
|
my ($store_name, $store); |
137
|
1
|
|
|
|
|
5
|
while ( ($store_name, $store) = each %stores ) { |
138
|
3
|
50
|
|
|
|
10
|
next unless $store; |
139
|
|
|
|
|
|
|
|
140
|
0
|
|
|
|
|
0
|
my $dbname = $store->dbname; |
141
|
0
|
|
|
|
|
0
|
my $dbuser = $store->dbuser; |
142
|
0
|
|
|
|
|
0
|
my $dbpass = $store->dbpass; |
143
|
0
|
|
|
|
|
0
|
my $dbhost = $store->dbhost; |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
# Clear out the test database, then set up tables afresh. |
146
|
0
|
|
|
|
|
0
|
my $setup_class = "Wiki::Toolkit::Setup::$store_name"; |
147
|
0
|
|
|
|
|
0
|
eval "require $setup_class"; |
148
|
|
|
|
|
|
|
{ |
149
|
8
|
|
|
8
|
|
36
|
no strict "refs"; |
|
8
|
|
|
|
|
8
|
|
|
8
|
|
|
|
|
1321
|
|
|
0
|
|
|
|
|
0
|
|
150
|
0
|
|
|
|
|
0
|
&{"$setup_class\:\:cleardb"}($dbname, $dbuser, $dbpass, $dbhost); |
|
0
|
|
|
|
|
0
|
|
151
|
0
|
|
|
|
|
0
|
&{"$setup_class\:\:setup"}($dbname, $dbuser, $dbpass, $dbhost); |
|
0
|
|
|
|
|
0
|
|
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
} |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
sub stores { |
157
|
8
|
|
|
8
|
0
|
1488
|
return %stores; |
158
|
|
|
|
|
|
|
} |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
sub combinations { |
161
|
0
|
|
|
0
|
0
|
|
return @combinations; |
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=head1 SEE ALSO |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
L, the replacement for this module. |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=head1 AUTHOR |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
Kake Pugh (kake@earth.li). |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=head1 COPYRIGHT |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
Copyright (C) 2003 Kake Pugh. All Rights Reserved. |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
This module is free software; you can redistribute it and/or modify it |
177
|
|
|
|
|
|
|
under the same terms as Perl itself. |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=cut |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
1; |