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

Apply the timeout scale to also separated workers

This commit is contained in:
Nobuyoshi Nakada 2021-10-30 12:26:06 +09:00
parent 1d0ce1a349
commit 99dad28b7c
No known key found for this signature in database
GPG key ID: 7CD2805BFA3770C6

View file

@ -1408,21 +1408,24 @@ class TestFileExhaustive < Test::Unit::TestCase
end end
def test_flock_exclusive def test_flock_exclusive
timeout = EnvUtil.apply_timeout_scale(0.1).to_s
File.open(regular_file, "r+") do |f| File.open(regular_file, "r+") do |f|
f.flock(File::LOCK_EX) f.flock(File::LOCK_EX)
assert_separately(["-rtimeout", "-", regular_file], "#{<<~begin}#{<<~"end;"}") assert_separately(["-rtimeout", "-", regular_file, timeout], "#{<<-"begin;"}\n#{<<-'end;'}")
begin begin;
timeout = ARGV[1].to_f
open(ARGV[0], "r") do |f| open(ARGV[0], "r") do |f|
Timeout.timeout(0.1) do Timeout.timeout(timeout) do
assert(!f.flock(File::LOCK_SH|File::LOCK_NB)) assert(!f.flock(File::LOCK_SH|File::LOCK_NB))
end end
end end
end; end;
assert_separately(["-rtimeout", "-", regular_file], "#{<<~begin}#{<<~"end;"}") assert_separately(["-rtimeout", "-", regular_file, timeout], "#{<<-"begin;"}\n#{<<-'end;'}")
begin begin;
timeout = ARGV[1].to_f
open(ARGV[0], "r") do |f| open(ARGV[0], "r") do |f|
assert_raise(Timeout::Error) do assert_raise(Timeout::Error) do
Timeout.timeout(0.1) do Timeout.timeout(timeout) do
f.flock(File::LOCK_SH) f.flock(File::LOCK_SH)
end end
end end
@ -1434,21 +1437,24 @@ class TestFileExhaustive < Test::Unit::TestCase
end end
def test_flock_shared def test_flock_shared
timeout = EnvUtil.apply_timeout_scale(0.1).to_s
File.open(regular_file, "r+") do |f| File.open(regular_file, "r+") do |f|
f.flock(File::LOCK_SH) f.flock(File::LOCK_SH)
assert_separately(["-rtimeout", "-", regular_file], "#{<<~begin}#{<<~"end;"}") assert_separately(["-rtimeout", "-", regular_file, timeout], "#{<<-"begin;"}\n#{<<-'end;'}")
begin begin;
timeout = ARGV[1].to_f
open(ARGV[0], "r") do |f| open(ARGV[0], "r") do |f|
Timeout.timeout(0.1) do Timeout.timeout(timeout) do
assert(f.flock(File::LOCK_SH)) assert(f.flock(File::LOCK_SH))
end end
end end
end; end;
assert_separately(["-rtimeout", "-", regular_file], "#{<<~begin}#{<<~"end;"}") assert_separately(["-rtimeout", "-", regular_file, timeout], "#{<<-"begin;"}\n#{<<-'end;'}")
begin begin;
timeout = ARGV[1].to_f
open(ARGV[0], "r+") do |f| open(ARGV[0], "r+") do |f|
assert_raise(Timeout::Error) do assert_raise(Timeout::Error) do
Timeout.timeout(0.1) do Timeout.timeout(timeout) do
f.flock(File::LOCK_EX) f.flock(File::LOCK_EX)
end end
end end