Test that IPC::Open{2,3} correctly fault read-only file-handle parameters.
authorNicholas Clark <nick@ccl4.org>
Mon, 6 Jun 2011 11:40:40 +0000 (13:40 +0200)
committerNicholas Clark <nick@ccl4.org>
Mon, 6 Jun 2011 19:58:43 +0000 (21:58 +0200)
ext/IPC-Open2/t/IPC-Open2.t
ext/IPC-Open3/t/IPC-Open3.t

index c0ea920..fecb209 100644 (file)
@@ -16,7 +16,7 @@ BEGIN {
 
 use strict;
 use IPC::Open2;
-use Test::More tests => 14;
+use Test::More tests => 15;
 
 my $perl = $^X;
 
@@ -55,3 +55,7 @@ is($?, 0, '$? should be zero');
     main::is($reaped_pid, $pid, "Reaped PID matches");
     main::is($?, 0, '$? should be zero');
 }
+
+$pid = eval { open2('READ', '', $perl, '-e', cmd_line('print scalar <STDIN>')) };
+like($@, qr/^open2: Modification of a read-only value attempted at /,
+     'open2 faults read-only parameters correctly') or do {waitpid $pid, 0};
index 8ff4100..09c44d7 100644 (file)
@@ -14,7 +14,7 @@ BEGIN {
 }
 
 use strict;
-use Test::More tests => 24;
+use Test::More tests => 25;
 
 use IO::Handle;
 use IPC::Open3;
@@ -157,3 +157,7 @@ if (IPC::Open3::DO_SPAWN) {
 } else {
     isnt($@, '') or do {waitpid $pid, 0};
 }
+
+$pid = eval { open3 'WRITE', '', 'ERROR', '/non/existent/program'; };
+like($@, qr/^open3: Modification of a read-only value attempted at /,
+     'open3 faults read-only parameters correctly') or do {waitpid $pid, 0};