summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2014-03-02 15:36:52 +0100
committerNicholas Clark <nick@ccl4.org>2014-03-19 10:57:52 +0100
commit0c9de5b7970eafe06ebc3a92f5f24b972581372d (patch)
treea37f04641c4f85344b650d2a5e48ed0d8ca69382
parentf5957b2f8fe72d02f44bba1d1da1eb1dc6c5c6ae (diff)
downloadperl-0c9de5b7970eafe06ebc3a92f5f24b972581372d.tar.gz
Tests that warnings are emitted if in-place edit fails to open a pathname.
These have the same text as other warnings which are tested. However the existing tests only covered the code path where a directory was able to be opened (read only) and then caught by an explicit stat test for non-files.
-rw-r--r--t/lib/warnings/doio26
1 files changed, 20 insertions, 6 deletions
diff --git a/t/lib/warnings/doio b/t/lib/warnings/doio
index bf0cd780c1..63250e156c 100644
--- a/t/lib/warnings/doio
+++ b/t/lib/warnings/doio
@@ -209,31 +209,45 @@ EXPECT
########
# doio.c [Perl_nextargv]
$^W = 0 ;
+# These happen to warn at different points within doio.c
+# This will open read only, and then be caught by an explicit check:
my $filename = "./temp.dir" ;
+# Whereas these two will fail to open:
+my $dir0 = "./zero.dir" ;
+# but files and directories have a different error message if they don't open:
+my $file3 = "date|" ;
mkdir $filename, 0777
or die "Cannot create directory $filename: $!\n" ;
+mkdir $dir0, 0
+ or die "Cannot create directory dir0: $!\n" ;
{
- local (@ARGV) = ($filename) ;
+ local (@ARGV) = ($filename, $dir0, $file3) ;
local ($^I) = "" ;
my $x = <> ;
}
{
no warnings 'inplace' ;
- local (@ARGV) = ($filename) ;
+ local (@ARGV) = ($filename, $dir0, $file3) ;
local ($^I) = "" ;
my $x = <> ;
}
{
use warnings 'inplace' ;
- local (@ARGV) = ($filename) ;
+ local (@ARGV) = ($filename, $dir0, $file3) ;
local ($^I) = "" ;
my $x = <> ;
}
rmdir $filename ;
+chmod 0777, $dir0 ;
+rmdir $dir0 ;
EXPECT
-Can't do inplace edit: ./temp.dir is not a regular file at - line 9.
-Can't do inplace edit: ./temp.dir is not a regular file at - line 21.
-
+OPTION regex
+Can't do inplace edit: \./temp\.dir is not a regular file at - line 17\.
+Can't do inplace edit: \./zero\.dir is not a regular file at - line 17\.
+Can't open date\|: .*? at - line 17\.
+Can't do inplace edit: \./temp\.dir is not a regular file at - line 29\.
+Can't do inplace edit: \./zero\.dir is not a regular file at - line 29\.
+Can't open date\|: .*? at - line 29\.
########
# doio.c [Perl_do_eof]
use warnings 'io' ;