Skip to content

Commit

Permalink
Item8640: expect_failure must be followed by a failing test, otherwis…
Browse files Browse the repository at this point in the history
…e it's useless, so adding a ->assert(0) to force it to fail

Btw, this mechanism is a bit odd to me. Why use ->annotate($comment), then assert(0), and not directly ->assert(0, $comment)?
Yes, we get the full trace, but what's the point?

git-svn-id: http://svn.foswiki.org/trunk@7294 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
OlivierRaginel authored and OlivierRaginel committed Apr 30, 2010
1 parent 5967d4e commit a1db4d1
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions UnitTestContrib/test/unit/ConfigureTests.pm
Expand Up @@ -726,23 +726,20 @@ sub test_Util_listDir {
my $stdout = '';
my $stderr = '';

eval 'use Capture::Tiny';
eval 'use Capture::Tiny qw/capture/';
if ($@) {
my $mess = $@;
$mess =~ s/\(\@INC contains:.*$//s;
$this->expect_failure();
$this->annotate(
"CANNOT RUN listDir test for illegal file names: $mess");
$this->assert(0);
}
else {
eval 'use Capture::Tiny qw/capture/;
($stdout, $stderr) = capture {
@dir= Foswiki::Configure::Util::listDir("$tempdir") ;
};
$this->assert_str_equals( "WARNING: skipping possibly unsafe file (not able to show it for the same reason :( )<br />\n", $stdout );
$this->assert_num_equals( 3, $count, "listDir returned incorrect number of directories");
';
}
($stdout, $stderr) = capture {
@dir= Foswiki::Configure::Util::listDir("$tempdir") ;
};
$this->assert_str_equals( "WARNING: skipping possibly unsafe file (not able to show it for the same reason :( )<br />\n", $stdout );
$this->assert_num_equals( 3, $count, "listDir returned incorrect number of directories");

rmtree($tempdir);

Expand Down Expand Up @@ -1357,13 +1354,12 @@ sub test_Util_createArchive {
$this->expect_failure();
$this->annotate(
"CANNOT RUN test for zip archive: $mess");
$this->assert(0);
}
else {
($file, $rslt) = Foswiki::Configure::Util::createArchive( "$extbkup", "$tempdir", '1', 'Pzip');
$this->assert( (-f $file), "$file does not appear to exist - Create Archive::Zip archive");
}
($file, $rslt) = Foswiki::Configure::Util::createArchive( "$extbkup", "$tempdir", '1', 'Pzip');
$this->assert( (-f $file), "$file does not appear to exist - Create Archive::Zip archive");

rmtree("$tempdir/$extbkup"); # Clean up old files if left behind
unlink "$tempdir/$extbkup"; # Clean up old files if left behind
}

#
Expand Down

0 comments on commit a1db4d1

Please sign in to comment.