Skip to content

Commit

Permalink
rename Ci::Test to CI::Recorder
Browse files Browse the repository at this point in the history
  • Loading branch information
anmarchenko committed Sep 18, 2023
1 parent f741f3a commit 48f786b
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 25 deletions.
19 changes: 9 additions & 10 deletions lib/datadog/ci/contrib/cucumber/formatter.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# frozen_string_literal: true

require_relative "../../test"
require_relative "../../ext/app_types"
require_relative "../../ext/environment"
require_relative "../../recorder"
require_relative "../../ext/test"
require_relative "ext"
require_relative "integration"

module Datadog
module CI
Expand All @@ -30,7 +29,7 @@ def bind_events(config)
end

def on_test_case_started(event)
@current_feature_span = CI::Test.trace(
@current_feature_span = CI::Recorder.trace(
configuration[:operation_name],
{
span_options: {
Expand All @@ -50,11 +49,11 @@ def on_test_case_finished(event)
return if @current_feature_span.nil?

if event.result.skipped?
CI::Test.skipped!(@current_feature_span)
CI::Recorder.skipped!(@current_feature_span)
elsif event.result.ok?
CI::Test.passed!(@current_feature_span)
CI::Recorder.passed!(@current_feature_span)
elsif event.result.failed?
CI::Test.failed!(@current_feature_span)
CI::Recorder.failed!(@current_feature_span)
end

@current_feature_span.finish
Expand All @@ -72,11 +71,11 @@ def on_test_step_finished(event)
return if @current_step_span.nil?

if event.result.skipped?
CI::Test.skipped!(@current_step_span, event.result.exception)
CI::Recorder.skipped!(@current_step_span, event.result.exception)
elsif event.result.ok?
CI::Test.passed!(@current_step_span)
CI::Recorder.passed!(@current_step_span)
elsif event.result.failed?
CI::Test.failed!(@current_step_span, event.result.exception)
CI::Recorder.failed!(@current_step_span, event.result.exception)
end

@current_step_span.finish
Expand Down
13 changes: 9 additions & 4 deletions lib/datadog/ci/contrib/minitest/hooks.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# frozen_string_literal: true

require_relative "../../recorder"
require_relative "../../ext/test"
require_relative "ext"
require_relative "integration"

module Datadog
module CI
module Contrib
Expand All @@ -15,7 +20,7 @@ def before_setup
path, = method(name).source_location
test_suite = Pathname.new(path.to_s).relative_path_from(Pathname.pwd).to_s

span = CI::Test.trace(
span = CI::Recorder.trace(
configuration[:operation_name],
{
span_options: {
Expand All @@ -41,11 +46,11 @@ def after_teardown

case result_code
when "."
CI::Test.passed!(span)
CI::Recorder.passed!(span)
when "E", "F"
CI::Test.failed!(span, failure)
CI::Recorder.failed!(span, failure)
when "S"
CI::Test.skipped!(span)
CI::Recorder.skipped!(span)
span.set_tag(CI::Ext::Test::TAG_SKIP_REASON, failure.message)
end

Expand Down
14 changes: 6 additions & 8 deletions lib/datadog/ci/contrib/rspec/example.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
# frozen_string_literal: true

require_relative "../../test"

require_relative "../../ext/app_types"
require_relative "../../ext/environment"
require_relative "../../recorder"
require_relative "../../ext/test"
require_relative "ext"
require_relative "integration"

module Datadog
module CI
Expand All @@ -28,7 +26,7 @@ def run(example_group_instance, reporter)
test_name += " #{description}"
end

CI::Test.trace(
CI::Recorder.trace(
configuration[:operation_name],
{
span_options: {
Expand All @@ -46,11 +44,11 @@ def run(example_group_instance, reporter)

case execution_result.status
when :passed
CI::Test.passed!(span)
CI::Recorder.passed!(span)
when :failed
CI::Test.failed!(span, execution_result.exception)
CI::Recorder.failed!(span, execution_result.exception)
else
CI::Test.skipped!(span, execution_result.exception) if execution_result.example_skipped?
CI::Recorder.skipped!(span, execution_result.exception) if execution_result.example_skipped?
end

result
Expand Down
2 changes: 1 addition & 1 deletion lib/datadog/ci/test.rb → lib/datadog/ci/recorder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
module Datadog
module CI
# Common behavior for CI tests
module Test
module Recorder
# Creates a new span for a CI test
def self.trace(span_name, options = {})
span_options = {
Expand Down
2 changes: 1 addition & 1 deletion sig/datadog/ci/test.rbs → sig/datadog/ci/recorder.rbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Datadog
module CI
module Test
module Recorder
self.@environment_tags: Hash[String, String]

def self.trace: (untyped span_name, ?::Hash[untyped, untyped] options) ?{ (untyped, untyped) -> untyped } -> untyped
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
RSpec.describe Datadog::CI::Test do
RSpec.describe Datadog::CI::Recorder do
let(:trace_op) { instance_double(Datadog::Tracing::TraceOperation) }
let(:span_name) { "span name" }

Expand Down

0 comments on commit 48f786b

Please sign in to comment.