From 30b8f1ee2be229690c27e61e451c1d6b82e5eeb7 Mon Sep 17 00:00:00 2001 From: akr Date: Wed, 3 Dec 2008 15:02:10 +0000 Subject: * 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: svn+ssh://ci.ruby-lang.org/ruby/trunk@20470 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_process.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_process.rb b/test/ruby/test_process.rb index a77773db20..827dde4844 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"') -- cgit v1.2.3