1use strict; 2use Test::More tests => 8; 3 4# Grab all of the plain routines from File::Spec 5use File::Spec; 6use File::Spec::Win32; 7 8require_ok($_) foreach qw(File::Spec File::Spec::Win32); 9 10 11if ($^O eq 'VMS') { 12 # hack: 13 # Need to cause the %ENV to get populated or you only get the builtins at 14 # first, and then something else can cause the hash to get populated. 15 my %look_env = %ENV; 16} 17my $num_keys = keys %ENV; 18File::Spec->tmpdir; 19is scalar keys %ENV, $num_keys, "tmpdir() shouldn't change the contents of %ENV"; 20 21SKIP: { 22 skip("Can't make list assignment to %ENV on this system", 1) 23 if $^O eq 'VMS'; 24 25 local %ENV; 26 File::Spec::Win32->tmpdir; 27 is(scalar keys %ENV, 0, "Win32->tmpdir() shouldn't change the contents of %ENV"); 28} 29 30File::Spec::Win32->tmpdir; 31is(scalar keys %ENV, $num_keys, "Win32->tmpdir() shouldn't change the contents of %ENV"); 32 33# Changing tmpdir dynamically 34for ('File::Spec', "File::Spec::Win32") { 35 SKIP: { 36 skip('sys$scratch: takes precedence over env on vms', 1) 37 if $^O eq 'VMS'; 38 local $ENV{TMPDIR} = $_->catfile($_->curdir, 'lib'); 39 -d $ENV{TMPDIR} && -w _ 40 or skip "Can't create usable TMPDIR env var", 1; 41 my $tmpdir1 = $_->tmpdir; 42 $ENV{TMPDIR} = $_->catfile($_->curdir, 't'); 43 -d $ENV{TMPDIR} && -w _ 44 or skip "Can't create usable TMPDIR env var", 1; 45 my $tmpdir2 = $_->tmpdir; 46 isn't $tmpdir2, $tmpdir1, "$_->tmpdir works with changing env"; 47 } 48} 49 50ok( 51 File::Spec->file_name_is_absolute(File::Spec->tmpdir()), 52 "tmpdir() always returns an absolute path" 53); 54