Skip to content

Fix improper parenting of tests w/ identical names in explorer #1664

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 30, 2025

Conversation

plemarquand
Copy link
Contributor

Two tests in swift-testing can share the same identifier, for instance if you have two identically named tests with the same name but that take arguments of different types, i.e:

@Test(arguments: [1]) func a(_ x: Int) {}
@Test(arguments: ["a"]) func a(_ x: String) {}

In this case sourcekit-lsp provides a disambiguated id with the filename/line number at the end, i.e. TestTarget/a:File.swift:2:2.

The code to synthesize parents in the test explorer when provided with test items that had none didn't take in to account this form of disambiguated id, which lead to these identically named tests being incorrectly synthesized and parented to the wrong test.

Two tests in swift-testing can share the same identifier, for instance
if you have two identically named tests with the same name but that take
arguments of different types, i.e:

```
@test(arguments: [1]) func a(_ x: Int) {}
@test(arguments: ["a"]) func a(_ x: String) {}
```

In this case sourcekit-lsp provides a disambiguated id with the
filename/line number at the end.

The code to synthesize parents in the test explorer when provided with
test items that had none didn't take in to account this form of
disambiguated id, which lead to tests being incorrectly synthesized and
parented to the wrong test.
@plemarquand plemarquand marked this pull request as draft June 28, 2025 20:57
@plemarquand plemarquand force-pushed the file-disambiguated-same-name branch from 67816ef to 08dd7d7 Compare June 29, 2025 18:02
@plemarquand plemarquand marked this pull request as ready for review June 29, 2025 22:50
@plemarquand plemarquand merged commit 6e5c04a into swiftlang:main Jun 30, 2025
18 checks passed
@plemarquand plemarquand deleted the file-disambiguated-same-name branch June 30, 2025 13:53
@award999
Copy link
Contributor

award999 commented Jul 2, 2025

Changelog entry 🙏

@award999 award999 added the needs verification Issue has been fixed, but requires verification before closing label Jul 2, 2025
@award999 award999 moved this to Needs Verification in Swift Extension for Visual Studio Code Jul 2, 2025
@award999 award999 self-assigned this Jul 2, 2025
@award999
Copy link
Contributor

award999 commented Jul 2, 2025

Verified with c3abc77

1 similar comment
@award999
Copy link
Contributor

award999 commented Jul 2, 2025

Verified with c3abc77

@award999 award999 removed the needs verification Issue has been fixed, but requires verification before closing label Jul 2, 2025
@award999 award999 moved this from Needs Verification to Done in Swift Extension for Visual Studio Code Jul 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants