From a1157350ae411d923510ca14680a1b297263bf26 Mon Sep 17 00:00:00 2001 From: Nicholas Clark Date: Mon, 6 Jun 2011 13:40:40 +0200 Subject: [PATCH] Test that IPC::Open{2,3} correctly fault read-only file-handle parameters. --- ext/IPC-Open2/t/IPC-Open2.t | 6 +++++- ext/IPC-Open3/t/IPC-Open3.t | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ext/IPC-Open2/t/IPC-Open2.t b/ext/IPC-Open2/t/IPC-Open2.t index c0ea920..fecb209 100644 --- a/ext/IPC-Open2/t/IPC-Open2.t +++ b/ext/IPC-Open2/t/IPC-Open2.t @@ -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 ')) }; +like($@, qr/^open2: Modification of a read-only value attempted at /, + 'open2 faults read-only parameters correctly') or do {waitpid $pid, 0}; diff --git a/ext/IPC-Open3/t/IPC-Open3.t b/ext/IPC-Open3/t/IPC-Open3.t index 8ff4100..09c44d7 100644 --- a/ext/IPC-Open3/t/IPC-Open3.t +++ b/ext/IPC-Open3/t/IPC-Open3.t @@ -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}; -- 2.7.4