[SDTEST-3795] Fix nested Swift Testing @Suite crash#253
Merged
Conversation
Nested @suite types crashed when `.datadogTesting` was applied. Build the suite identifier from the full enclosing-type chain (e.g. `Outer.Inner`), gate suite_end emission on whether any tests ran inside, and normalize the module name (`_` → `-`) so XCTest and Swift Testing converge on the same Module instance for a given bundle. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Verifies the function-lines lookup resolves nested-type symbols (`STNestedSuite.Inner.nestedPass()`) into the suite-qualified key used by `AdditionalTagsFeature`. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
calvinbayer
approved these changes
May 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
@Suitetypes crashed when.datadogTestingwas applied, because the trait keyed tests by the outermost type only while suite registration used the innermost, so the inner suite ran tests it had never been told about.Testing.Test.ddSuitenow joins the full enclosing-type chain (e.g.Outer.Inner) so the registry, function-lines lookup, and span tags all agree on one identifier per suite._with-in both the Swift Testing (ddModule) and XCTest (bundleName) paths, so the same bundle yields a singleModuleinstance no matter which framework reachesmodule(named:)first.Suite.internalEndskipstest_suite_endemission when no tests started in that suite — container types that only enclose nested@Suites and the XCTest wrapper-suite no longer generate empty suite events.Test plan
DDSuiteNamingTests— new unit tests assertddSuitereturns the full dotted chain for top-level, single-nested, and doubly-nested suites.ObserverTesterTraitnow keys its expected dictionary by suite-qualified test name to avoid collisions across nested suites.nestedSuitePassintegration test (IntegrationTests-UnitTests) asserts: onetest_suite_end(STNestedSuite.Inner), onetest_module_end, onetest_session_end.Mocks.TestBase.set(skipped:)), so nested-type symbol lookup works without further changes.🤖 Generated with Claude Code