Debian Codegraph @

t/02_renamed.t

raw symbols SCIP
1 use strict;
2 use warnings;
3 use Test::More;
4
5 use Cwd qw/getcwd/;
6 use Cwd::Guard qw/cwd_guard/;
7 use File::Temp qw/tempdir/;
8
9 use Test::Requires qw/File::Spec::Link/;
10
11 plan skip_all => "Safe renames only possible with fchdir"
12 if !Cwd::Guard::USE_FCHDIR;
13
14 my $tempdir_path = tempdir(CLEANUP => 1);
15 my $tempdir = File::Spec::Link->resolve_path($tempdir_path);
16
17 my $olddir = "$tempdir/foo";
18 my $newdir = "$tempdir/bla";
19 mkdir $olddir;
20 chdir $olddir or die $!;
21 {
22 my $guard = cwd_guard $tempdir;
23 rename $olddir, $newdir or die $!;
24 }
25
26 is getcwd, $newdir, 'can change back to renamed directory';
27
28 chdir '/'; # so tempdir can do a cleanup
29
30 done_testing;
31
32 __END__