mirror of
https://github.com/ruby/ruby.git
synced 2025-09-19 10:33:58 +02:00
merges r21733 from trunk into ruby_1_9_1.
* test/ruby/test_process.rb: mswin specs. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@21823 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
063d6c71ec
commit
8a917193c9
1 changed files with 24 additions and 22 deletions
|
@ -385,7 +385,7 @@ class TestProcess < Test::Unit::TestCase
|
||||||
wios = pipes.map {|r, w| w }
|
wios = pipes.map {|r, w| w }
|
||||||
child_wfds = wios.map {|w| h2[w].fileno }
|
child_wfds = wios.map {|w| h2[w].fileno }
|
||||||
pid = spawn(RUBY, "-e",
|
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|
|
pipes.each {|r, w|
|
||||||
assert_equal("#{h2[w].fileno}\n", r.gets)
|
assert_equal("#{h2[w].fileno}\n", r.gets)
|
||||||
}
|
}
|
||||||
|
@ -401,7 +401,7 @@ class TestProcess < Test::Unit::TestCase
|
||||||
wios = pipes.map {|r, w| w }
|
wios = pipes.map {|r, w| w }
|
||||||
child_wfds = wios.map {|w| h2[w].fileno }
|
child_wfds = wios.map {|w| h2[w].fileno }
|
||||||
pid = spawn(RUBY, "-e",
|
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|
|
pipes.each {|r, w|
|
||||||
assert_equal("#{h2[w].fileno}\n", r.gets)
|
assert_equal("#{h2[w].fileno}\n", r.gets)
|
||||||
}
|
}
|
||||||
|
@ -417,7 +417,7 @@ class TestProcess < Test::Unit::TestCase
|
||||||
|
|
||||||
with_pipe {|r, w|
|
with_pipe {|r, w|
|
||||||
w.close_on_exec = true
|
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
|
w.close
|
||||||
assert_equal("a", r.read)
|
assert_equal("a", r.read)
|
||||||
Process.wait pid
|
Process.wait pid
|
||||||
|
@ -457,13 +457,13 @@ class TestProcess < Test::Unit::TestCase
|
||||||
IO.popen([*ECHO["fuga"], STDOUT=>"out"]) {|io| }
|
IO.popen([*ECHO["fuga"], STDOUT=>"out"]) {|io| }
|
||||||
}
|
}
|
||||||
with_pipe {|r, w|
|
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)
|
assert_equal("b\n", io.read)
|
||||||
}
|
}
|
||||||
w.close
|
w.close
|
||||||
assert_equal("a\n", r.read)
|
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|
|
9=>["out2", File::WRONLY|File::CREAT|File::TRUNC]]) {|io|
|
||||||
assert_equal("", io.read)
|
assert_equal("", io.read)
|
||||||
}
|
}
|
||||||
|
@ -484,15 +484,14 @@ class TestProcess < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_fd_inheritance
|
def test_fd_inheritance
|
||||||
skip "inheritance of fd>=3 is not supported" if /mswin|bccwin|mingw/ =~ RUBY_PLATFORM
|
|
||||||
with_pipe {|r, w|
|
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
|
w.close
|
||||||
assert_equal("ba\n", r.read)
|
assert_equal("ba\n", r.read)
|
||||||
}
|
}
|
||||||
with_pipe {|r, w|
|
with_pipe {|r, w|
|
||||||
Process.wait spawn(RUBY, '-e',
|
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.fileno.to_s)
|
||||||
w.close
|
w.close
|
||||||
assert_equal("", r.read)
|
assert_equal("", r.read)
|
||||||
|
@ -501,7 +500,7 @@ class TestProcess < Test::Unit::TestCase
|
||||||
with_tmpchdir {|d|
|
with_tmpchdir {|d|
|
||||||
write_file("s", <<-"End")
|
write_file("s", <<-"End")
|
||||||
exec(#{RUBY.dump}, '-e',
|
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})
|
#{w.fileno.to_s.dump})
|
||||||
End
|
End
|
||||||
Process.wait spawn(RUBY, "s", :close_others=>false)
|
Process.wait spawn(RUBY, "s", :close_others=>false)
|
||||||
|
@ -510,7 +509,7 @@ class TestProcess < Test::Unit::TestCase
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
with_pipe {|r, w|
|
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
|
w.close
|
||||||
errmsg = io.read
|
errmsg = io.read
|
||||||
assert_equal("", r.read)
|
assert_equal("", r.read)
|
||||||
|
@ -518,7 +517,7 @@ class TestProcess < Test::Unit::TestCase
|
||||||
Process.wait
|
Process.wait
|
||||||
}
|
}
|
||||||
with_pipe {|r, w|
|
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
|
w.close
|
||||||
assert_equal("", r.read)
|
assert_equal("", r.read)
|
||||||
assert_not_equal("", errmsg)
|
assert_not_equal("", errmsg)
|
||||||
|
@ -528,28 +527,28 @@ class TestProcess < Test::Unit::TestCase
|
||||||
def test_execopts_close_others
|
def test_execopts_close_others
|
||||||
with_tmpchdir {|d|
|
with_tmpchdir {|d|
|
||||||
with_pipe {|r, w|
|
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
|
w.close
|
||||||
assert_equal("", r.read)
|
assert_equal("", r.read)
|
||||||
assert_not_equal("", File.read("err"))
|
assert_not_equal("", File.read("err"))
|
||||||
File.unlink("err")
|
File.unlink("err")
|
||||||
}
|
}
|
||||||
with_pipe {|r, w|
|
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
|
w.close
|
||||||
assert_equal("", r.read)
|
assert_equal("", r.read)
|
||||||
assert_not_equal("", File.read("err"))
|
assert_not_equal("", File.read("err"))
|
||||||
File.unlink("err")
|
File.unlink("err")
|
||||||
}
|
}
|
||||||
with_pipe {|r, w|
|
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
|
w.close
|
||||||
assert_equal("bi\n", r.read)
|
assert_equal("bi\n", r.read)
|
||||||
}
|
}
|
||||||
with_pipe {|r, w|
|
with_pipe {|r, w|
|
||||||
write_file("s", <<-"End")
|
write_file("s", <<-"End")
|
||||||
exec(#{RUBY.dump}, '-e',
|
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},
|
#{w.fileno.to_s.dump},
|
||||||
:close_others=>true)
|
:close_others=>true)
|
||||||
End
|
End
|
||||||
|
@ -560,7 +559,7 @@ class TestProcess < Test::Unit::TestCase
|
||||||
File.unlink("err")
|
File.unlink("err")
|
||||||
}
|
}
|
||||||
with_pipe {|r, w|
|
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
|
w.close
|
||||||
errmsg = io.read
|
errmsg = io.read
|
||||||
assert_equal("", r.read)
|
assert_equal("", r.read)
|
||||||
|
@ -568,7 +567,7 @@ class TestProcess < Test::Unit::TestCase
|
||||||
Process.wait
|
Process.wait
|
||||||
}
|
}
|
||||||
with_pipe {|r, w|
|
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
|
w.close
|
||||||
errmsg = io.read
|
errmsg = io.read
|
||||||
assert_equal("mo\n", r.read)
|
assert_equal("mo\n", r.read)
|
||||||
|
@ -576,7 +575,7 @@ class TestProcess < Test::Unit::TestCase
|
||||||
Process.wait
|
Process.wait
|
||||||
}
|
}
|
||||||
with_pipe {|r, w|
|
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
|
w.close
|
||||||
errmsg = io.read
|
errmsg = io.read
|
||||||
assert_equal("mo\n", r.read)
|
assert_equal("mo\n", r.read)
|
||||||
|
@ -593,7 +592,7 @@ class TestProcess < Test::Unit::TestCase
|
||||||
w << "haha\n"
|
w << "haha\n"
|
||||||
w.close
|
w.close
|
||||||
r.close_on_exec = true
|
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)
|
assert_equal("haha\n", io.read)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -644,7 +643,7 @@ class TestProcess < Test::Unit::TestCase
|
||||||
with_pipe {|r, w|
|
with_pipe {|r, w|
|
||||||
write_file("s", <<-"End")
|
write_file("s", <<-"End")
|
||||||
str = "echo non existing command name which contains spaces"
|
str = "echo non existing command name which contains spaces"
|
||||||
w = IO.new(#{w.fileno})
|
w = IO.new(#{w.fileno}, "w")
|
||||||
STDOUT.reopen(w)
|
STDOUT.reopen(w)
|
||||||
STDERR.reopen(w)
|
STDERR.reopen(w)
|
||||||
begin
|
begin
|
||||||
|
@ -1041,8 +1040,11 @@ class TestProcess < Test::Unit::TestCase
|
||||||
Process.wait pid
|
Process.wait pid
|
||||||
sleep 2
|
sleep 2
|
||||||
assert_equal [true], signal_received, " [ruby-core:19744]"
|
assert_equal [true], signal_received, " [ruby-core:19744]"
|
||||||
rescue NotImplementedError
|
rescue NotImplementedError, ArgumentError
|
||||||
ensure
|
ensure
|
||||||
|
begin
|
||||||
Signal.trap(:CHLD, 'DEFAULT')
|
Signal.trap(:CHLD, 'DEFAULT')
|
||||||
|
rescue ArgumentError
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue