use rlimit_nproc other than Windows

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52273 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
naruse 2015-10-24 18:21:39 +00:00
parent a530172285
commit b78b66a976
2 changed files with 6 additions and 2 deletions

View File

@ -1080,7 +1080,9 @@ class TestIO < Test::Unit::TestCase
def ruby(*args) def ruby(*args)
args = ['-e', '$>.write($<.read)'] if args.empty? args = ['-e', '$>.write($<.read)'] if args.empty?
ruby = EnvUtil.rubybin ruby = EnvUtil.rubybin
f = IO.popen([ruby] + args, 'r+') opts = {}
opts[:rlimit_nproc] = 1024 if /mswin|mingw/ =~ RUBY_PLATFORM
f = IO.popen([ruby] + args, 'r+', opts)
pid = f.pid pid = f.pid
yield(f) yield(f)
ensure ensure

View File

@ -1596,11 +1596,13 @@ class TestProcess < Test::Unit::TestCase
cmds = Array.new(min, cmd) cmds = Array.new(min, cmd)
exs = [Errno::ENOENT] exs = [Errno::ENOENT]
exs << Errno::E2BIG if defined?(Errno::E2BIG) exs << Errno::E2BIG if defined?(Errno::E2BIG)
opts = {[STDOUT, STDERR]=>File::NULL}
opts[:rlimit_nproc] = 128 if /mswin|mingw/ =~ RUBY_PLATFORM
EnvUtil.suppress_warning do EnvUtil.suppress_warning do
assert_raise(*exs, mesg) do assert_raise(*exs, mesg) do
begin begin
loop do loop do
Process.spawn(cmds.join(sep), [STDOUT, STDERR]=>File::NULL, rlimit_nproc: 1) Process.spawn(cmds.join(sep), opts)
min = [cmds.size, min].max min = [cmds.size, min].max
cmds *= 100 cmds *= 100
end end