/
FoswikiStoreTestCase.pm
73 lines (64 loc) · 1.83 KB
/
FoswikiStoreTestCase.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package FoswikiStoreTestCase;
# Specialisation of FoswikiFnTestCase used to perform tests over all
# viable store implementations.
#
# Subclasses are expected to implement set_up_for_verify()
#
use FoswikiFnTestCase;
our @ISA = qw( FoswikiFnTestCase );
# Determine if RCS is installed. used in tests for RCS functionality.
our $rcs_installed;
sub rcs_is_installed {
if (!defined($rcs_installed)) {
eval {
`co -V`; # Check to see if we have co
};
if ( $@ || $? ) {
$rcs_installed = 0;
print STDERR "*** CANNOT RUN RcsWrap TESTS - NO COMPATIBLE co: $@\n";
} else {
$rcs_installed = 1;
}
}
return $rcs_installed;
}
sub set_up {
my $this = shift;
$this->SUPER::set_up();
}
sub tear_down {
my $this = shift;
$this->SUPER::tear_down();
}
sub set_up_for_verify {
die "ABSTRACT BASE CLASS";
}
sub fixture_groups {
my @groups;
foreach my $dir (@INC) {
if ( opendir( D, "$dir/Foswiki/Store" ) ) {
foreach my $alg ( readdir D ) {
next unless $alg =~ s/^(.*)\.pm$/$1/;
next if defined &$alg;
$ENV{PATH} =~ /^(.*)$/ms;
$ENV{PATH} = $1;
next if $alg =~ /RcsWrap/ && !rcs_is_installed();
($alg) = $alg =~ /^(.*)$/ms;
eval "require Foswiki::Store::$alg";
die $@ if $@;
no strict 'refs';
*$alg = sub {
my $this = shift;
$Foswiki::cfg{Store}{Implementation} =
'Foswiki::Store::'.$alg;
$this->set_up_for_verify();
};
use strict 'refs';
push(@groups, $alg);
}
closedir(D);
}
}
return \@groups;
}
1;