Module: Datadog::CI::Contrib::Minitest::Runnable::ClassMethods

Defined in:
lib/datadog/ci/contrib/minitest/runnable.rb

Instance Method Summary collapse

Instance Method Details

#run(*args) ⇒ Object



13
14
15
16
17
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
# File 'lib/datadog/ci/contrib/minitest/runnable.rb', line 13

def run(*args)
  return super unless datadog_configuration[:enabled]
  return super if Helpers.parallel?(self)

  method = runnable_methods.first
  return super if method.nil?

  test_suite_name = Helpers.test_suite_name(self, method)
  source_file, line_number = Helpers.extract_source_location_from_class(self)

  test_suite_tags = if source_file
    {
      CI::Ext::Test::TAG_SOURCE_FILE => (Git::LocalRepository.relative_to_root(source_file) if source_file),
      CI::Ext::Test::TAG_SOURCE_START => line_number&.to_s
    }
  else
    {}
  end

  test_suite = test_visibility_component.start_test_suite(
    test_suite_name,
    tags: test_suite_tags
  )

  results = super
  return results unless test_suite

  test_suite.finish

  results
end