mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* test/ruby/test_process.rb (TestProcess#windows?): new method.
* test/ruby/test_process.rb (TestProcess#*): use above method. * test/ruby/test_process.rb (TestProcess#test_execopts_redirect): windows doesn't support FD_CLOEXEC. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32799 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
f209dc7242
commit
b8d546db64
2 changed files with 33 additions and 30 deletions
|
@ -1,3 +1,12 @@
|
|||
Mon Aug 1 20:12:03 2011 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||
|
||||
* test/ruby/test_process.rb (TestProcess#windows?): new method.
|
||||
|
||||
* test/ruby/test_process.rb (TestProcess#*): use above method.
|
||||
|
||||
* test/ruby/test_process.rb (TestProcess#test_execopts_redirect):
|
||||
windows doesn't support FD_CLOEXEC.
|
||||
|
||||
Mon Aug 01 15:45:23 2011 Eric Hodel <drbrain@segment7.net>
|
||||
|
||||
* test/rake/test_rake_functional.rb: Don't assume the binary name of
|
||||
|
|
|
@ -16,6 +16,10 @@ class TestProcess < Test::Unit::TestCase
|
|||
Process.waitall
|
||||
end
|
||||
|
||||
def windows?
|
||||
return /mswin|mingw|bccwin/ =~ RUBY_PLATFORM
|
||||
end
|
||||
|
||||
def write_file(filename, content)
|
||||
File.open(filename, "w") {|f|
|
||||
f << content
|
||||
|
@ -154,7 +158,7 @@ class TestProcess < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_execopts_pgroup
|
||||
skip "system(:pgroup) is not supported" if /mswin|bccwin|mingw/ =~ RUBY_PLATFORM
|
||||
skip "system(:pgroup) is not supported" if windows?
|
||||
assert_nothing_raised { system(*TRUECOMMAND, :pgroup=>false) }
|
||||
|
||||
io = IO.popen([RUBY, "-e", "print Process.getpgrp"])
|
||||
|
@ -326,7 +330,7 @@ class TestProcess < Test::Unit::TestCase
|
|||
UMASK = [RUBY, '-e', 'printf "%04o\n", File.umask']
|
||||
|
||||
def test_execopts_umask
|
||||
skip "umask is not supported" if /mswin|bccwin|mingw/ =~ RUBY_PLATFORM
|
||||
skip "umask is not supported" if windows?
|
||||
IO.popen([*UMASK, :umask => 0]) {|io|
|
||||
assert_equal("0000", io.read.chomp)
|
||||
}
|
||||
|
@ -368,7 +372,7 @@ class TestProcess < Test::Unit::TestCase
|
|||
with_tmpchdir {|d|
|
||||
Process.wait Process.spawn(*ECHO["a"], STDOUT=>["out", File::WRONLY|File::CREAT|File::TRUNC, 0644])
|
||||
assert_equal("a", File.read("out").chomp)
|
||||
if /mswin|mingw/ =~ RUBY_PLATFORM
|
||||
if windows?
|
||||
# currently telling to child the file modes is not supported.
|
||||
open("out", "a") {|f| f.write "0\n"}
|
||||
else
|
||||
|
@ -391,18 +395,14 @@ class TestProcess < Test::Unit::TestCase
|
|||
assert_equal("d", File.read("out").chomp)
|
||||
}
|
||||
opts = {STDOUT=>["out", File::WRONLY|File::CREAT|File::TRUNC, 0644]}
|
||||
if /mswin|mingw/ !~ RUBY_PLATFORM
|
||||
opts.merge(3=>STDOUT, 4=>STDOUT, 5=>STDOUT, 6=>STDOUT, 7=>STDOUT)
|
||||
end
|
||||
opts.merge(3=>STDOUT, 4=>STDOUT, 5=>STDOUT, 6=>STDOUT, 7=>STDOUT) unless windows?
|
||||
Process.wait Process.spawn(*ECHO["e"], opts)
|
||||
assert_equal("e", File.read("out").chomp)
|
||||
opts = {STDOUT=>["out", File::WRONLY|File::CREAT|File::TRUNC, 0644]}
|
||||
if /mswin|mingw/ !~ RUBY_PLATFORM
|
||||
opts.merge(3=>0, 4=>:in, 5=>STDIN, 6=>1, 7=>:out, 8=>STDOUT, 9=>2, 10=>:err, 11=>STDERR)
|
||||
end
|
||||
opts.merge(3=>0, 4=>:in, 5=>STDIN, 6=>1, 7=>:out, 8=>STDOUT, 9=>2, 10=>:err, 11=>STDERR) unless windows?
|
||||
Process.wait Process.spawn(*ECHO["ee"], opts)
|
||||
assert_equal("ee", File.read("out").chomp)
|
||||
if /mswin|mingw/ !~ RUBY_PLATFORM
|
||||
unless windows?
|
||||
# passing non-stdio fds is not supported on Windows
|
||||
File.open("out", "w") {|f|
|
||||
h = {STDOUT=>f, f=>STDOUT}
|
||||
|
@ -428,7 +428,7 @@ class TestProcess < Test::Unit::TestCase
|
|||
Process.wait Process.spawn(*SORT, STDIN=>"out", STDOUT=>"out2")
|
||||
assert_equal("ggg\nhhh\n", File.read("out2"))
|
||||
|
||||
if /mswin|mingw/ !~ RUBY_PLATFORM
|
||||
unless windows?
|
||||
# passing non-stdio fds is not supported on Windows
|
||||
assert_raise(Errno::ENOENT) {
|
||||
Process.wait Process.spawn("non-existing-command", (3..60).to_a=>["err", File::WRONLY|File::CREAT])
|
||||
|
@ -443,7 +443,9 @@ class TestProcess < Test::Unit::TestCase
|
|||
|
||||
with_pipe {|r1, w1|
|
||||
with_pipe {|r2, w2|
|
||||
pid = spawn(*SORT, STDIN=>r1, STDOUT=>w2, w1=>:close, r2=>:close)
|
||||
opts = {STDIN=>r1, STDOUT=>w2}
|
||||
opts.merge(w1=>:close, r2=>:close) unless windows?
|
||||
pid = spawn(*SORT, opts)
|
||||
r1.close
|
||||
w2.close
|
||||
w1.puts "c"
|
||||
|
@ -456,7 +458,7 @@ class TestProcess < Test::Unit::TestCase
|
|||
}
|
||||
}
|
||||
|
||||
if /mswin|mingw/ !~ RUBY_PLATFORM
|
||||
unless windows?
|
||||
# passing non-stdio fds is not supported on Windows
|
||||
with_pipes(5) {|pipes|
|
||||
ios = pipes.flatten
|
||||
|
@ -528,9 +530,7 @@ class TestProcess < Test::Unit::TestCase
|
|||
STDERR=>"out", STDOUT=>[:child, STDERR])
|
||||
assert_equal("errout", File.read("out"))
|
||||
|
||||
if /mswin|bccwin|mingw/ =~ RUBY_PLATFORM
|
||||
skip "inheritance of fd other than stdin,stdout and stderr is not supported"
|
||||
end
|
||||
skip "inheritance of fd other than stdin,stdout and stderr is not supported" if windows?
|
||||
Process.wait spawn(RUBY, "-e", "STDERR.print 'err'; STDOUT.print 'out'",
|
||||
STDOUT=>"out",
|
||||
STDERR=>[:child, 3],
|
||||
|
@ -573,9 +573,7 @@ class TestProcess < Test::Unit::TestCase
|
|||
assert_raise(ArgumentError) {
|
||||
IO.popen([*ECHO["fuga"], STDOUT=>"out"]) {|io| }
|
||||
}
|
||||
if /mswin|bccwin|mingw/ =~ RUBY_PLATFORM
|
||||
skip "inheritance of fd other than stdin,stdout and stderr is not supported"
|
||||
end
|
||||
skip "inheritance of fd other than stdin,stdout and stderr is not supported" if windows?
|
||||
with_pipe {|r, w|
|
||||
IO.popen([RUBY, '-e', 'IO.new(3, "w").puts("a"); puts "b"', 3=>w]) {|io|
|
||||
assert_equal("b\n", io.read)
|
||||
|
@ -603,9 +601,7 @@ class TestProcess < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_fd_inheritance
|
||||
if /mswin|bccwin|mingw/ =~ RUBY_PLATFORM
|
||||
skip "inheritance of fd other than stdin,stdout and stderr is not supported"
|
||||
end
|
||||
skip "inheritance of fd other than stdin,stdout and stderr is not supported" if windows?
|
||||
with_pipe {|r, w|
|
||||
system(RUBY, '-e', 'IO.new(ARGV[0].to_i, "w").puts(:ba)', w.fileno.to_s)
|
||||
w.close
|
||||
|
@ -647,9 +643,7 @@ class TestProcess < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_execopts_close_others
|
||||
if /mswin|bccwin|mingw/ =~ RUBY_PLATFORM
|
||||
skip "inheritance of fd other than stdin,stdout and stderr is not supported"
|
||||
end
|
||||
skip "inheritance of fd other than stdin,stdout and stderr is not supported" if windows?
|
||||
with_tmpchdir {|d|
|
||||
with_pipe {|r, w|
|
||||
system(RUBY, '-e', 'STDERR.reopen("err", "w"); IO.new(ARGV[0].to_i, "w").puts("ma")', w.fileno.to_s, :close_others=>true)
|
||||
|
@ -853,7 +847,7 @@ class TestProcess < Test::Unit::TestCase
|
|||
assert_equal(pid, status.pid)
|
||||
assert(status.exited?)
|
||||
assert_equal(6, status.exitstatus)
|
||||
if /mswin|bccwin|mingw/ =~ RUBY_PLATFORM
|
||||
if windows?
|
||||
expected = "hehe ppid=#{status.pid}"
|
||||
else
|
||||
expected = "hehe pid=#{status.pid} ppid=#{$$}"
|
||||
|
@ -882,7 +876,7 @@ class TestProcess < Test::Unit::TestCase
|
|||
assert_match(/\Ataki pid=\d+ ppid=\d+\z/, result2)
|
||||
assert_not_equal(result1[/\d+/].to_i, status.pid)
|
||||
|
||||
if /mswin|bccwin|mingw/ =~ RUBY_PLATFORM
|
||||
if windows?
|
||||
Dir.mkdir(path = "path with space")
|
||||
write_file(bat = path + "/bat test.bat", "@echo %1>out")
|
||||
system(bat, "foo 'bar'")
|
||||
|
@ -914,7 +908,7 @@ class TestProcess < Test::Unit::TestCase
|
|||
assert_match(/\Atake pid=\d+ ppid=\d+\z/, result2)
|
||||
assert_not_equal(result1[/\d+/].to_i, status.pid)
|
||||
|
||||
if /mswin|bccwin|mingw/ =~ RUBY_PLATFORM
|
||||
if windows?
|
||||
Dir.mkdir(path = "path with space")
|
||||
write_file(bat = path + "/bat test.bat", "@echo %1>out")
|
||||
pid = spawn(bat, "foo 'bar'")
|
||||
|
@ -952,7 +946,7 @@ class TestProcess < Test::Unit::TestCase
|
|||
assert_match(/\Atako pid=\d+ ppid=\d+\ntika pid=\d+ ppid=\d+\n\z/, result)
|
||||
assert_not_equal(result[/\d+/].to_i, status.pid)
|
||||
|
||||
if /mswin|bccwin|mingw/ =~ RUBY_PLATFORM
|
||||
if windows?
|
||||
Dir.mkdir(path = "path with space")
|
||||
write_file(bat = path + "/bat test.bat", "@echo %1")
|
||||
r = IO.popen([bat, "foo 'bar'"]) {|f| f.read}
|
||||
|
@ -1256,7 +1250,7 @@ class TestProcess < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_system_sigpipe
|
||||
return if /mswin|mingw/ =~ RUBY_PLATFORM
|
||||
return if windows?
|
||||
|
||||
pid = 0
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue