1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
use Test::More tests => 8;
BEGIN {
our $getpwuid_should_die = 0;
our $getgrgid_should_die = 0;
};
BEGIN{
no warnings;
*CORE::GLOBAL::getpwuid = sub ($) { die "Fred" if $getpwuid_should_die };
*CORE::GLOBAL::getgrgid = sub ($) { die "Barney" if $getgrgid_should_die };
}
use_ok( 'Test::File' );
ok( defined &{ "Test::File::_obviously_non_multi_user" }, "_win32 defined" );
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# The ones that we know aren't multi-user
{
local $^O = 'MacOS';
ok( Test::File::_obviously_non_multi_user(), "Returns false for MacOS" );
}
{
local $^O = 'dos';
ok( Test::File::_obviously_non_multi_user(), "Returns true for Win32" );
}
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# The ones that use get*, but die
{
local $^O = 'Fooey';
$getpwuid_should_die = 1;
$getgrgid_should_die = 0;
ok( Test::File::_obviously_non_multi_user(), 'getpwuid dying returns true' );
}
{
local $^O = 'Fooey';
$getpwuid_should_die = 0;
$getgrgid_should_die = 1;
ok( Test::File::_obviously_non_multi_user(), 'getgrgid dying returns true' );
}
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# The ones that use get*, but don't die
{
local $^O = 'Fooey';
$getpwuid_should_die = 0;
$getgrgid_should_die = 0;
ok( ! Test::File::_obviously_non_multi_user(), 'getpwuid dying returns true' );
}
{
local $^O = 'Fooey';
$getpwuid_should_die = 0;
$getgrgid_should_die = 0;
ok( ! Test::File::_obviously_non_multi_user(), 'getgrgid dying returns true' );
}
|