Bug: Xcode gutter diamond reports "0 tests" for Swift Testing suites nested 4+ levels deep
## Description
Clicking the Xcode gutter diamond to run an individual `@Test` function reports "0 tests" when the test is nested 4+ levels deep (3+ enclosing `@Suite` types). Running all tests via Cmd+U or `swift test` discovers and runs the test correctly.
SourceKit-LSP produces the correct `TestItem` hierarchy (verified via existing test `DocumentTestDiscoveryTests.testSwiftTestingTestWithNestedRawIdentifiers`). The issue appears to be in Xcode's test filter construction when routing gutter diamond clicks to the swift-testing runner.
## Environment
- **Swift version**: Apple Swift version 6.2.4 (swiftlang-6.2.4.1.4 clang-1700.6.4.2)
- **Target**: arm64-apple-macosx26.0
- **Xcode**: 26.0 beta
## Minimal Reproduction (7 lines)
```swift
import Testing
@Suite struct A {
@Suite struct B {
@Suite struct C {
@Test func bug() { #expect(Bool(true)) }
}
}
}
```
## Reproduction Repository
https://github.com/coenttb/swift-issue-testing-xcode-nested-suite-filter
## To Reproduce
```bash
git clone https://github.com/coenttb/swift-issue-testing-xcode-nested-suite-filter
cd swift-issue-testing-xcode-nested-suite-filter
swift test # Both tests pass
```
Then open in Xcode:
1. Click the gutter diamond next to `bug()` (depth 4) → reports "0 tests"
2. Click the gutter diamond next to `works()` (depth 3) → runs correctly
3. Press Cmd+U → both tests run and pass
## Verified Test Results
| Test | Depth | `swift test` | Cmd+U | Gutter Diamond |
|------|-------|--------------|-------|----------------|
| `X.Y.works()` | 3 | ✅ | ✅ | ✅ |
| `A.B.C.bug()` | 4 | ✅ | ✅ | ❌ 0 tests |
**Key finding**: The boundary is exactly depth 3 → 4. Removing any one nesting level makes the gutter diamond work. Backticks, raw identifiers, cross-module extensions, and `@testable import` are NOT required.
## Apple Feedback
Filed as FB22115546.
## Related Issues
- #524 — Same symptom pattern (gutter diamond fails, Cmd+U works; tracked as rdar://131227159)
- [sourcekit-lsp#1218](https://github.com/swiftlang/sourcekit-lsp/issues/1218) — Tests in extensions not nested correctly in `textDocument/tests` (tracked as rdar://127491907)
0 条评论