Skip to content

Don't prepend target id to test ids if it exists #941

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

Conversation

plemarquand
Copy link
Contributor

@plemarquand plemarquand commented Jun 27, 2024

With swiftlang/sourcekit-lsp#1530, sourcekit-lsp will start prepending a test target's name to the test id. This helps disambiguate when there are two identically named suites in two different test targets.

To maintain the current behaviour with older sourcekit-lsp versions only prefix the test target if it isn't already there.

sourcekit-lsp will start prepending a test target's name to the test id.
This helps disambiguate when there are two identically named suites in
two different test targets.

To maintain the current behaviour with older sourcekit-lsp versions
only prefix the test target if it isn't already there.
const id =
target !== undefined && !item.id.startsWith(`${target.c99name}.`)
? `${target.c99name}.${item.id}`
: item.id;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the test not be is id of form target.class/method return id else find the target and prefix to id.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check applies to both XCTest and swift-testing tests. Swift-testing can have tests in the form target.method(), target.struct/method(), target.struct/anotherstruct/method(), etc... so it seems safer to check if the test has already been prefixed with the target instead of trying to match the test id form exactly.

@plemarquand plemarquand merged commit 862f8d5 into swiftlang:main Jul 1, 2024
8 checks passed
@plemarquand plemarquand deleted the dont-prepend-target-id-to-test-ids branch July 1, 2024 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Issues with tests in classes with the same name but in different targets
3 participants