Sha256: 5b930541984a5dace78e74f0bf4dd243a0e9b1acbf5c7a9a3a2e0fdf78f60bfe

Contents?: true

Size: 1.53 KB

Versions: 6

Compression:

Stored size: 1.53 KB

Contents

# frozen_string_literal: true

require_relative "concurrent_span"
require_relative "ext/test"

module Datadog
  module CI
    # Represents the whole test session process.
    # Documentation on test sessions is here:
    # https://docs.datadoghq.com/continuous_integration/explorer/?tab=testruns#sessions
    # This object can be shared between multiple threads.
    #
    # @public_api
    class TestSession < ConcurrentSpan
      # Finishes the current test session.
      # @return [void]
      def finish
        recorder.deactivate_test_session

        super
      end

      # Return the test session's name which is equal to test command used
      # @return [String] the command for this test session.
      def name
        get_tag(Ext::Test::TAG_COMMAND)
      end

      def skipping_tests?
        get_tag(Ext::Test::TAG_ITR_TEST_SKIPPING_ENABLED) == "true"
      end

      def code_coverage?
        get_tag(Ext::Test::TAG_CODE_COVERAGE_ENABLED) == "true"
      end

      # Return the test session tags that could be inherited by sub-spans
      # @return [Hash] the tags to be inherited by sub-spans.
      def inheritable_tags
        return @inheritable_tags if defined?(@inheritable_tags)

        # this method is not synchronized because it does not iterate over the tags collection, but rather
        # uses synchronized method #get_tag to get each tag value
        res = {}
        Ext::Test::INHERITABLE_TAGS.each do |tag|
          res[tag] = get_tag(tag)
        end
        @inheritable_tags = res.freeze
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
datadog-ci-1.1.0 lib/datadog/ci/test_session.rb
datadog-ci-1.0.1 lib/datadog/ci/test_session.rb
datadog-ci-1.0.0 lib/datadog/ci/test_session.rb
datadog-ci-1.0.0.beta6 lib/datadog/ci/test_session.rb
datadog-ci-1.0.0.beta3 lib/datadog/ci/test_session.rb
datadog-ci-1.0.0.beta2 lib/datadog/ci/test_session.rb