modify test to skip unreadable file test if user is root

This commit is contained in:
Colin Kuskie 2006-08-11 00:34:44 +00:00
parent 3bab20fb62
commit b2340842a0

View file

@ -33,10 +33,7 @@ $storage->addFileFromScalar('goodFile', $goodFile);
$storage->addFileFromScalar('twoLines', $twoLines);
$storage->addFileFromScalar('unreadableFile', 'The contents of this file are not readable');
my $unreadable = $storage->getPath('unreadableFile');
diag(sprintf "original mode: %o", (stat $unreadable)[2]);
chmod(0111, $unreadable) or
diag("Unable to chmod file.");
diag(sprintf "modified mode: %o", (stat $unreadable)[2]);
chmod(0111, $unreadable);
my @testSets = (
{
@ -79,11 +76,6 @@ my @testSets = (
output => $i18n->get('not found'),
comment => q|Non-existant file returns NOT FOUND|,
},
{
file => $storage->getPath('unreadableFile'),
output => $i18n->get('not found'),
comment => q|Unreadable file returns NOT FOUND|,
},
{
file => $storage->getPath('goodFile'),
output => $goodFile,
@ -99,6 +91,7 @@ my @testSets = (
my $numTests = scalar @testSets;
$numTests += 1; #For the use_ok
$numTests += 1; #For the unreadable file test
plan tests => $numTests;
@ -111,13 +104,19 @@ skip "Unable to load $macro", $numTests-1 unless $loaded;
foreach my $testSet (@testSets) {
my $output = WebGUI::Macro::Include::process($session, $testSet->{file});
my $passed = is($output, $testSet->{output}, $testSet->{comment} . ":" .$testSet->{file});
is($output, $testSet->{output}, $testSet->{comment} . ":" .$testSet->{file});
}
SKIP: {
skip "Root will cause this test to fail since it does not obey file permissions", 1
if $< == 0;
my $file = $storage->getPath('unreadableFile');
my $output = WebGUI::Macro::Include::process($session, $file);
is($output, $i18n->get('not found'), q|Unreadable file returns NOT FOUND|. ":" .$file);
}
}
diag(sprintf "post test mode: %o", (stat $unreadable)[2]);
END {
$storage->delete;
}