diff --git a/lib/datadog/ci/contrib/rspec/example_group.rb b/lib/datadog/ci/contrib/rspec/example_group.rb index 47941101..a18a1900 100644 --- a/lib/datadog/ci/contrib/rspec/example_group.rb +++ b/lib/datadog/ci/contrib/rspec/example_group.rb @@ -21,7 +21,13 @@ def run(reporter = ::RSpec::Core::NullReporter) return super unless top_level? suite_name = "#{description} at #{file_path}" - test_suite = test_visibility_component.start_test_suite(suite_name) + test_suite = test_visibility_component.start_test_suite( + suite_name, + tags: { + 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 + } + ) success = super return success unless test_suite diff --git a/lib/datadog/ci/test_visibility/component.rb b/lib/datadog/ci/test_visibility/component.rb index 67503874..f9edb3b8 100644 --- a/lib/datadog/ci/test_visibility/component.rb +++ b/lib/datadog/ci/test_visibility/component.rb @@ -166,6 +166,8 @@ def on_test_module_started(test_module) end def on_test_suite_started(test_suite) + # set_codeowners(test_suite) + Telemetry.event_created(test_suite) end diff --git a/spec/datadog/ci/contrib/rspec/instrumentation_spec.rb b/spec/datadog/ci/contrib/rspec/instrumentation_spec.rb index 3e9779af..26d9d5d8 100644 --- a/spec/datadog/ci/contrib/rspec/instrumentation_spec.rb +++ b/spec/datadog/ci/contrib/rspec/instrumentation_spec.rb @@ -506,7 +506,7 @@ def expect_failure context "with git root changed" do before do - expect(Datadog::CI::Git::LocalRepository).to receive(:root).and_return("#{Dir.pwd}/spec") + allow(Datadog::CI::Git::LocalRepository).to receive(:root).and_return("#{Dir.pwd}/spec") end it "provides source file path relative to git root" do @@ -588,6 +588,13 @@ def expect_failure :framework_version, Datadog::CI::Contrib::RSpec::Integration.version.to_s ) + + expect(first_test_suite_span).to have_test_tag( + :source_file, + "spec/datadog/ci/contrib/rspec/instrumentation_spec.rb" + ) + expect(first_test_suite_span).to have_test_tag(:source_start, "57") + expect(first_test_suite_span).to have_pass_status end diff --git a/vendor/rbs/rspec/0/rspec.rbs b/vendor/rbs/rspec/0/rspec.rbs index 82fe6d6d..0e82dd72 100644 --- a/vendor/rbs/rspec/0/rspec.rbs +++ b/vendor/rbs/rspec/0/rspec.rbs @@ -38,6 +38,7 @@ module RSpec::Core::ExampleGroup def top_level?: () -> bool def file_path: () -> String def description: () -> String + def metadata: () -> untyped end end