Class: Datadog::CI::ITR::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/datadog/ci/itr/runner.rb

Overview

Intelligent test runner implementation Integrates with backend to provide test impact analysis data and skip tests that are not impacted by the changes

Instance Method Summary collapse

Constructor Details

#initialize(enabled: false) ⇒ Runner

Returns a new instance of Runner.



13
14
15
16
17
18
19
20
21
# File 'lib/datadog/ci/itr/runner.rb', line 13

def initialize(
  enabled: false
)
  @enabled = enabled
  @test_skipping_enabled = false
  @code_coverage_enabled = false

  Datadog.logger.debug("ITR Runner initialized with enabled: #{@enabled}")
end

Instance Method Details

#code_coverage?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/datadog/ci/itr/runner.rb', line 55

def code_coverage?
  @code_coverage_enabled
end

#configure(remote_configuration, test_session) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/datadog/ci/itr/runner.rb', line 23

def configure(remote_configuration, test_session)
  Datadog.logger.debug("Configuring ITR Runner with remote configuration: #{remote_configuration}")

  @enabled = convert_to_bool(
    remote_configuration.fetch(Ext::Transport::DD_API_SETTINGS_RESPONSE_ITR_ENABLED_KEY, false)
  )
  @test_skipping_enabled = @enabled && convert_to_bool(
    remote_configuration.fetch(Ext::Transport::DD_API_SETTINGS_RESPONSE_TESTS_SKIPPING_KEY, false)
  )
  @code_coverage_enabled = @enabled && convert_to_bool(
    remote_configuration.fetch(Ext::Transport::DD_API_SETTINGS_RESPONSE_CODE_COVERAGE_KEY, false)
  )

  test_session.set_tag(Ext::Test::TAG_ITR_TEST_SKIPPING_ENABLED, @test_skipping_enabled)
  # currently we set this tag when ITR requires collecting code coverage
  # this will change as soon as we implement total code coverage support in this library
  test_session.set_tag(Ext::Test::TAG_CODE_COVERAGE_ENABLED, @code_coverage_enabled)

  # we skip tests, not suites
  test_session.set_tag(Ext::Test::TAG_ITR_TEST_SKIPPING_TYPE, Ext::Test::ITR_TEST_SKIPPING_MODE)

  Datadog.logger.debug("Configured ITR Runner with enabled: #{@enabled}, skipping_tests: #{@test_skipping_enabled}, code_coverage: #{@code_coverage_enabled}")
end

#enabled?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/datadog/ci/itr/runner.rb', line 47

def enabled?
  @enabled
end

#skipping_tests?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/datadog/ci/itr/runner.rb', line 51

def skipping_tests?
  @test_skipping_enabled
end