Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/TestExplorer/LSPTestDiscovery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,12 @@ export class LSPTestDiscovery {
.getTargets(TargetType.test)
.find(target => swiftPackage.getTarget(location.uri.fsPath) === target);

const id = target !== undefined ? `${target.c99name}.${item.id}` : item.id;
// If we're using an older sourcekit-lsp it doesn't prepend the target name
// to the test item id.
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.

return item.style === "XCTest" ? id.replace(/\(\)$/, "") : id;
}
}