From b0eff48b18c792b25d2b1b5b0bafbeaf747c0888 Mon Sep 17 00:00:00 2001 From: Connor Peet Date: Mon, 19 Apr 2021 12:43:49 -0700 Subject: [PATCH] testing: adopt workspace trust for testing Fixes #2047 --- product.json | 2 +- .../contrib/testing/common/testServiceImpl.ts | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/product.json b/product.json index d6769946ad948..58d4cbaf078fc 100644 --- a/product.json +++ b/product.json @@ -48,7 +48,7 @@ }, { "name": "ms-vscode.node-debug2", - "version": "1.42.5", + "version": "1.42.6", "repo": "https://github.com/microsoft/vscode-node-debug2", "metadata": { "id": "36d19e17-7569-4841-a001-947eb18602b2", diff --git a/src/vs/workbench/contrib/testing/common/testServiceImpl.ts b/src/vs/workbench/contrib/testing/common/testServiceImpl.ts index 850e17a2cd418..0cd4a5515dfd9 100644 --- a/src/vs/workbench/contrib/testing/common/testServiceImpl.ts +++ b/src/vs/workbench/contrib/testing/common/testServiceImpl.ts @@ -14,6 +14,7 @@ import { localize } from 'vs/nls'; import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { INotificationService } from 'vs/platform/notification/common/notification'; import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage'; +import { IWorkspaceTrustRequestService } from 'vs/platform/workspace/common/workspaceTrust'; import { ExtHostTestingResource } from 'vs/workbench/api/common/extHost.protocol'; import { MutableObservableValue } from 'vs/workbench/contrib/testing/common/observableValue'; import { StoredValue } from 'vs/workbench/contrib/testing/common/storedValue'; @@ -64,6 +65,7 @@ export class TestService extends Disposable implements ITestService { @IStorageService private readonly storageService: IStorageService, @INotificationService private readonly notificationService: INotificationService, @ITestResultService private readonly testResults: ITestResultService, + @IWorkspaceTrustRequestService private readonly workspaceTrustRequestService: IWorkspaceTrustRequestService, ) { super(); this.providerCount = TestingContextKeys.providerCount.bindTo(contextKeyService); @@ -195,6 +197,15 @@ export class TestService extends Disposable implements ITestService { } const result = this.testResults.createLiveResult(req); + const trust = await this.workspaceTrustRequestService.requestWorkspaceTrust({ + modal: true, + message: localize('testTrust', "Running tests may execute code in your workspace."), + }); + + if (!trust) { + return result; + } + const testsWithIds = req.tests.map(test => { if (test.src) { return test as TestIdWithSrc;