summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-12-03 15:02:10 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-12-03 15:02:10 +0000
commit227cc42e85e067f1349025f1e906ccbab7b78eba (patch)
treea2a537707ea9382fc976f642e5ab6ce95e9d4c1e /test
parentd8d89a07ed7b223e81bdb8937a5ba4479968c578 (diff)
downloadruby-227cc42e85e067f1349025f1e906ccbab7b78eba.tar.gz
ruby-227cc42e85e067f1349025f1e906ccbab7b78eba.tar.xz
ruby-227cc42e85e067f1349025f1e906ccbab7b78eba.zip
* process.c (EXEC_OPTION_DUP2_CHILD): defined.
(check_exec_redirect_fd): check :in, :out and :err. (check_exec_redirect): check [:child, fd]. (check_exec_fds): validate EXEC_OPTION_DUP2_CHILD array. (run_exec_dup2_child): new function. (rb_run_exec_options): call run_exec_dup2_child. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@20470 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_process.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/ruby/test_process.rb b/test/ruby/test_process.rb
index a77773db2..827dde484 100644
--- a/test/ruby/test_process.rb
+++ b/test/ruby/test_process.rb
@@ -415,6 +415,26 @@ class TestProcess < Test::Unit::TestCase
}
end
+ def test_execopts_redirect_dup2_child
+ with_tmpchdir {|d|
+ Process.wait spawn(RUBY, "-e", "STDERR.print 'err'; STDOUT.print 'out'", STDOUT=>"out", STDERR=>[:child, STDOUT])
+ assert_equal("errout", File.read("out"))
+ Process.wait spawn(RUBY, "-e", "STDERR.print 'err'; STDOUT.print 'out'", STDERR=>"out", STDOUT=>[:child, STDERR])
+ assert_equal("errout", File.read("out"))
+
+ IO.popen([RUBY, "-e", "STDERR.print 'err'; STDOUT.print 'out'", STDERR=>[:child, STDOUT]]) {|io|
+ assert_equal("errout", io.read)
+ }
+
+ assert_raise(ArgumentError) {
+ Process.wait spawn(*TRUECOMMAND, STDOUT=>[:child, STDOUT])
+ }
+ assert_raise(ArgumentError) {
+ Process.wait spawn(*TRUECOMMAND, STDOUT=>[:child, 3])
+ }
+ }
+ end
+
def test_execopts_exec
with_tmpchdir {|d|
write_file("s", 'exec "echo aaa", STDOUT=>"foo"')