1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

test_parallel.rb: extend timeout for --jit-wait

testing. 10s was long enough for my machine, but not for travis.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63285 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
k0kubun 2018-04-28 08:41:19 +00:00
parent ada4198478
commit 9aab4b6bc7

View file

@ -5,6 +5,7 @@ require 'timeout'
module TestParallel
PARALLEL_RB = "#{File.dirname(__FILE__)}/../lib/test/unit/parallel.rb"
TESTS = "#{File.dirname(__FILE__)}/tests_for_parallel"
TIMEOUT = RubyVM::MJIT.enabled? ? 100 : 10 # use large timeout for --jit-wait
class TestParallelWorker < Test::Unit::TestCase
def setup
@ -43,7 +44,7 @@ module TestParallel
end
def test_run
Timeout.timeout(10) do
Timeout.timeout(TIMEOUT) do
assert_match(/^ready/,@worker_out.gets)
@worker_in.puts "run #{TESTS}/ptest_first.rb test"
assert_match(/^okay/,@worker_out.gets)
@ -55,7 +56,7 @@ module TestParallel
end
def test_run_multiple_testcase_in_one_file
Timeout.timeout(10) do
Timeout.timeout(TIMEOUT) do
assert_match(/^ready/,@worker_out.gets)
@worker_in.puts "run #{TESTS}/ptest_second.rb test"
assert_match(/^okay/,@worker_out.gets)
@ -70,7 +71,7 @@ module TestParallel
end
def test_accept_run_command_multiple_times
Timeout.timeout(10) do
Timeout.timeout(TIMEOUT) do
assert_match(/^ready/,@worker_out.gets)
@worker_in.puts "run #{TESTS}/ptest_first.rb test"
assert_match(/^okay/,@worker_out.gets)
@ -91,7 +92,7 @@ module TestParallel
end
def test_p
Timeout.timeout(10) do
Timeout.timeout(TIMEOUT) do
@worker_in.puts "run #{TESTS}/ptest_first.rb test"
while buf = @worker_out.gets
break if /^p (.+?)$/ =~ buf
@ -101,7 +102,7 @@ module TestParallel
end
def test_done
Timeout.timeout(10) do
Timeout.timeout(TIMEOUT) do
@worker_in.puts "run #{TESTS}/ptest_forth.rb test"
while buf = @worker_out.gets
break if /^done (.+?)$/ =~ buf
@ -124,7 +125,7 @@ module TestParallel
end
def test_quit
Timeout.timeout(10) do
Timeout.timeout(TIMEOUT) do
@worker_in.puts "quit"
assert_match(/^bye$/m,@worker_out.read)
end
@ -160,40 +161,40 @@ module TestParallel
"--ruby", @options[:ruby].join(" "),
"-j","0", out: File::NULL, err: o)
o.close
Timeout.timeout(10) {
Timeout.timeout(TIMEOUT) {
assert_match(/Error: parameter of -j option should be greater than 0/,@test_out.read)
}
end
def test_should_run_all_without_any_leaks
spawn_runner
buf = Timeout.timeout(10) {@test_out.read}
buf = Timeout.timeout(TIMEOUT) {@test_out.read}
assert_match(/^9 tests/,buf)
end
def test_should_retry_failed_on_workers
spawn_runner
buf = Timeout.timeout(10) {@test_out.read}
buf = Timeout.timeout(TIMEOUT) {@test_out.read}
assert_match(/^Retrying\.+$/,buf)
end
def test_no_retry_option
spawn_runner "--no-retry"
buf = Timeout.timeout(10) {@test_out.read}
buf = Timeout.timeout(TIMEOUT) {@test_out.read}
refute_match(/^Retrying\.+$/,buf)
assert_match(/^ +\d+\) Failure:\nTestD#test_fail_at_worker/,buf)
end
def test_jobs_status
spawn_runner "--jobs-status"
buf = Timeout.timeout(10) {@test_out.read}
buf = Timeout.timeout(TIMEOUT) {@test_out.read}
assert_match(/\d+=ptest_(first|second|third|forth) */,buf)
end
def test_separate
# this test depends to --jobs-status
spawn_runner "--jobs-status", "--separate"
buf = Timeout.timeout(10) {@test_out.read}
buf = Timeout.timeout(TIMEOUT) {@test_out.read}
assert(buf.scan(/(\d+?)[:=]/).flatten.uniq.size > 1)
end
end