Skip to content

Commit

Permalink
ITR code coverage start/stop in Recorder
Browse files Browse the repository at this point in the history
  • Loading branch information
anmarchenko committed Mar 14, 2024
1 parent 0af7555 commit 6a4c76b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
18 changes: 17 additions & 1 deletion lib/datadog/ci/test_visibility/recorder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,22 @@ def trace_test(test_name, test_suite_name, service: nil, tags: {}, &block)
test = build_test(tracer_span, tags)

@local_context.activate_test(test) do
block.call(test)
@itr.start_coverage

res = block.call(test)
on_test_finished(test)

res
end
end
else
tracer_span = start_datadog_tracer_span(test_name, span_options)

test = build_test(tracer_span, tags)

@local_context.activate_test(test)
@itr.start_coverage

test
end
end
Expand Down Expand Up @@ -168,6 +176,9 @@ def active_test_suite(test_suite_name)
end

def deactivate_test
test = active_test
on_test_finished(test) if test

@local_context.deactivate_test
end

Expand Down Expand Up @@ -334,6 +345,11 @@ def validate_test_suite_level_visibility_correctness(test)
end
end
end

# TODO: use kind of event system to notify about test finished?
def on_test_finished(_test)
@itr.stop_coverage
end
end
end
end
Expand Down
2 changes: 2 additions & 0 deletions sig/datadog/ci/test_visibility/recorder.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ module Datadog
def set_inherited_globals: (Hash[untyped, untyped] tags) -> void

def validate_test_suite_level_visibility_correctness: (Datadog::CI::Test test) -> void

def on_test_finished: (Datadog::CI::Test test) -> void
end
end
end
Expand Down

0 comments on commit 6a4c76b

Please sign in to comment.