Skip to content

Commit

Permalink
fix bad call prior to prereq
Browse files Browse the repository at this point in the history
  • Loading branch information
rpcme committed Aug 3, 2015
1 parent 157ec48 commit 7cf53b2
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions t/Path_root.t
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@ use FilePathTest;
use File::Path qw(rmtree mkpath make_path remove_tree);
use File::Spec::Functions;


my $prereq = prereq();
plan skip_all => $prereq if defined $prereq;
plan tests => 8;

my $pwent = max_u();
my $grent = max_g();
my ( $max_uid, $max_user ) = @{ $pwent };
my ( $max_gid, $max_group ) = @{ $grent };

my $prereq = prereq($max_uid, $max_gid);
plan skip_all => $prereq if defined $prereq;
plan tests => 8;

my $tmp_base = catdir(
curdir(),
sprintf( 'test-%x-%x-%x', time, $$, rand(99999) ),
Expand Down Expand Up @@ -106,11 +107,16 @@ sub max_g {
}

sub prereq {
my ( $max_uid, $max_gid ) = @_;
return "getpwent() not implemented on $^O" unless $Config{d_getpwent};
return "getgrent() not implemented on $^O" unless $Config{d_getgrent};
return "not running as root" unless $< == 0;
return "darwin's nobody and nogroup are -1 or -2" if $^O eq 'darwin';

my $pwent = max_u();
my $grent = max_g();
my ( $max_uid, $max_user ) = @{ $pwent };
my ( $max_gid, $max_group ) = @{ $grent };

return "getpwent() appears to be insane" unless $max_uid > 0;
return "getgrent() appears to be insane" unless $max_gid > 0;
return undef;
Expand Down

0 comments on commit 7cf53b2

Please sign in to comment.