Skip to content

Commit 9332099

Browse files
committed
feat(vscode): add option to disable the vscodes test explorer/execution integration
closes #204
1 parent 9a8a635 commit 9332099

File tree

2 files changed

+32
-16
lines changed

2 files changed

+32
-16
lines changed

package.json

+12-6
Original file line numberDiff line numberDiff line change
@@ -428,12 +428,6 @@
428428
"default": true,
429429
"markdownDescription": "Enable/disable inlay hints for namespaces.",
430430
"scope": "resource"
431-
},
432-
"robotcode.testExplorer.enabled": {
433-
"type": "boolean",
434-
"default": true,
435-
"description": "Whether to show robot tests in the test explorer. You may want to disable this if you are using another tool to run robot tests.",
436-
"scope": "resource"
437431
}
438432
}
439433
},
@@ -887,6 +881,18 @@
887881
"description": "Starts the internal HTTP server only if needed."
888882
}
889883
}
884+
},
885+
{
886+
"title": "Test Explorer",
887+
"type": "object",
888+
"properties": {
889+
"robotcode.testExplorer.enabled": {
890+
"type": "boolean",
891+
"default": true,
892+
"description": "Enable/disable whether Robot Framework tests and tasks are integrated into the VSCode Test/Test Explorer view.",
893+
"scope": "resource"
894+
}
895+
}
890896
}
891897
],
892898
"commands": [

vscode-client/testcontrollermanager.ts

+20-10
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,6 @@ class WorkspaceFolderEntry {
127127
}
128128
}
129129

130-
const testExplorerIsEnabled = (workspace: vscode.WorkspaceFolder) =>
131-
vscode.workspace.getConfiguration("robotcode.testExplorer", workspace).get<boolean>("enabled");
132-
133130
export class TestControllerManager {
134131
private _disposables: vscode.Disposable;
135132
public readonly testController: vscode.TestController;
@@ -197,16 +194,19 @@ export class TestControllerManager {
197194
(_) => undefined,
198195
);
199196
}),
200-
vscode.workspace.onDidChangeConfiguration((event) => {
197+
vscode.workspace.onDidChangeConfiguration(async (event) => {
198+
let refresh = false;
199+
201200
for (const ws of vscode.workspace.workspaceFolders ?? []) {
202201
if (event.affectsConfiguration("robotcode.testExplorer", ws)) {
203-
if (testExplorerIsEnabled(ws)) {
204-
this.refresh().catch((_) => undefined);
205-
} else {
206-
if (ws) this.removeWorkspaceFolderItems(ws);
207-
}
202+
refresh = true;
208203
}
209204
}
205+
206+
if (refresh) {
207+
await this.refreshWorkspace();
208+
await this.updateRunProfiles();
209+
}
210210
}),
211211
vscode.workspace.onDidCloseTextDocument((document) => this.refreshDocument(document)),
212212
vscode.workspace.onDidSaveTextDocument((document) => this.refreshDocument(document)),
@@ -308,6 +308,8 @@ export class TestControllerManager {
308308
const multiFolders = (vscode.workspace.workspaceFolders?.length ?? 0) > 1;
309309

310310
for (const folder of vscode.workspace.workspaceFolders ?? []) {
311+
if (!this.isTestExplorerEnabledForWorkspace(folder)) continue;
312+
311313
const folderTag = this.getFolderTag(folder);
312314

313315
const folderName = multiFolders ? ` [${folder.name}]` : "";
@@ -831,6 +833,12 @@ export class TestControllerManager {
831833
}
832834
}
833835

836+
// eslint-disable-next-line class-methods-use-this
837+
private isTestExplorerEnabledForWorkspace(workspace: vscode.WorkspaceFolder): boolean {
838+
const result = vscode.workspace.getConfiguration(CONFIG_SECTION, workspace).get<boolean>("testExplorer.enabled");
839+
return result === undefined || result;
840+
}
841+
834842
private async refreshItem(item?: vscode.TestItem, token?: vscode.CancellationToken): Promise<void> {
835843
if (token?.isCancellationRequested) return;
836844

@@ -898,7 +906,9 @@ export class TestControllerManager {
898906
const addedIds = new Set<string>();
899907

900908
for (const folder of vscode.workspace.workspaceFolders ?? []) {
901-
if (token?.isCancellationRequested || !testExplorerIsEnabled(folder)) return;
909+
if (token?.isCancellationRequested) return;
910+
911+
if (!this.isTestExplorerEnabledForWorkspace(folder)) continue;
902912

903913
if (this.robotTestItems.get(folder) === undefined || !this.robotTestItems.get(folder)?.valid) {
904914
const items = await this.getTestsFromWorkspaceFolder(folder, token);

0 commit comments

Comments
 (0)