This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Upgrade Scalar-List-Utils from version 1.37 to 1.38
[perl5.git] / dist / PathTools / t / tmpdir.t
CommitLineData
9d5071ba 1use strict;
82730d4c 2use Test::More tests => 7;
9d5071ba
SP
3
4# Grab all of the plain routines from File::Spec
5use File::Spec;
6use File::Spec::Win32;
7
cba09117 8require_ok($_) foreach qw(File::Spec File::Spec::Win32);
9d5071ba 9
9d5071ba 10
ae5a807c
JM
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}
9d5071ba
SP
17my $num_keys = keys %ENV;
18File::Spec->tmpdir;
cba09117 19is scalar keys %ENV, $num_keys, "tmpdir() shouldn't change the contents of %ENV";
9d5071ba 20
cba09117
NC
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");
dfa4e5d3
RGS
28}
29
9d5071ba 30File::Spec::Win32->tmpdir;
cba09117 31is(scalar keys %ENV, $num_keys, "Win32->tmpdir() shouldn't change the contents of %ENV");
82730d4c
FC
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}