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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
# File 'lib/datadog/ci/contrib/rspec/example.rb', line 19
def run(*args)
return super if ::RSpec.configuration.dry_run? && !datadog_configuration[:dry_run_enabled]
return super unless datadog_configuration[:enabled]
test_name = full_description.strip
if metadata[:description].empty?
test_name << " #{description}"
end
test_suite_description = fetch_top_level_example_group[:description]
suite_name = "#{test_suite_description} at #{metadata[:example_group][:rerun_file_path]}"
test_name = test_name.sub(test_suite_description, "").strip
if ci_queue?
suite_name = "#{suite_name} (ci-queue running example [#{test_name}])"
ci_queue_test_span = test_visibility_component.start_test_suite(suite_name)
end
@skip_reporting = true
test_retries_component.with_retries do
test_visibility_component.trace_test(
test_name,
suite_name,
tags: {
CI::Ext::Test::TAG_FRAMEWORK => Ext::FRAMEWORK,
CI::Ext::Test::TAG_FRAMEWORK_VERSION => CI::Contrib::RSpec::Integration.version.to_s,
CI::Ext::Test::TAG_SOURCE_FILE => Git::LocalRepository.relative_to_root(metadata[:file_path]),
CI::Ext::Test::TAG_SOURCE_START => metadata[:line_number].to_s,
CI::Ext::Test::TAG_PARAMETERS => Utils::TestRun.test_parameters(
metadata: {"scoped_id" => metadata[:scoped_id]}
)
},
service: datadog_configuration[:service_name]
) do |test_span|
test_span&.itr_unskippable! if metadata[CI::Ext::Test::ITR_UNSKIPPABLE_OPTION]
metadata[:skip] = CI::Ext::Test::ITR_TEST_SKIP_REASON if test_span&.skipped_by_itr?
@exception = nil
result = super
return result if ::RSpec.world.wants_to_quit
case execution_result.status
when :passed
test_span&.passed!
when :failed
test_span&.failed!(exception: execution_result.exception)
@exception = nil if test_span&.any_retry_passed?
else
test_span&.skipped!(
reason: execution_result.pending_message,
exception: execution_result.pending_exception
)
end
end
end
ci_queue_test_span&.finish
@skip_reporting = false
finish(reporter)
end
|