Skip to content

Commit

Permalink
fix multithreading regression in Minitest, keep Thread.local before c…
Browse files Browse the repository at this point in the history
…ontext is introduced
  • Loading branch information
anmarchenko committed Nov 3, 2023
1 parent 1ea75fb commit 30dfdd0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 4 additions & 3 deletions lib/datadog/ci/contrib/minitest/hooks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@ def before_setup
operation_name: configuration[:operation_name]
)

@current_test_span = test_span
Thread.current[:_datadog_test_span] = test_span
end

def after_teardown
test_span = @current_test_span
test_span = Thread.current[:_datadog_test_span]
return super unless test_span

Thread.current[:_datadog_test_span] = nil

case result_code
when "."
test_span.passed!
Expand All @@ -48,7 +50,6 @@ def after_teardown
end

test_span.finish
@current_test_span = nil

super
end
Expand Down
2 changes: 0 additions & 2 deletions sig/datadog/ci/contrib/minitest/hooks.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ module Datadog
module Hooks : ::Minitest::Test
include ::Minitest::Test::LifecycleHooks

@current_test_span: Datadog::CI::Span?

def before_setup: () -> (nil | untyped)

def after_teardown: () -> untyped
Expand Down

0 comments on commit 30dfdd0

Please sign in to comment.