ruby-changes:10278
From: yugui <ko1@a...>
Date: Wed, 28 Jan 2009 18:22:37 +0900 (JST)
Subject: [ruby-changes:10278] Ruby:r21823 (ruby_1_9_1): merges r21733 from trunk into ruby_1_9_1.
yugui 2009-01-28 18:21:35 +0900 (Wed, 28 Jan 2009) New Revision: 21823 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=21823 Log: merges r21733 from trunk into ruby_1_9_1. * test/ruby/test_process.rb: mswin specs. Modified files: branches/ruby_1_9_1/test/ruby/test_process.rb Index: ruby_1_9_1/test/ruby/test_process.rb =================================================================== --- ruby_1_9_1/test/ruby/test_process.rb (revision 21822) +++ ruby_1_9_1/test/ruby/test_process.rb (revision 21823) @@ -385,7 +385,7 @@ wios = pipes.map {|r, w| w } child_wfds = wios.map {|w| h2[w].fileno } pid = spawn(RUBY, "-e", - "[#{child_wfds.join(',')}].each {|fd| IO.new(fd).puts fd }", h) + "[#{child_wfds.join(',')}].each {|fd| IO.new(fd, 'w').puts fd }", h) pipes.each {|r, w| assert_equal("#{h2[w].fileno}\n", r.gets) } @@ -401,7 +401,7 @@ wios = pipes.map {|r, w| w } child_wfds = wios.map {|w| h2[w].fileno } pid = spawn(RUBY, "-e", - "[#{child_wfds.join(',')}].each {|fd| IO.new(fd).puts fd }", h) + "[#{child_wfds.join(',')}].each {|fd| IO.new(fd, 'w').puts fd }", h) pipes.each {|r, w| assert_equal("#{h2[w].fileno}\n", r.gets) } @@ -417,7 +417,7 @@ with_pipe {|r, w| w.close_on_exec = true - pid = spawn(RUBY, "-e", "IO.new(#{w.fileno}).print 'a'", w=>w) + pid = spawn(RUBY, "-e", "IO.new(#{w.fileno}, 'w').print 'a'", w=>w) w.close assert_equal("a", r.read) Process.wait pid @@ -457,13 +457,13 @@ IO.popen([*ECHO["fuga"], STDOUT=>"out"]) {|io| } } with_pipe {|r, w| - IO.popen([RUBY, '-e', 'IO.new(3).puts("a"); puts "b"', 3=>w]) {|io| + IO.popen([RUBY, '-e', 'IO.new(3, "w").puts("a"); puts "b"', 3=>w]) {|io| assert_equal("b\n", io.read) } w.close assert_equal("a\n", r.read) } - IO.popen([RUBY, '-e', "IO.new(9).puts(:b)", + IO.popen([RUBY, '-e', "IO.new(9, 'w').puts(:b)", 9=>["out2", File::WRONLY|File::CREAT|File::TRUNC]]) {|io| assert_equal("", io.read) } @@ -484,15 +484,14 @@ end def test_fd_inheritance - skip "inheritance of fd>=3 is not supported" if /mswin|bccwin|mingw/ =~ RUBY_PLATFORM with_pipe {|r, w| - system(RUBY, '-e', 'IO.new(ARGV[0].to_i).puts(:ba)', w.fileno.to_s) + system(RUBY, '-e', 'IO.new(ARGV[0].to_i, "w").puts(:ba)', w.fileno.to_s) w.close assert_equal("ba\n", r.read) } with_pipe {|r, w| Process.wait spawn(RUBY, '-e', - 'IO.new(ARGV[0].to_i).puts("bi") rescue nil', + 'IO.new(ARGV[0].to_i, "w").puts("bi") rescue nil', w.fileno.to_s) w.close assert_equal("", r.read) @@ -501,7 +500,7 @@ with_tmpchdir {|d| write_file("s", <<-"End") exec(#{RUBY.dump}, '-e', - 'IO.new(ARGV[0].to_i).puts("bu") rescue nil', + 'IO.new(ARGV[0].to_i, "w").puts("bu") rescue nil', #{w.fileno.to_s.dump}) End Process.wait spawn(RUBY, "s", :close_others=>false) @@ -510,7 +509,7 @@ } } with_pipe {|r, w| - io = IO.popen([RUBY, "-e", "STDERR.reopen(STDOUT); IO.new(#{w.fileno}).puts('me')"]) + io = IO.popen([RUBY, "-e", "STDERR.reopen(STDOUT); IO.new(#{w.fileno}, 'w').puts('me')"]) w.close errmsg = io.read assert_equal("", r.read) @@ -518,7 +517,7 @@ Process.wait } with_pipe {|r, w| - errmsg = `#{RUBY} -e "STDERR.reopen(STDOUT); IO.new(#{w.fileno}).puts(123)"` + errmsg = `#{RUBY} -e "STDERR.reopen(STDOUT); IO.new(#{w.fileno}, 'w').puts(123)"` w.close assert_equal("", r.read) assert_not_equal("", errmsg) @@ -528,28 +527,28 @@ def test_execopts_close_others with_tmpchdir {|d| with_pipe {|r, w| - system(RUBY, '-e', 'STDERR.reopen("err", "w"); IO.new(ARGV[0].to_i).puts("ma")', w.fileno.to_s, :close_others=>true) + system(RUBY, '-e', 'STDERR.reopen("err", "w"); IO.new(ARGV[0].to_i, "w").puts("ma")', w.fileno.to_s, :close_others=>true) w.close assert_equal("", r.read) assert_not_equal("", File.read("err")) File.unlink("err") } with_pipe {|r, w| - Process.wait spawn(RUBY, '-e', 'STDERR.reopen("err", "w"); IO.new(ARGV[0].to_i).puts("mi")', w.fileno.to_s, :close_others=>true) + Process.wait spawn(RUBY, '-e', 'STDERR.reopen("err", "w"); IO.new(ARGV[0].to_i, "w").puts("mi")', w.fileno.to_s, :close_others=>true) w.close assert_equal("", r.read) assert_not_equal("", File.read("err")) File.unlink("err") } with_pipe {|r, w| - Process.wait spawn(RUBY, '-e', 'IO.new(ARGV[0].to_i).puts("bi")', w.fileno.to_s, :close_others=>false) + Process.wait spawn(RUBY, '-e', 'IO.new(ARGV[0].to_i, "w").puts("bi")', w.fileno.to_s, :close_others=>false) w.close assert_equal("bi\n", r.read) } with_pipe {|r, w| write_file("s", <<-"End") exec(#{RUBY.dump}, '-e', - 'STDERR.reopen("err", "w"); IO.new(ARGV[0].to_i).puts("mu")', + 'STDERR.reopen("err", "w"); IO.new(ARGV[0].to_i, "w").puts("mu")', #{w.fileno.to_s.dump}, :close_others=>true) End @@ -560,7 +559,7 @@ File.unlink("err") } with_pipe {|r, w| - io = IO.popen([RUBY, "-e", "STDERR.reopen(STDOUT); IO.new(#{w.fileno}).puts('me')", :close_others=>true]) + io = IO.popen([RUBY, "-e", "STDERR.reopen(STDOUT); IO.new(#{w.fileno}, 'w').puts('me')", :close_others=>true]) w.close errmsg = io.read assert_equal("", r.read) @@ -568,7 +567,7 @@ Process.wait } with_pipe {|r, w| - io = IO.popen([RUBY, "-e", "STDERR.reopen(STDOUT); IO.new(#{w.fileno}).puts('mo')", :close_others=>false]) + io = IO.popen([RUBY, "-e", "STDERR.reopen(STDOUT); IO.new(#{w.fileno}, 'w').puts('mo')", :close_others=>false]) w.close errmsg = io.read assert_equal("mo\n", r.read) @@ -576,7 +575,7 @@ Process.wait } with_pipe {|r, w| - io = IO.popen([RUBY, "-e", "STDERR.reopen(STDOUT); IO.new(#{w.fileno}).puts('mo')", :close_others=>nil]) + io = IO.popen([RUBY, "-e", "STDERR.reopen(STDOUT); IO.new(#{w.fileno}, 'w').puts('mo')", :close_others=>nil]) w.close errmsg = io.read assert_equal("mo\n", r.read) @@ -593,7 +592,7 @@ w << "haha\n" w.close r.close_on_exec = true - IO.popen([RUBY, "-e", "print IO.new(#{r.fileno}).read", r.fileno=>r.fileno, :close_others=>false]) {|io| + IO.popen([RUBY, "-e", "print IO.new(#{r.fileno}, 'r').read", r.fileno=>r.fileno, :close_others=>false]) {|io| assert_equal("haha\n", io.read) } } @@ -644,7 +643,7 @@ with_pipe {|r, w| write_file("s", <<-"End") str = "echo non existing command name which contains spaces" - w = IO.new(#{w.fileno}) + w = IO.new(#{w.fileno}, "w") STDOUT.reopen(w) STDERR.reopen(w) begin @@ -1041,8 +1040,11 @@ Process.wait pid sleep 2 assert_equal [true], signal_received, " [ruby-core:19744]" - rescue NotImplementedError + rescue NotImplementedError, ArgumentError ensure - Signal.trap(:CHLD, 'DEFAULT') + begin + Signal.trap(:CHLD, 'DEFAULT') + rescue ArgumentError + end end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/