testing: adopt workspace trust for testing

Fixes #2047
This commit is contained in:
Connor Peet 2021-04-19 12:43:49 -07:00
parent 94894dfe7f
commit b0eff48b18
No known key found for this signature in database
GPG key ID: CF8FD2EA0DBC61BD
2 changed files with 12 additions and 1 deletions

View file

@ -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",

View file

@ -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;