Skip to content

Commit

Permalink
Item11091: Item10961: Item10993: handling of missing ,v files revised…
Browse files Browse the repository at this point in the history
…, with the store now behaving correctly if a .txt,v is missing or inconsistent with .txt. Note that this *will not work* if used with a file system that does not maintain file modification times, or a perl that doesn't report them correctly, or an RCS that assigns a more recently file time to the .txt than that on the .txt,v. I also have some conserns about performance, but based on my benchmarking can't nail anything down.

git-svn-id: http://svn.foswiki.org/branches/Release01x01@12497 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
CrawfordCurrie authored and CrawfordCurrie committed Sep 11, 2011
1 parent 45dd367 commit a5f1985
Show file tree
Hide file tree
Showing 21 changed files with 949 additions and 434 deletions.
6 changes: 4 additions & 2 deletions UnitTestContrib/lib/Foswiki/Contrib/UnitTestContrib/MANIFEST
Expand Up @@ -69,7 +69,7 @@ test/unit/PluginHandlerTests.pm 0644
test/unit/PrefsTests.pm 0644
test/unit/QueryTests.pm 0644
test/unit/RESTTests.pm 0644
test/unit/RcsTests.pm 0644
test/unit/RCSHandlerTests.pm 0644
test/unit/RegisterTests.pm 0644
test/unit/RenameTests.pm 0755
test/unit/RenderFormTests.pm 0644
Expand All @@ -80,10 +80,12 @@ test/unit/RobustnessTests.pm 0644
test/unit/SaveScriptTests.pm 0644
test/unit/SeleniumConfigTests.pm 0644
test/unit/SemiAutomaticTestCaseTests.pm 0644
test/unit/StoreSmokeTests.pm 0644
test/unit/VCStoreTests.pm 0644
test/unit/VCMetaTests.pm 0644
test/unit/StoreTests.pm 0644
test/unit/TOCTests.pm 0644
test/unit/FoswikiFnTestCase.pm 0644
test/unit/FoswikiStoreTestCase.pm 0644
test/unit/FoswikiSeleniumTestCase.pm 0644
test/unit/FoswikiSuite.pm 0644
test/unit/FoswikiTestCase.pm 0644
Expand Down
50 changes: 25 additions & 25 deletions UnitTestContrib/test/unit/ConfigureTests.pm
Expand Up @@ -1019,16 +1019,16 @@ sub test_Package_makeBackup {
$this->assert_matches( qr/Backup saved into/, $msg );
$result = $pkg->uninstall();

my @expFiles = qw(
Testsandboxweb1234/Subweb/TestTopic43.txt
Testsandboxweb1234/TestTopic1.txt
Testsandboxweb1234/TestTopic43.txt
Testsandboxweb1234/Subweb/TestTopic43/file3.att
Testsandboxweb1234/Subweb/TestTopic43/subdir-1.2.3/file4.att
Testsandboxweb1234/TestTopic1/file.att
Testsandboxweb1234/TestTopic43/file.att
Testsandboxweb1234/TestTopic43/file2.att
configure/pkgdata/MyPlugin_installer
my @expFiles = (
'Testsandboxweb1234/Subweb/TestTopic43.txt',
'Testsandboxweb1234/TestTopic1.txt',
'Testsandboxweb1234/TestTopic43.txt',
'Testsandboxweb1234/Subweb/TestTopic43/file3.att',
'Testsandboxweb1234/Subweb/TestTopic43/subdir-1.2.3/file4.att',
'Testsandboxweb1234/TestTopic1/file.att',
'Testsandboxweb1234/TestTopic43/file.att',
'Testsandboxweb1234/TestTopic43/file2.att',
'configure/pkgdata/MyPlugin_installer'
);

push @expFiles, "$this->{scriptdir}/shbtest1";
Expand Down Expand Up @@ -1383,21 +1383,21 @@ qr/^Foswiki::Contrib::OptionalDependency version >=14754 required(.*)^ -- perl m
#
my $results = $pkg2->uninstall();

my @expFiles = qw(
Testsandboxweb1234/Subweb/TestTopic43.txt
Testsandboxweb1234/Subweb/TestTopic43.txt,v
Testsandboxweb1234/TestTopic1.txt
Testsandboxweb1234/TestTopic43.txt
Testsandboxweb1234/TestTopic43.txt,v
Testsandboxweb1234/Subweb/TestTopic43/file3.att
Testsandboxweb1234/Subweb/TestTopic43/file3.att,v
Testsandboxweb1234/Subweb/TestTopic43/subdir-1.2.3/file4.att
Testsandboxweb1234/TestTopic1/file.att
Testsandboxweb1234/TestTopic43/file.att
Testsandboxweb1234/TestTopic43/file.att,v
Testsandboxweb1234/TestTopic43/file2.att
Testsandboxweb1234/TestTopic43/file2.att,v
configure/pkgdata/MyPlugin_installer
my @expFiles = (
'Testsandboxweb1234/Subweb/TestTopic43.txt',
'Testsandboxweb1234/Subweb/TestTopic43.txt,v',
'Testsandboxweb1234/TestTopic1.txt',
'Testsandboxweb1234/TestTopic43.txt',
'Testsandboxweb1234/TestTopic43.txt,v',
'Testsandboxweb1234/Subweb/TestTopic43/file3.att',
'Testsandboxweb1234/Subweb/TestTopic43/file3.att,v',
'Testsandboxweb1234/Subweb/TestTopic43/subdir-1.2.3/file4.att',
'Testsandboxweb1234/TestTopic1/file.att',
'Testsandboxweb1234/TestTopic43/file.att',
'Testsandboxweb1234/TestTopic43/file.att,v',
'Testsandboxweb1234/TestTopic43/file2.att',
'Testsandboxweb1234/TestTopic43/file2.att,v',
'configure/pkgdata/MyPlugin_installer'
);

push @expFiles, "$this->{scriptdir}/shbtest1";
Expand Down
11 changes: 10 additions & 1 deletion UnitTestContrib/test/unit/Fn_SEARCH.pm
Expand Up @@ -2845,6 +2845,15 @@ GNURF
);

#order by modified, limit=2, with groupby=none
my @tops = ();
foreach my $web ($this->{test_web}, "Main", "System", "Sandbox") {
if (Foswiki::Func::topicExists($web, "WebHome")) {
my @i = Foswiki::Func::getRevisionInfo($web, "WebHome");
push(@tops, [$web, $i[0]]);
}
}
@tops = map { $_->[0] } sort { $a->[1] <=> $b->[1] } @tops;

$result = $this->{test_topicObject}->expandMacros( <<GNURF );
%SEARCH{"1"
type="query"
Expand All @@ -2861,7 +2870,7 @@ GNURF
limit="2"
}%
GNURF
$this->assert_equals( "HEADERMain WebHome, Sandbox WebHomeFOOTER\n",
$this->assert_equals( "HEADER$tops[0] WebHome, $tops[1] WebHomeFOOTER\n",
$result );
}

Expand Down
73 changes: 73 additions & 0 deletions UnitTestContrib/test/unit/FoswikiStoreTestCase.pm
@@ -0,0 +1,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;
3 changes: 1 addition & 2 deletions UnitTestContrib/test/unit/FuncTests.pm
Expand Up @@ -2035,8 +2035,7 @@ sub test_getRevisionAtTime {
forcedate => $t2
}
);
$this->assert_equals(
0,
$this->assert_null(
Foswiki::Func::getRevisionAtTime(
$this->{test_web}, "ShutThatDoor", $t1 - 60
)
Expand Down
4 changes: 2 additions & 2 deletions UnitTestContrib/test/unit/LoadedRevTests.pm
Expand Up @@ -124,7 +124,7 @@ WHEE
my $topicObject =
Foswiki::Meta->load(
$this->{session}, $this->{test_web}, "NoCommaV");
$this->assert_equals(3, $topicObject->getLoadedRev());
$this->assert_equals(1, $topicObject->getLoadedRev());

$topicObject =
Foswiki::Meta->new(
Expand All @@ -145,7 +145,7 @@ WHEE
$topicObject = Foswiki::Meta->new(
$this->{session}, $this->{test_web}, "NoCommaV");
$topicObject->load();
$this->assert_equals(3, $topicObject->getLoadedRev());
$this->assert_equals(1, $topicObject->getLoadedRev());

# Reload 0
$topicObject = Foswiki::Meta->new(
Expand Down
2 changes: 1 addition & 1 deletion UnitTestContrib/test/unit/MetaTests.pm
Expand Up @@ -967,7 +967,7 @@ HERE

$ti = $meta->getRevisionInfo();
$this->assert_equals('BaseUserMapping_666', $ti->{author});
$this->assert_equals(1, $ti->{version});
$this->assert_equals(0, $ti->{version});
$this->assert_equals(0, $ti->{date});
}

Expand Down
34 changes: 0 additions & 34 deletions UnitTestContrib/test/unit/QueryTests.pm
Expand Up @@ -369,40 +369,6 @@ sub verify_d2n {
$this->check( "d2n notatime", eval => undef );
}

sub verify_string_bops {
my $this = shift;
$this->check( "string='String'", eval => 1 );
$this->check( "string='String '", eval => 0 );
$this->check( "string~'String '", eval => 0 );
$this->check( "string~notafield", eval => 0 );
$this->check( "notafield=~'SomeTextToTestFor'", eval => 0 );
$this->check( "string!=notafield", eval => 1 );
$this->check( "string=notafield", eval => 0 );
$this->check( "string='Str'", eval => 0 );
$this->check( "string~'?trin?'", eval => 1 );
$this->check( "string~'*'", eval => 1 );
$this->check( "string~'*String'", eval => 1 );
$this->check( "string~'*trin*'", eval => 1 );
$this->check( "string~'*in?'", eval => 1 );
$this->check( "string~'*ri?'", eval => 0 );
$this->check( "string~'??????'", eval => 1 );
$this->check( "string~'???????'", eval => 0 );
$this->check( "string~'?????'", eval => 0 );
$this->check( "'SomeTextToTestFor'~'Text'", eval => 0, simpler => 0 );
$this->check( "'SomeTextToTestFor'~'*Text'", eval => 0, simpler => 0 );
$this->check( "'SomeTextToTestFor'~'Text*'", eval => 0, simpler => 0 );
$this->check( "'SomeTextToTestFor'~'*Text*'", eval => 1, simpler => 1 );
$this->check( "string!='Str'", eval => 1 );
$this->check( "string!='String '", eval => 1 );
$this->check( "string!='String'", eval => 0 );
$this->check( "string!='string'", eval => 1 );
$this->check( "string='string'", eval => 0 );
$this->check( "macro='\%RED\%'", eval => 1, syntaxOnly => 1 );
$this->check( "macro~'\%RED?'", eval => 1, syntaxOnly => 1 );
$this->check( "macro~'?RED\%'", eval => 1, syntaxOnly => 1 );
$this->check( "macro~'?RED\%'", eval => 1, syntaxOnly => 1 );
}

sub verify_constants {
my $this = shift;
$this->check( "undefined", eval => undef );
Expand Down

0 comments on commit a5f1985

Please sign in to comment.