Skip to content

Commit

Permalink
Item5437: address perlcriticisms which break unicode branch
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/branches/Release01x01@15003 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
PaulHarvey authored and PaulHarvey committed Jun 16, 2012
1 parent 84d591f commit 5b39b20
Showing 1 changed file with 28 additions and 19 deletions.
47 changes: 28 additions & 19 deletions UnitTestContrib/test/unit/FoswikiStoreTestCase.pm
@@ -1,31 +1,32 @@
package FoswikiStoreTestCase;
use strict;
use warnings;

# Specialisation of FoswikiFnTestCase used to perform tests over all
# viable store implementations.
#
# Subclasses are expected to implement set_up_for_verify()
#
use FoswikiFnTestCase;
use FoswikiFnTestCase();
our @ISA = qw( FoswikiFnTestCase );
use File::Spec();

# Determine if RCS is installed. used in tests for RCS functionality.
our $rcs_installed;

sub rcs_is_installed {
if ( !defined($rcs_installed) ) {
$ENV{PATH} =~ /^(.*)$/ms;
$ENV{PATH} = $1; # untaint
eval {
`co -V`; # Check to see if we have co
};
if ( $@ || $? ) {
local $ENV{PATH} = $1; # untaint
if ( eval { `co -V`; 1; } ) # Check to see if we have co
{
$rcs_installed = 1;
}
else {
$rcs_installed = 0;
print STDERR
"*** CANNOT RUN RcsWrap TESTS - NO COMPATIBLE co: $@\n";
}
else {
$rcs_installed = 1;
}
}
return $rcs_installed;
}
Expand All @@ -34,12 +35,16 @@ sub set_up {
my $this = shift;
$this->SUPER::set_up();
$Foswiki::cfg{EnableHierarchicalWebs} = 1;

return;
}

sub tear_down {
my $this = shift;

$this->SUPER::tear_down();

return;
}

sub set_up_for_verify {
Expand All @@ -51,27 +56,31 @@ sub fixture_groups {
my @groups;

foreach my $dir (@INC) {
if ( opendir( D, "$dir/Foswiki/Store" ) ) {
foreach my $alg ( readdir D ) {
my ( $volume, $directories ) = File::Spec->splitpath( $dir, 1 );

$directories = File::Spec->catdir( File::Spec->splitdir($directories),
qw(Foswiki Store) );
if (
opendir( my $D, File::Spec->catpath( $volume, $directories, '' ) ) )
{
foreach my $alg ( readdir $D ) {
next unless $alg =~ s/^(.*)\.pm$/$1/;
next if $alg =~ /RcsWrap/ && !rcs_is_installed();
($alg) = $alg =~ /^(.*)$/ms; # untaint
eval "require Foswiki::Store::$alg";
die $@ if $@;
$this->assert( eval "require Foswiki::Store::$alg; 1;" );
my $algname = ref($this) . '_' . $alg;
next if defined &$algname;
next if defined &{$algname};
no strict 'refs';
*$algname = sub {
my $this = shift;
*{$algname} = sub {
my $self = shift;
$Foswiki::cfg{Store}{Implementation} =
'Foswiki::Store::' . $alg;
$this->set_up_for_verify();
$self->set_up_for_verify();
};
use strict 'refs';
push( @groups, $algname );
$seen{$alg} = 1;
}
closedir(D);
closedir($D);
}
}
# Uncomment below to test one store in isolation
Expand Down

0 comments on commit 5b39b20

Please sign in to comment.