Skip to content

Commit f8a269c

Browse files
committed
Only attempt to discover QL tests in on-disk workspace folders
This was only a problem for the new test UI, because the third-party Test Explorer extension we used before must have had this filter in its implementation.
1 parent f0ef985 commit f8a269c

File tree

2 files changed

+26
-16
lines changed

2 files changed

+26
-16
lines changed

extensions/ql-vscode/src/helpers.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -249,15 +249,17 @@ export async function showInformationMessageWithAction(
249249
return chosenItem === actionItem;
250250
}
251251

252+
/** Returns true if the specified workspace folder is on the file system. */
253+
export function isWorkspaceFolderOnDisk(
254+
workspaceFolder: WorkspaceFolder,
255+
): boolean {
256+
return workspaceFolder.uri.scheme === "file";
257+
}
258+
252259
/** Gets all active workspace folders that are on the filesystem. */
253260
export function getOnDiskWorkspaceFoldersObjects() {
254-
const workspaceFolders = workspace.workspaceFolders || [];
255-
const diskWorkspaceFolders: WorkspaceFolder[] = [];
256-
for (const workspaceFolder of workspaceFolders) {
257-
if (workspaceFolder.uri.scheme === "file")
258-
diskWorkspaceFolders.push(workspaceFolder);
259-
}
260-
return diskWorkspaceFolders;
261+
const workspaceFolders = workspace.workspaceFolders ?? [];
262+
return workspaceFolders.filter(isWorkspaceFolderOnDisk);
261263
}
262264

263265
/** Gets all active workspace folders that are on the filesystem. */

extensions/ql-vscode/src/test-manager.ts

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import { BaseLogger, LogOptions } from "./common";
2828
import { TestRunner } from "./test-runner";
2929
import { TestManagerBase } from "./test-manager-base";
3030
import { App } from "./common/app";
31+
import { isWorkspaceFolderOnDisk } from "./helpers";
3132

3233
/**
3334
* Returns the complete text content of the specified file. If there is an error reading the file,
@@ -162,15 +163,22 @@ export class TestManager extends TestManagerBase {
162163
private startTrackingWorkspaceFolders(
163164
workspaceFolders: readonly WorkspaceFolder[],
164165
): void {
165-
for (const workspaceFolder of workspaceFolders) {
166-
const workspaceFolderHandler = new WorkspaceFolderHandler(
167-
workspaceFolder,
168-
this,
169-
this.cliServer,
170-
);
171-
this.track(workspaceFolderHandler);
172-
this.workspaceFolderHandlers.set(workspaceFolder, workspaceFolderHandler);
173-
}
166+
// Only track on-disk workspace folders, to avoid trying to run the CLI test discovery command
167+
// on random URIs.
168+
workspaceFolders
169+
.filter(isWorkspaceFolderOnDisk)
170+
.forEach((workspaceFolder) => {
171+
const workspaceFolderHandler = new WorkspaceFolderHandler(
172+
workspaceFolder,
173+
this,
174+
this.cliServer,
175+
);
176+
this.track(workspaceFolderHandler);
177+
this.workspaceFolderHandlers.set(
178+
workspaceFolder,
179+
workspaceFolderHandler,
180+
);
181+
});
174182
}
175183

176184
/** Stop tracking tests in the specified workspace folders. */

0 commit comments

Comments
 (0)