Skip to content

Commit

Permalink
Item11479: skip rather than expect_failure
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/trunk@13854 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
PaulHarvey authored and PaulHarvey committed Jan 29, 2012
1 parent 16986b8 commit 944c324
Show file tree
Hide file tree
Showing 10 changed files with 217 additions and 135 deletions.
8 changes: 8 additions & 0 deletions UnitTestContrib/test/unit/AddToHeadTests.pm
Expand Up @@ -15,6 +15,14 @@ sub new {
return $self;
}

sub skip {
my ( $this, $test ) = @_;

return $this->check_dependency('Foswiki,>=,1.1')
? 'Feature removed from Foswiki 1.1+'
: undef;
}

sub set_up {
my $this = shift;
$this->SUPER::set_up();
Expand Down
40 changes: 8 additions & 32 deletions UnitTestContrib/test/unit/AddressTests.pm
Expand Up @@ -256,6 +256,14 @@ sub new {
return $this;
}

sub skip {
my ( $this, $test ) = @_;

return $this->check_dependency('Foswiki,<,1.2')
? 'Foswiki 1.1 has no Foswiki::Address'
: undef;
}

sub set_up {
my ($this) = @_;

Expand Down Expand Up @@ -355,8 +363,6 @@ HERE
sub test_roundtrips {
my ($this) = @_;

$this->expect_failure( 'Foswiki 1.1 has no Foswiki::Address',
with_dep => 'Foswiki,<,1.2' );
$this->gendata( \%test_roundtrip_range );
my %test_range = $this->gen_roundtrip_range_tests( \%test_roundtrip_range );

Expand Down Expand Up @@ -391,8 +397,6 @@ sub gen_testspec_fns {

no strict 'refs';
*{$fn} = sub {
$this->expect_failure( 'Foswiki 1.1 has no Foswiki::Address',
with_dep => 'Foswiki,<,1.2' );
my $addrObj = Foswiki::Address->new( %{ $test->{atoms} } );
my $parsedaddrObj =
Foswiki::Address->new( string => $test->{string} );
Expand Down Expand Up @@ -512,8 +516,6 @@ sub _newAddrTestingWebpathParam {

sub test_meta1 {
my ($this) = @_;
$this->expect_failure( 'Foswiki 1.1 has no Foswiki::Address',
with_dep => 'Foswiki,<,1.2' );
my %constructor = (
web => "$test_web/SubWeb",
topic => 'Topic',
Expand All @@ -535,8 +537,6 @@ sub test_meta1 {

sub test_meta2 {
my ($this) = @_;
$this->expect_failure( 'Foswiki 1.1 has no Foswiki::Address',
with_dep => 'Foswiki,<,1.2' );
my %constructor = (
web => "$test_web/SubWeb",
topic => 'Topic',
Expand Down Expand Up @@ -567,8 +567,6 @@ sub test_meta2 {

sub test_meta3 {
my ($this) = @_;
$this->expect_failure( 'Foswiki 1.1 has no Foswiki::Address',
with_dep => 'Foswiki,<,1.2' );
my %constructor = (
web => "$test_web/SubWeb",
topic => 'Topic',
Expand All @@ -591,8 +589,6 @@ sub test_meta3 {

sub test_meta4 {
my ($this) = @_;
$this->expect_failure( 'Foswiki 1.1 has no Foswiki::Address',
with_dep => 'Foswiki,<,1.2' );
my %constructor = (
web => "$test_web/SubWeb",
topic => 'Topic',
Expand All @@ -615,8 +611,6 @@ sub test_meta4 {

sub test_chain_new_web {
my ($this) = @_;
$this->expect_failure( 'Foswiki 1.1 has no Foswiki::Address',
with_dep => 'Foswiki,<,1.2' );
my $addrObj = Foswiki::Address->new( web => 'Main', topic => 'WebHome' );
my $web = Foswiki::Address->new( web => 'Main', topic => 'WebHome' )->web();

Expand Down Expand Up @@ -662,8 +656,6 @@ sub test_timing_normaliseWebTopicName_default {

sub test_timing_normaliseWebTopicName_equiv {
my ($this) = @_;
$this->expect_failure( 'Foswiki 1.1 has no Foswiki::Address',
with_dep => 'Foswiki,<,1.2' );
my $addr;
my $benchmark = timeit(
10000,
Expand All @@ -682,8 +674,6 @@ sub test_timing_normaliseWebTopicName_equiv {

sub test_timing_normaliseWebTopicName_equiv_default {
my ($this) = @_;
$this->expect_failure( 'Foswiki 1.1 has no Foswiki::Address',
with_dep => 'Foswiki,<,1.2' );
my $addr;
my $benchmark = timeit(
10000,
Expand All @@ -703,8 +693,6 @@ sub test_timing_normaliseWebTopicName_equiv_default {

sub test_timing_creation {
my ($this) = @_;
$this->expect_failure( 'Foswiki 1.1 has no Foswiki::Address',
with_dep => 'Foswiki,<,1.2' );
my $addr;
my $benchmark = timeit(
100000,
Expand Down Expand Up @@ -745,8 +733,6 @@ sub test_timing_hashref_creation {

sub test_timing_reparse_default {
my ($this) = @_;
$this->expect_failure( 'Foswiki 1.1 has no Foswiki::Address',
with_dep => 'Foswiki,<,1.2' );
my $addr =
Foswiki::Address->new( topic => 'Topic', webpath => [qw(Web SubWeb)] );
my $benchmark = timeit(
Expand All @@ -767,8 +753,6 @@ sub test_timing_reparse_default {

sub test_timing_reparse {
my ($this) = @_;
$this->expect_failure( 'Foswiki 1.1 has no Foswiki::Address',
with_dep => 'Foswiki,<,1.2' );
my $addr =
Foswiki::Address->new( topic => 'Topic', webpath => [qw(Web SubWeb)] );
my $benchmark = timeit(
Expand Down Expand Up @@ -799,8 +783,6 @@ sub test_timing_reparse {

sub test_attachment_constructor_tompath {
my ($this) = @_;
$this->expect_failure( 'Foswiki 1.1 has no Foswiki::Address',
with_dep => 'Foswiki,<,1.2' );
my %constructor = (
web => "$test_web/SubWeb",
topic => 'Topic',
Expand All @@ -822,8 +804,6 @@ sub test_attachment_constructor_tompath {

sub test_attachment_constructor {
my ($this) = @_;
$this->expect_failure( 'Foswiki 1.1 has no Foswiki::Address',
with_dep => 'Foswiki,<,1.2' );
my %constructor = (
web => "$test_web/SubWeb",
topic => 'Topic',
Expand All @@ -845,8 +825,6 @@ sub test_attachment_constructor {

sub test_attachment_getsetters {
my ($this) = @_;
$this->expect_failure( 'Foswiki 1.1 has no Foswiki::Address',
with_dep => 'Foswiki,<,1.2' );
my %constructor = (
web => "$test_web/SubWeb",
topic => 'Topic',
Expand Down Expand Up @@ -875,8 +853,6 @@ sub test_attachment_getsetters {

sub test_root {
my ($this) = @_;
$this->expect_failure( 'Foswiki 1.1 has no Foswiki::Address',
with_dep => 'Foswiki,<,1.2' );
my %constructor = ( root => 1 );
my $addrObj = Foswiki::Address->new(%constructor);
my $parsedaddrObj = Foswiki::Address->new( string => "/" );
Expand Down
11 changes: 8 additions & 3 deletions UnitTestContrib/test/unit/AdminOnlyAccessControlTests.pm
Expand Up @@ -8,7 +8,6 @@ use FoswikiFnTestCase();
our @ISA = qw( FoswikiFnTestCase );

use Foswiki ();
use Foswiki::Address ();
use Foswiki::Meta ();
use Foswiki::Plugins ();
use Foswiki::Configure::Dependency();
Expand Down Expand Up @@ -54,6 +53,14 @@ my $MrOrange;
my $MrGreen;
my $MrYellow;

sub skip {
my ( $this, $test ) = @_;

return $this->check_dependency('Foswiki,<,1.2')
? 'Foswiki 1.1 has no Foswiki::Access'
: undef;
}

sub set_up {
my $this = shift;
$this->SUPER::set_up();
Expand Down Expand Up @@ -82,8 +89,6 @@ sub set_up {
THIS
$topicObject->save();
$topicObject->finish();
$this->expect_failure( 'Foswiki 1.1 has no Foswiki::Access',
with_dep => 'Foswiki,<,1.2' );

return;
}
Expand Down
46 changes: 34 additions & 12 deletions UnitTestContrib/test/unit/ConfigureTests.pm
Expand Up @@ -18,6 +18,28 @@ use Foswiki::Configure::Valuer ();
use Foswiki::Configure::UI ();
use Foswiki::Configure::GlobalControls ();

sub skip {
my ( $this, $test ) = @_;

return $this->SUPER::skip_test_if(
$test,
{
condition => { without_dep => 'Archive::Tar' },
tests => {
'ConfigureTests::test_Util_createArchive_perlTar' =>
'Missing Archive::Tar'
}
},
{
condition => { without_dep => 'Archive::Zip' },
tests => {
'ConfigureTests::test_Util_createArchive_perlZip' =>
'Missing Archive::Zip'
}
}
);
}

sub set_up {
my $this = shift;
$this->SUPER::set_up();
Expand Down Expand Up @@ -1744,12 +1766,12 @@ sub test_Util_createArchive_perlTar {
mkpath("$tempdir/$extbkup");
_makePackage( "$tempdir/$extbkup", $extension );

eval { require Archive::Tar; 1; } or do {
my $mess = $@;
$mess =~ s/\(\@INC contains:.*$//s;
$this->expect_failure("CANNOT RUN test for tar archive: $mess");
$this->assert(0);
};
#eval { require Archive::Tar; 1; } or do {
# my $mess = $@;
# $mess =~ s/\(\@INC contains:.*$//s;
# $this->expect_failure("CANNOT RUN test for tar archive: $mess");
# $this->assert(0);
#};

( $file, $rslt ) =
Foswiki::Configure::Util::createArchive( "$extbkup", "$tempdir", '0',
Expand Down Expand Up @@ -1787,12 +1809,12 @@ sub test_Util_createArchive_perlZip {
mkpath("$tempdir/$extbkup");
_makePackage( "$tempdir/$extbkup", $extension );

eval { require Archive::Zip; 1; } or do {
my $mess = $@;
$mess =~ s/\(\@INC contains:.*$//s;
$this->expect_failure("CANNOT RUN test for zip archive: $mess");
$this->assert(0);
};
#eval { require Archive::Zip; 1; } or do {
# my $mess = $@;
# $mess =~ s/\(\@INC contains:.*$//s;
# $this->expect_failure("CANNOT RUN test for zip archive: $mess");
# $this->assert(0);
#};

( $file, $rslt ) =
Foswiki::Configure::Util::createArchive( "$extbkup", "$tempdir", '0',
Expand Down
30 changes: 8 additions & 22 deletions UnitTestContrib/test/unit/Fn_SEARCH.pm
Expand Up @@ -1661,17 +1661,10 @@ sub verify_formQuery3 {
sub verify_formQuery4 {
my $this = shift;

if (
( $Foswiki::cfg{OS} eq 'WINDOWS' )
and ( $Foswiki::cfg{DetailedOS} ne 'cygwin' )
and ( $Foswiki::cfg{Store}{SearchAlgorithm} eq
'Foswiki::Store::SearchAlgorithms::Forking' )
)
{
$this->expect_failure();
$this->annotate(
"THIS IS WINDOWS & grep; Test will fail because of Item1072");
}
$this->expect_failure(
"THIS IS WINDOWS & grep; Test will fail because of Item1072",
using => [ 'PlatformWindows', 'SearchAlgorithmForking' ]
);

$this->set_up_for_queries();

Expand All @@ -1686,17 +1679,10 @@ sub verify_formQuery4 {
sub verify_formQuery5 {
my $this = shift;

if (
( $Foswiki::cfg{OS} eq 'WINDOWS' )
and ( $Foswiki::cfg{DetailedOS} ne 'cygwin' )
and ( $Foswiki::cfg{Store}{SearchAlgorithm} eq
'Foswiki::Store::SearchAlgorithms::Forking' )
)
{
$this->expect_failure();
$this->annotate(
"THIS IS WINDOWS & grep; Test will fail because of Item1072");
}
$this->expect_failure(
"THIS IS WINDOWS & grep; Test will fail because of Item1072",
using => [ 'PlatformWindows', 'SearchAlgorithmForking' ]
);

$this->set_up_for_queries();

Expand Down
17 changes: 15 additions & 2 deletions UnitTestContrib/test/unit/FormattingTests.pm
Expand Up @@ -114,6 +114,21 @@ sub new {
return $self;
}

sub skip {
my ( $this, $test ) = @_;

return $this->SUPER::skip_test_if(
$test,
{
condition => { with_dep => 'Foswiki,<,1.2' },
tests => {
'FormattingTests::test_lists' =>
'Post-Foswiki 1.1.x TML syntax',
}
}
);
}

sub set_up {
my $this = shift;

Expand Down Expand Up @@ -1311,8 +1326,6 @@ None
: Sunny
Pleasant
ACTUAL
$this->expect_failure( 'Post-Foswiki 1.1.x TML syntax',
with_dep => 'Foswiki,<,1.2' );
$this->do_test( $expected, $actual );
}

Expand Down
17 changes: 15 additions & 2 deletions UnitTestContrib/test/unit/HoistREsTests.pm
Expand Up @@ -11,6 +11,21 @@ use Foswiki::Query::HoistREs;
use Foswiki::Query::Node;
use Foswiki::Meta;

sub skip {
my ( $this, $test ) = @_;

return $this->SUPER::skip_test_if(
$test,
{
condition => { with_dep => 'Foswiki,<,1.2' },
tests => {
'HoistREsTests::test_hoist_mixed_or' =>
'n-ary query nodes are Foswiki 1.2+ only',
}
}
);
}

sub set_up {
my $this = shift;
$this->SUPER::set_up();
Expand Down Expand Up @@ -532,8 +547,6 @@ sub test_hoist_mixed_or {
my $query = $queryParser->parse($s);

my $filter = $this->_hoist($query);
$this->expect_failure( 'n-ary query nodes are Foswiki 1.2+ only',
with_dep => 'Foswiki,<,1.2' );
$this->assert_num_equals( 0, $this->_getFilterNumElements($filter) );
}

Expand Down

0 comments on commit 944c324

Please sign in to comment.