Skip to content

Commit a245f19

Browse files
hsbtmame
andauthored
Pick ruby/ruby changes for test/fiddle/test_function.rb (#141)
ruby/ruby#11048 (comment) --------- Co-authored-by: Yusuke Endoh <mame@ruby-lang.org>
1 parent c3dbf7b commit a245f19

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ gemspec
55
gem "rake"
66
gem "rake-compiler"
77
gem "test-unit", ">= 3.4.5"
8+
gem "test-unit-ruby-core"

test/fiddle/test_function.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@ def test_function_as_method
167167
end
168168

169169
def test_nogvl_poll
170+
require "envutil" unless defined?(EnvUtil)
171+
170172
# XXX hack to quiet down CI errors on EINTR from r64353
171173
# [ruby-core:88360] [Misc #14937]
172174
# Making pipes (and sockets) non-blocking by default would allow
@@ -180,13 +182,13 @@ def test_nogvl_poll
180182
end
181183
f = Function.new(poll, [TYPE_VOIDP, TYPE_INT, TYPE_INT], TYPE_INT)
182184

183-
msec = 200
185+
msec = EnvUtil.apply_timeout_scale(1000)
184186
t0 = Process.clock_gettime(Process::CLOCK_MONOTONIC, :millisecond)
185187
th = Thread.new { f.call(nil, 0, msec) }
186188
n1 = f.call(nil, 0, msec)
187189
n2 = th.value
188190
t1 = Process.clock_gettime(Process::CLOCK_MONOTONIC, :millisecond)
189-
assert_in_delta(msec, t1 - t0, 180, 'slept amount of time')
191+
assert_in_delta(msec, t1 - t0, EnvUtil.apply_timeout_scale(500), 'slept amount of time')
190192
assert_equal(0, n1, perror("poll(2) in main-thread"))
191193
assert_equal(0, n2, perror("poll(2) in sub-thread"))
192194
end

0 commit comments

Comments
 (0)