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 62 63 64 65 66 67 68 69
|
# t/06_Win32.t
use strict;
use warnings;
use Test::More;
if( $^O !~ /Win32/ ) {
plan skip_all => 'Test irrelevant except on Win32';
} else {
plan qw(no_plan);
}
like($^O, qr/Win32/, "You're on Windows -- the greatest operating system to come out of Redmond, Washington!");
SKIP: {
eval { require File::HomeDir };
skip "File::HomeDir not found",
14 if $@;
use_ok('File::Save::Home', qw|
get_subhome_directory_status
make_subhome_temp_directory
| );
use_ok('File::Temp', qw| tempdir |);
use_ok('Cwd');
use_ok ( 'String::Random', qw(random_regex) );
*make_varname = sub { return random_regex(q([a-z]{10})) };
my ($cwd, $pseudohome, $desired_dir_ref );
$cwd = cwd();
ok($pseudohome = File::HomeDir->my_home(),
'pseudo-home directory has been created');
ok(chdir $pseudohome, "able to change to $pseudohome");
$desired_dir_ref = get_subhome_directory_status(
make_varname(),
$pseudohome,
);
ok(! defined $desired_dir_ref->{flag},
"random directory name $desired_dir_ref->{abs} is undefined");
ok(chdir $cwd, "able to change to $cwd");
eval {
$desired_dir_ref = get_subhome_directory_status(
make_varname(),
make_varname(),
);
};
like($@, qr/is\snot\sa\svalid\sdirectory/,
"optional second argument must be a valid directory");
my ($newpseudohome, $tmpdir);
ok($newpseudohome = File::HomeDir->my_home(),
'another pseudo-home directory has been created');
ok(chdir $newpseudohome, "able to change to $newpseudohome");
$tmpdir = make_subhome_temp_directory($newpseudohome);
ok( (-d $tmpdir), "$tmpdir exists");
ok(chdir $cwd, "able to change to $cwd");
eval {
$tmpdir = make_subhome_temp_directory(make_varname());
};
like($@, qr/is\snot\sa\svalid\sdirectory/,
"optional argument must be a valid directory");
}
|