16fb12b70Safresh1use strict; 26fb12b70Safresh1use Test::More tests => 8; 36fb12b70Safresh1 46fb12b70Safresh1# Grab all of the plain routines from File::Spec 56fb12b70Safresh1use File::Spec; 66fb12b70Safresh1use File::Spec::Win32; 76fb12b70Safresh1 86fb12b70Safresh1require_ok($_) foreach qw(File::Spec File::Spec::Win32); 96fb12b70Safresh1 106fb12b70Safresh1 116fb12b70Safresh1if ($^O eq 'VMS') { 126fb12b70Safresh1 # hack: 136fb12b70Safresh1 # Need to cause the %ENV to get populated or you only get the builtins at 146fb12b70Safresh1 # first, and then something else can cause the hash to get populated. 156fb12b70Safresh1 my %look_env = %ENV; 166fb12b70Safresh1} 176fb12b70Safresh1my $num_keys = keys %ENV; 186fb12b70Safresh1File::Spec->tmpdir; 196fb12b70Safresh1is scalar keys %ENV, $num_keys, "tmpdir() shouldn't change the contents of %ENV"; 206fb12b70Safresh1 216fb12b70Safresh1SKIP: { 226fb12b70Safresh1 skip("Can't make list assignment to %ENV on this system", 1) 236fb12b70Safresh1 if $^O eq 'VMS'; 246fb12b70Safresh1 256fb12b70Safresh1 local %ENV; 266fb12b70Safresh1 File::Spec::Win32->tmpdir; 276fb12b70Safresh1 is(scalar keys %ENV, 0, "Win32->tmpdir() shouldn't change the contents of %ENV"); 286fb12b70Safresh1} 296fb12b70Safresh1 306fb12b70Safresh1File::Spec::Win32->tmpdir; 316fb12b70Safresh1is(scalar keys %ENV, $num_keys, "Win32->tmpdir() shouldn't change the contents of %ENV"); 326fb12b70Safresh1 336fb12b70Safresh1# Changing tmpdir dynamically 346fb12b70Safresh1for ('File::Spec', "File::Spec::Win32") { 356fb12b70Safresh1 SKIP: { 366fb12b70Safresh1 skip('sys$scratch: takes precedence over env on vms', 1) 376fb12b70Safresh1 if $^O eq 'VMS'; 386fb12b70Safresh1 local $ENV{TMPDIR} = $_->catfile($_->curdir, 'lib'); 396fb12b70Safresh1 -d $ENV{TMPDIR} && -w _ 406fb12b70Safresh1 or skip "Can't create usable TMPDIR env var", 1; 416fb12b70Safresh1 my $tmpdir1 = $_->tmpdir; 426fb12b70Safresh1 $ENV{TMPDIR} = $_->catfile($_->curdir, 't'); 436fb12b70Safresh1 -d $ENV{TMPDIR} && -w _ 446fb12b70Safresh1 or skip "Can't create usable TMPDIR env var", 1; 456fb12b70Safresh1 my $tmpdir2 = $_->tmpdir; 46*f2a19305Safresh1 isnt $tmpdir2, $tmpdir1, "$_->tmpdir works with changing env"; 476fb12b70Safresh1 } 486fb12b70Safresh1} 496fb12b70Safresh1 506fb12b70Safresh1ok( 516fb12b70Safresh1 File::Spec->file_name_is_absolute(File::Spec->tmpdir()), 526fb12b70Safresh1 "tmpdir() always returns an absolute path" 536fb12b70Safresh1); 54