Skip to content

Commit

Permalink
finally working prototype
Browse files Browse the repository at this point in the history
  • Loading branch information
anmarchenko committed Apr 19, 2024
1 parent 39ff720 commit 9d65fb0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
21 changes: 11 additions & 10 deletions lib/datadog/ci/contrib/cucumber/formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,16 @@ def on_test_run_finished(event)
end

def on_test_case_started(event)
::Cucumber::Core::Test::Step.class_eval do
def execute(*args)
test_span = CI.active_test
if test_span&.skipped_by_itr?
@action.skip(*args)
else
@action.execute(*args)
end
end
end
test_suite_name = test_suite_name(event.test_case)

# @type var tags: Hash[String, String]
Expand All @@ -70,27 +80,18 @@ def on_test_case_started(event)

start_test_suite(test_suite_name) unless same_test_suite_as_current?(test_suite_name)

test_span = CI.start_test(
CI.start_test(
event.test_case.name,
test_suite_name,
tags: tags,
service: configuration[:service_name]
)
if test_span&.skipped_by_itr?
p "WANT TO SKIP TEST #{test_span}"
p ::Cucumber::Core::Ast::Tag.new("", "_dd_itr_skip")
event.test_case.tags << ::Cucumber::Core::Ast::Tag.new("", "@_dd_itr_skip")
end
end

def on_test_case_finished(event)
test_span = CI.active_test
return if test_span.nil?

if test_span.skipped_by_itr?
p "DID WE SKIP TEST? answer: #{event.result}"
end

finish_span(test_span, event.result)
@failed_tests_count += 1 if test_span.failed?
end
Expand Down
3 changes: 1 addition & 2 deletions spec/datadog/ci/contrib/cucumber/instrumentation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,7 @@

it "skips the test" do
expect(test_spans).to have(4).items
p test_spans.map { |span| span.get_tag("test.status") }
# expect(test_spans).to all have_skip_status
expect(test_spans).to all have_skip_status
end
end
end
Expand Down

0 comments on commit 9d65fb0

Please sign in to comment.