diff options
author | Tony Cook <tony@develop-help.com> | 2017-01-12 13:51:01 +1100 |
---|---|---|
committer | Tony Cook <tony@develop-help.com> | 2017-09-11 10:59:44 +1000 |
commit | 83419aa9e098e2540d02ab10d5923186289189ef (patch) | |
tree | 03753c85540434eac3a0151d98896cf94b53b27d /t/run | |
parent | 5a39f542c649762dfe5caedbe1643bdb8a6b3d84 (diff) | |
download | perl-83419aa9e098e2540d02ab10d5923186289189ef.tar.gz |
(perl #127663) test we fail if the backup rename fails
and that we clean up the temp file
Diffstat (limited to 't/run')
-rw-r--r-- | t/run/switches.t | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/t/run/switches.t b/t/run/switches.t index 951f8e0469..7b1db0331c 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 => 133); +plan(tests => 134); use Config; @@ -537,6 +537,21 @@ CODE close $fh; } + { + # test we handle the rename to the backup failing + # make it fail by creating a directory of the backup name + mkdir "$work.bak" or die "Cannot make mask backup directory: $!"; + fresh_perl_like(<<'CODE', qr/Can't rename/, { stderr => 1 }, "fail backup rename"); +@ARGV = ("inplacetmp/foo"); +$^I = ".bak"; +while (<>) { + print; +} +print "ok\n"; +CODE + rmdir "$work.bak" or die "Cannot remove mask backup directory: $!"; + } + unlink $work; # we now use temp files for in-place editing, make sure we didn't leave |