Skip to content

Commit 862f8d5

Browse files
authored
Don't prepend target id to test ids if it exists (#941)
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.
1 parent a2b7ff4 commit 862f8d5

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/TestExplorer/LSPTestDiscovery.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,12 @@ export class LSPTestDiscovery {
148148
.getTargets(TargetType.test)
149149
.find(target => swiftPackage.getTarget(location.uri.fsPath) === target);
150150

151-
const id = target !== undefined ? `${target.c99name}.${item.id}` : item.id;
151+
// If we're using an older sourcekit-lsp it doesn't prepend the target name
152+
// to the test item id.
153+
const id =
154+
target !== undefined && !item.id.startsWith(`${target.c99name}.`)
155+
? `${target.c99name}.${item.id}`
156+
: item.id;
152157
return item.style === "XCTest" ? id.replace(/\(\)$/, "") : id;
153158
}
154159
}

0 commit comments

Comments
 (0)