Module: Datadog::CI::Contrib::Minitest::Helpers
- Defined in:
- lib/datadog/ci/contrib/minitest/helpers.rb
Defined Under Namespace
Modules: RunnableClassMethods
Class Method Summary
collapse
Class Method Details
.ci_queue? ⇒ Boolean
100
101
102
|
# File 'lib/datadog/ci/contrib/minitest/helpers.rb', line 100
def self.ci_queue?
!!(defined?(::Minitest::Queue) && ::Minitest.singleton_class.ancestors.include?(::Minitest::Queue))
end
|
83
84
85
86
87
88
89
|
# File 'lib/datadog/ci/contrib/minitest/helpers.rb', line 83
def self.(klass, method_name)
source_location = (klass)
if source_location.nil? || source_location.empty?
return klass.instance_method(method_name).source_location
end
source_location
end
|
.parallel?(klass) ⇒ Boolean
96
97
98
|
# File 'lib/datadog/ci/contrib/minitest/helpers.rb', line 96
def self.parallel?(klass)
klass.ancestors.include?(::Minitest::Parallel::Test) || ci_queue?
end
|
.skip_test_suite(test_suite) ⇒ Object
91
92
93
94
|
# File 'lib/datadog/ci/contrib/minitest/helpers.rb', line 91
def self.skip_test_suite(test_suite)
test_suite&.finish
[]
end
|
.start_test_suite(klass) ⇒ Object
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
|
# File 'lib/datadog/ci/contrib/minitest/helpers.rb', line 35
def self.start_test_suite(klass)
method = klass.runnable_methods.first
return nil if method.nil?
test_suite_name = test_suite_name(klass, method)
source_file, line_number = (klass, method)
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
if klass.dd_any_unskippable?
test_suite_tags[CI::Ext::Test::TAG_ITR_UNSKIPPABLE] = "true"
end
test_tracing_component = Datadog.send(:components).test_tracing
test_suite = test_tracing_component.start_test_suite(
test_suite_name,
tags: test_suite_tags
)
test_suite&.set_expected_tests!(klass.runnable_methods)
test_suite
end
|
.test_suite_name(klass, method_name) ⇒ Object
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
# File 'lib/datadog/ci/contrib/minitest/helpers.rb', line 64
def self.test_suite_name(klass, method_name)
source_location = (klass, method_name)&.first
source_file_path = Pathname.new(source_location.to_s)
if source_file_path.absolute?
source_file_path = source_file_path.relative_path_from(Pathname.pwd).to_s
end
"#{klass.name} at #{source_file_path}"
end
|