Skip to content

Commit

Permalink
Revert fix #68 and rely on workspace trust instead
Browse files Browse the repository at this point in the history
  • Loading branch information
fredericbonnet committed May 4, 2024
1 parent c405884 commit 9fd1620
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 17 deletions.
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
18 changes: 2 additions & 16 deletions src/cmake-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
);
Expand Down

0 comments on commit 9fd1620

Please sign in to comment.