mirror of
https://github.com/ruby/ruby.git
synced 2026-01-26 12:14:51 +00:00
Count assertions in child processes
Fix up GH-15785.
This commit is contained in:
parent
189bb64af8
commit
886202bac8
Notes:
git
2026-01-15 04:02:30 +00:00
@ -384,11 +384,10 @@ eom
|
||||
end
|
||||
raise if $!
|
||||
abort = status.coredump? || (status.signaled? && ABORT_SIGNALS.include?(status.termsig))
|
||||
assertions = 0
|
||||
marshal_error = nil
|
||||
assert(!abort, FailDesc[status, nil, stderr])
|
||||
res.scan(/^<error id="#{token_re}" assertions=(\d+)>\n(.*?)\n(?=<\/error id="#{token_re}">$)/m) do
|
||||
assertions += $1.to_i
|
||||
self._assertions += $1.to_i
|
||||
res = Marshal.load($2.unpack1("m")) or next
|
||||
rescue => marshal_error
|
||||
ignore_stderr = nil
|
||||
|
||||
@ -17,6 +17,29 @@ class TestAssertion < Test::Unit::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
def test_assertion_count_separately
|
||||
beginning = self._assertions
|
||||
|
||||
assert_separately([], "")
|
||||
assertions_at_nothing = self._assertions - beginning
|
||||
|
||||
prev_assertions = self._assertions + assertions_at_nothing
|
||||
assert_separately([], "assert true")
|
||||
assert_equal(1, self._assertions - prev_assertions)
|
||||
|
||||
omit unless Process.respond_to?(:fork)
|
||||
prev_assertions = self._assertions + assertions_at_nothing
|
||||
assert_separately([], "Process.fork {assert true}; assert true")
|
||||
assert_equal(2, self._assertions - prev_assertions)
|
||||
|
||||
prev_assertions = self._assertions + assertions_at_nothing
|
||||
# TODO: assertions before `fork` are counted twice; it is possible
|
||||
# to reset `_assertions` at `Process._fork`, but the hook can
|
||||
# interfere in other tests.
|
||||
assert_separately([], "assert true; Process.fork {assert true}")
|
||||
assert_equal(3, self._assertions - prev_assertions)
|
||||
end
|
||||
|
||||
def return_in_assert_raise
|
||||
assert_raise(RuntimeError) do
|
||||
return
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user