summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTony Cook <tony@develop-help.com>2017-01-09 17:02:38 +1100
committerTony Cook <tony@develop-help.com>2017-09-11 10:59:44 +1000
commit977bd6d625ba53702249ae8c80cede962e6402b5 (patch)
tree405eca073c19909d464ce837c26f7cd01cb73e0d
parent733612e0500c5f8f8dfedaa93a56d04d4f9c1930 (diff)
downloadperl-977bd6d625ba53702249ae8c80cede962e6402b5.tar.gz
(perl #127663) test chdir() within an in-place edit loop
-rw-r--r--t/run/switches.t24
1 files changed, 23 insertions, 1 deletions
diff --git a/t/run/switches.t b/t/run/switches.t
index 86c9dcb54a..79a5fa7dbf 100644
--- a/t/run/switches.t
+++ b/t/run/switches.t
@@ -12,7 +12,7 @@ BEGIN {
BEGIN { require "./test.pl"; require "./loc_tools.pl"; }
-plan(tests => 124);
+plan(tests => 127);
use Config;
@@ -462,6 +462,28 @@ __EOF__
close $f;
is(join(":", @file4), "bar:bar", "check output");
+ SKIP:
+ {
+ # this needs to match how ARGV_USE_ATFUNCTIONS is defined in doio.c
+ skip "Not enough *at functions", 3
+ unless $Config{d_unlinkat} && $Config{d_renameat} && $Config{d_fchmodat}
+ && ($Config{d_dirfd} || $Config{d_dir_dd_fd})
+ && $Config{ccflags} !~ /-DNO_USE_ATFUNCTIONS\b/;
+ fresh_perl_is(<<'CODE', "ok\n", { },
+@ARGV = ("inplacetmp/foo");
+$^I = "";
+while (<>) {
+ chdir "..";
+ print "xx\n";
+}
+print "ok\n";
+CODE
+ "chdir while in-place editing");
+ ok(open(my $fh, "<", $work), "open out file");
+ is(scalar <$fh>, "xx\n", "file successfully saved after chdir");
+ close $fh;
+ }
+
unlink $work;
# we now use temp files for in-place editing, make sure we didn't leave