From a167731a931fc9b31b6dceac9d29f9a9ce5f3963 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Tue, 7 Oct 2008 23:21:35 +0000 Subject: [PATCH] begin guardbanding the test to survive being run by root --- t/Asset/AssetExportHtml.t | 53 +++++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/t/Asset/AssetExportHtml.t b/t/Asset/AssetExportHtml.t index 4e2d203e9..714e503df 100644 --- a/t/Asset/AssetExportHtml.t +++ b/t/Asset/AssetExportHtml.t @@ -102,32 +102,37 @@ cmp_deeply( my $tempDirectory = tempdir('webguiXXXXX', CLEANUP => 1); my $inaccessibleDirectory = Path::Class::Dir->new($tempDirectory, 'unwritable'); -chmod 0000, $tempDirectory; -$config->set('exportPath', $inaccessibleDirectory->stringify); -eval { WebGUI::Asset->exportCheckPath($session) }; -$e = Exception::Class->caught(); -isa_ok($e, 'WebGUI::Error', "exportCheckPath throws if it can't create the directory it needs"); -cmp_deeply( - $e, - methods( - error => "can't create exportPath $inaccessibleDirectory", - ), - "exportCheckPath throws if it can't create the directory it needs" -); + SKIP: { + skip 'Root will cause this test to fail since it does not obey file permissions', 4 + if $< == 0; + chmod 0000, $tempDirectory; + $config->set('exportPath', $inaccessibleDirectory->stringify); -chmod 0444, $tempDirectory; -$config->set('exportPath', $tempDirectory); -eval { WebGUI::Asset->exportCheckPath($session) }; -$e = Exception::Class->caught(); -isa_ok($e, 'WebGUI::Error', "exportCheckPath throws if it can't access the exportPath for writing"); -cmp_deeply( - $e, - methods( - error => "can't access $tempDirectory", - ), - "exportCheckPath throws if we can't access the exportPath" -); + eval { WebGUI::Asset->exportCheckPath($session) }; + $e = Exception::Class->caught(); + isa_ok($e, 'WebGUI::Error', "exportCheckPath throws if it can't create the directory it needs"); + cmp_deeply( + $e, + methods( + error => "can't create exportPath $inaccessibleDirectory", + ), + "exportCheckPath throws if it can't create the directory it needs" + ); + + chmod 0444, $tempDirectory; + $config->set('exportPath', $tempDirectory); + eval { WebGUI::Asset->exportCheckPath($session) }; + $e = Exception::Class->caught(); + isa_ok($e, 'WebGUI::Error', "exportCheckPath throws if it can't access the exportPath for writing"); + cmp_deeply( + $e, + methods( + error => "can't access $tempDirectory", + ), + "exportCheckPath throws if we can't access the exportPath" + ); + } # we're finished making sure that the code explodes on bad stuff, so let's make # sure that it really works when it's really supposed to.