Sha256: 7215d1987639262e914aeb2ce116974d5dbdc1e7695882518d1e5e26c07eb2c5
Contents?: true
Size: 1.7 KB
Versions: 2
Compression:
Stored size: 1.7 KB
Contents
# frozen_string_literal: true module Datadog module CI module Contrib module Minitest # Lifecycle hooks to instrument Minitest::Test module Hooks def before_setup super return unless configuration[:enabled] test_name = "#{class_name}##{name}" path, = method(name).source_location test_suite = Pathname.new(path.to_s).relative_path_from(Pathname.pwd).to_s span = CI::Test.trace( configuration[:operation_name], { span_options: { resource: test_name, service: configuration[:service_name] }, framework: Ext::FRAMEWORK, framework_version: CI::Contrib::Minitest::Integration.version.to_s, test_name: test_name, test_suite: test_suite, test_type: Ext::TEST_TYPE } ) Thread.current[:_datadog_test_span] = span end def after_teardown span = Thread.current[:_datadog_test_span] return super unless span Thread.current[:_datadog_test_span] = nil case result_code when "." CI::Test.passed!(span) when "E", "F" CI::Test.failed!(span, failure) when "S" CI::Test.skipped!(span) span.set_tag(CI::Ext::Test::TAG_SKIP_REASON, failure.message) end span.finish super end private def configuration ::Datadog.configuration.ci[:minitest] end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
datadog-ci-0.1.1 | lib/datadog/ci/contrib/minitest/hooks.rb |
datadog-ci-0.1.0 | lib/datadog/ci/contrib/minitest/hooks.rb |