Skip to content

Commit 70a0a73

Browse files
committed
add option to disable the test controller
1 parent c2fc9ac commit 70a0a73

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,12 @@
425425
"default": true,
426426
"markdownDescription": "Enable/disable inlay hints for namespaces.",
427427
"scope": "resource"
428+
},
429+
"robotcode.testExplorer.enabled": {
430+
"type": "boolean",
431+
"default": true,
432+
"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.",
433+
"scope": "resource"
428434
}
429435
}
430436
},

vscode-client/testcontrollermanager.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ class WorkspaceFolderEntry {
127127
}
128128
}
129129

130+
const testExplorerIsEnabled = (workspace: vscode.WorkspaceFolder) =>
131+
vscode.workspace.getConfiguration("robotcode.testExplorer", workspace).get<boolean>("enabled");
132+
130133
export class TestControllerManager {
131134
private _disposables: vscode.Disposable;
132135
public readonly testController: vscode.TestController;
@@ -194,6 +197,17 @@ export class TestControllerManager {
194197
(_) => undefined,
195198
);
196199
}),
200+
vscode.workspace.onDidChangeConfiguration((event) => {
201+
for (const ws of vscode.workspace.workspaceFolders ?? []) {
202+
if (event.affectsConfiguration("robotcode.testExplorer", ws)) {
203+
if (testExplorerIsEnabled(ws)) {
204+
this.refresh().catch((_) => undefined);
205+
} else {
206+
if (ws) this.removeWorkspaceFolderItems(ws);
207+
}
208+
}
209+
}
210+
}),
197211
vscode.workspace.onDidCloseTextDocument((document) => this.refreshDocument(document)),
198212
vscode.workspace.onDidSaveTextDocument((document) => this.refreshDocument(document)),
199213
vscode.workspace.onDidOpenTextDocument((document) => this.refreshDocument(document)),
@@ -884,7 +898,7 @@ export class TestControllerManager {
884898
const addedIds = new Set<string>();
885899

886900
for (const folder of vscode.workspace.workspaceFolders ?? []) {
887-
if (token?.isCancellationRequested) return;
901+
if (token?.isCancellationRequested || !testExplorerIsEnabled(folder)) return;
888902

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

0 commit comments

Comments
 (0)