Module: Datadog::CI::Contrib::Knapsack::Runner::InstanceMethods

Defined in:
lib/datadog/ci/contrib/knapsack/runner.rb

Instance Method Summary collapse

Instance Method Details

#knapsack__run_specs(*args) ⇒ Object

TODO: this is coupled to RSpec integration being present, not sure if it's bad or not at this point



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/datadog/ci/contrib/knapsack/runner.rb', line 18

def knapsack__run_specs(*args)
  return super if ::RSpec.configuration.dry_run? && !datadog_configuration[:dry_run_enabled]
  return super unless datadog_configuration[:enabled]

  # @type var test_session: Datadog::CI::TestSession?
  test_session = test_tracing_component.start_test_session(
    tags: {
      CI::Ext::Test::TAG_FRAMEWORK => CI::Contrib::RSpec::Ext::FRAMEWORK,
      CI::Ext::Test::TAG_FRAMEWORK_VERSION => datadog_integration.version.to_s
    },
    service: datadog_configuration[:service_name]
  )

  # @type var test_module: Datadog::CI::TestModule?
  test_module = test_tracing_component.start_test_module(CI::Contrib::RSpec::Ext::FRAMEWORK)

  return super unless test_module && test_session

  result = nil
  begin
    result = super
  ensure
    [test_module, test_session].each do |span|
      _dd_cleanup { (result == 0) ? span.passed! : span.failed! }
    end
    _dd_cleanup { test_module.finish }
    _dd_cleanup { test_session.finish }
  end
end