Subject: | Test::Dir addtions like Test::File |
In order to "align" Test::Dir with Test::File conventions I suggest the
following additions.
dir_empty_ok (I guess readdir(less "." and "..") = 0 but not sure how
portable)
dir_readable_ok (both -d and -r)
dir_writable_ok (both -d and -w)
dir_executable_ok (both -d and -x)
dir_not_empty_ok (I guess readdir(less "." and "..") > 0 but not sure
how portable)
dir_not_readable_ok (both -d and !-r)
dir_not_writable_ok (both -d and !-w)
dir_not_executable_ok (both -d and !-x)
I personally would super class Test::Dir and Test::Folder as the code
is identical between the two.
e.g.
package Test::Dir::Base;
dir_subs...
*folder_subX=\&dir_subX;
export nothing
package Test::Dir;
use base qw{Test::Dir::Base};
export :dir group
package Test::Folder;
use base qw{Test::Dir::Base};
export :folder group
From: http://arstechnica.com/civis/viewtopic.php?f=20&t=290481
sub dir_is_empty
{
my ($path) = @_;
opendir DIR, $path;
while(my $entry = readdir DIR) {
next if($entry =~ /^\.\.?$/);
closedir DIR;
return 0;
}
closedir DIR;
return 1;
}