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