Sha256: 55f8d951a13cfbb849f4f33a87fe36a6e8540376ccce86b797b2fc7f87f98830

Contents?: true

Size: 1.03 KB

Versions: 6

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true

require_relative "../ext/test"

module Datadog
  module CI
    module TestVisibility
      module TotalCoverage
        def self.extract_lines_pct(test_session)
          unless defined?(::SimpleCov)
            Datadog.logger.debug("SimpleCov is not loaded, skipping code coverage extraction")
            return
          end

          unless ::SimpleCov.running
            Datadog.logger.debug("SimpleCov is not running, skipping code coverage extraction")
            return
          end

          unless ::SimpleCov.respond_to?(:__dd_peek_result)
            Datadog.logger.debug("SimpleCov is not patched, skipping code coverage extraction")
            return
          end

          result = ::SimpleCov.__dd_peek_result
          unless result
            Datadog.logger.debug("SimpleCov result is nil, skipping code coverage extraction")
            return
          end

          test_session.set_tag(Ext::Test::TAG_CODE_COVERAGE_LINES_PCT, result.covered_percent)
        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/test_visibility/total_coverage.rb
datadog-ci-1.10.0 lib/datadog/ci/test_visibility/total_coverage.rb
datadog-ci-1.9.0 lib/datadog/ci/test_visibility/total_coverage.rb
datadog-ci-1.8.1 lib/datadog/ci/test_visibility/total_coverage.rb
datadog-ci-1.8.0 lib/datadog/ci/test_visibility/total_coverage.rb
datadog-ci-1.7.0 lib/datadog/ci/test_visibility/total_coverage.rb