From 9fd1620fa38bf5699b4b72219f4441c4daf1c9ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Bonnet?= Date: Sat, 4 May 2024 21:51:34 +0200 Subject: [PATCH] Revert fix #68 and rely on workspace trust instead See https://code.visualstudio.com/api/extension-guides/workspace-trust --- package.json | 6 ++++++ src/cmake-adapter.ts | 18 ++---------------- src/main.ts | 2 +- 3 files changed, 9 insertions(+), 17 deletions(-) diff --git a/package.json b/package.json index f799a12..dbbffad 100644 --- a/package.json +++ b/package.json @@ -159,5 +159,11 @@ } } } + }, + "capabilities": { + "untrustedWorkspaces": { + "supported": false, + "description": "This extension requires running the CTest executable from the location specified in the CMakeCache.txt file of the workspace folder" + } } } diff --git a/src/cmake-adapter.ts b/src/cmake-adapter.ts index 6e1f4a0..02d96ae 100644 --- a/src/cmake-adapter.ts +++ b/src/cmake-adapter.ts @@ -90,8 +90,7 @@ export class CmakeAdapter implements TestAdapter { constructor( public readonly workspaceFolder: vscode.WorkspaceFolder, - private readonly log: Log, - private readonly context: vscode.ExtensionContext + private readonly log: Log ) { this.log.info('Initializing CMake test adapter'); @@ -220,22 +219,9 @@ export class CmakeAdapter implements TestAdapter { 'testLineVar', ]); - // Resolve and check CTest path + // Resolve CTest path const dir = path.resolve(this.workspaceFolder.uri.fsPath, buildDir); const ctestPath = getCtestPath(dir); - const currentPath = this.context.workspaceState.get('ctestPath'); - if (currentPath != ctestPath) { - const answer = await vscode.window.showWarningMessage( - `The CMake Test Explorer extension detected the following CTest path: "${ctestPath}". Do you allow execution of this file?`, - 'Allow', - 'Deny' - ); - if (answer != 'Allow') { - throw new Error(`CTest execution denied: "${ctestPath}"`); - } - // Record path for next time - this.context.workspaceState.update('ctestPath', ctestPath); - } // Load CTest test list this.ctestPath = ctestPath; diff --git a/src/main.ts b/src/main.ts index 669895a..7cee605 100644 --- a/src/main.ts +++ b/src/main.ts @@ -63,7 +63,7 @@ export async function activate(context: vscode.ExtensionContext) { context.subscriptions.push( new TestAdapterRegistrar( testHub, - (workspaceFolder) => new CmakeAdapter(workspaceFolder, log, context), + (workspaceFolder) => new CmakeAdapter(workspaceFolder, log), log ) );