Sha256: 1336e15f3ba70f74d8dfdb371c8bbb8736cfe5292e68da241b59d737d7e62dd9

Contents?: true

Size: 1.55 KB

Versions: 6

Compression:

Stored size: 1.55 KB

Contents

require_relative "helpers"

module Datadog
  module CI
    module Contrib
      module Minitest
        module Runnable
          def self.included(base)
            base.singleton_class.prepend(ClassMethods)
          end

          module ClassMethods
            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

            private

            def datadog_configuration
              Datadog.configuration.ci[:minitest]
            end

            def test_visibility_component
              Datadog.send(:components).test_visibility
            end
          end
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
datadog-ci-1.11.0 lib/datadog/ci/contrib/minitest/runnable.rb
datadog-ci-1.10.0 lib/datadog/ci/contrib/minitest/runnable.rb
datadog-ci-1.9.0 lib/datadog/ci/contrib/minitest/runnable.rb
datadog-ci-1.8.1 lib/datadog/ci/contrib/minitest/runnable.rb
datadog-ci-1.8.0 lib/datadog/ci/contrib/minitest/runnable.rb
datadog-ci-1.7.0 lib/datadog/ci/contrib/minitest/runnable.rb