mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
f5d2041138
After 5680c38c75
, postponed job APIs now
expect to be called on native threads not managed by Ruby and handles
getting a NULL execution context. However, in debug builds the change
runs into an assertion failure with GET_EC() which asserts that EC is
non-NULL. Avoid the assertion failure by passing `false` for `expect_ec`
instead as the intention is to handle when there is no EC.
Add a test from John Crepezzi and John Hawthorn to exercise this
situation.
See GH-4108
See GH-5094
[Bug #17573]
Co-authored-by: John Hawthorn <john@hawthorn.email>
Co-authored-by: John Crepezzi <john.crepezzi@gmail.com>
35 lines
829 B
Ruby
35 lines
829 B
Ruby
# frozen_string_literal: false
|
|
require 'test/unit'
|
|
require '-test-/postponed_job'
|
|
|
|
module Bug
|
|
def self.postponed_job_call_direct_wrapper(*args)
|
|
postponed_job_call_direct(*args)
|
|
end
|
|
|
|
def self.postponed_job_register_wrapper(*args)
|
|
postponed_job_register(*args)
|
|
end
|
|
end
|
|
|
|
class TestPostponed_job < Test::Unit::TestCase
|
|
def test_register
|
|
direct, registered = [], []
|
|
|
|
Bug.postponed_job_call_direct_wrapper(direct)
|
|
Bug.postponed_job_register_wrapper(registered)
|
|
|
|
assert_equal([0], direct)
|
|
assert_equal([3], registered)
|
|
|
|
Bug.postponed_job_register_one(ary = [])
|
|
assert_equal [1], ary
|
|
end
|
|
|
|
if Bug.respond_to?(:postponed_job_register_in_c_thread)
|
|
def test_register_in_c_thread
|
|
assert Bug.postponed_job_register_in_c_thread(ary = [])
|
|
assert_equal [1], ary
|
|
end
|
|
end
|
|
end
|