Skip to content

Commit ca5bd33

Browse files
committed
Mock out getTarget in LSP tests to avoid loading real package info
1 parent 88b606a commit ca5bd33

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

src/commands/generateSourcekitConfiguration.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -130,16 +130,9 @@ async function checkURLExists(url: string): Promise<boolean> {
130130
export async function determineSchemaURL(folderContext: FolderContext): Promise<string> {
131131
const version = folderContext.toolchain.swiftVersion;
132132
const versionString = `${version.major}.${version.minor}`;
133+
let branch =
134+
configuration.lspConfigurationBranch || (version.dev ? "main" : `release/${versionString}`);
133135

134-
// If configuration branch is set, use it
135-
if (configuration.lspConfigurationBranch) {
136-
return schemaURL(configuration.lspConfigurationBranch);
137-
}
138-
139-
// Determine branch based on version
140-
let branch = version.dev ? "main" : `release/${versionString}`;
141-
142-
// Check if the branch-specific URL exists, fallback to main if not
143136
if (!(await checkURLExists(schemaURL(branch)))) {
144137
branch = "main";
145138
}

test/integration-tests/testexplorer/LSPTestDiscovery.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ suite("LSPTestDiscovery Suite", () => {
8888
beforeEach(async function () {
8989
this.timeout(10000000);
9090
pkg = await SwiftPackage.create(file);
91+
92+
// Provde an undefined target as a mock to avoid loading actual package info.
93+
pkg.getTarget = () => Promise.resolve(undefined);
94+
9195
client = new TestLanguageClient();
9296
discoverer = new LSPTestDiscovery(
9397
instance(

0 commit comments

Comments
 (0)