From c1fdf81475da9d7a20a6e30e91660dd8c82c4305 Mon Sep 17 00:00:00 2001 From: Andrey Date: Tue, 24 Sep 2024 12:36:08 +0200 Subject: [PATCH] don't report test suite source locations when test suite is an anonymous class in minitest --- lib/datadog/ci/contrib/minitest/runnable.rb | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/datadog/ci/contrib/minitest/runnable.rb b/lib/datadog/ci/contrib/minitest/runnable.rb index e8e2ba6d..2cb96d40 100644 --- a/lib/datadog/ci/contrib/minitest/runnable.rb +++ b/lib/datadog/ci/contrib/minitest/runnable.rb @@ -20,12 +20,18 @@ def run(*args) test_suite_name = Helpers.test_suite_name(self, method) source_file, line_number = Helpers.extract_source_location_from_class(self) - test_suite = test_visibility_component.start_test_suite( - test_suite_name, - tags: { + 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 + + test_suite = test_visibility_component.start_test_suite( + test_suite_name, + tags: test_suite_tags ) results = super