From 0fb0a6df31fe49ab17a67ef33192aca9e1434699 Mon Sep 17 00:00:00 2001 From: Ladislau Szomoru <3372902+lszomoru@users.noreply.github.com> Date: Wed, 9 Feb 2022 11:26:45 +0100 Subject: [PATCH] Workspace trust - add tracing to track down integration test failure (#142609) --- src/vs/workbench/browser/web.main.ts | 2 +- .../electron-sandbox/desktop.main.ts | 2 +- .../workspaces/common/workspaceTrust.ts | 33 ++++++++++++++++++- .../test/common/workspaceTrust.test.ts | 8 +++-- 4 files changed, 40 insertions(+), 5 deletions(-) diff --git a/src/vs/workbench/browser/web.main.ts b/src/vs/workbench/browser/web.main.ts index 4324f9f3814..2e1995f1b09 100644 --- a/src/vs/workbench/browser/web.main.ts +++ b/src/vs/workbench/browser/web.main.ts @@ -243,7 +243,7 @@ export class BrowserMain extends Disposable { const workspaceTrustEnablementService = new WorkspaceTrustEnablementService(configurationService, environmentService); serviceCollection.set(IWorkspaceTrustEnablementService, workspaceTrustEnablementService); - const workspaceTrustManagementService = new WorkspaceTrustManagementService(configurationService, remoteAuthorityResolverService, storageService, uriIdentityService, environmentService, configurationService, workspaceTrustEnablementService); + const workspaceTrustManagementService = new WorkspaceTrustManagementService(configurationService, remoteAuthorityResolverService, storageService, uriIdentityService, environmentService, configurationService, workspaceTrustEnablementService, logService); serviceCollection.set(IWorkspaceTrustManagementService, workspaceTrustManagementService); // Update workspace trust so that configuration is updated accordingly diff --git a/src/vs/workbench/electron-sandbox/desktop.main.ts b/src/vs/workbench/electron-sandbox/desktop.main.ts index 17d292a9972..0e904ced751 100644 --- a/src/vs/workbench/electron-sandbox/desktop.main.ts +++ b/src/vs/workbench/electron-sandbox/desktop.main.ts @@ -284,7 +284,7 @@ export class DesktopMain extends Disposable { const workspaceTrustEnablementService = new WorkspaceTrustEnablementService(configurationService, environmentService); serviceCollection.set(IWorkspaceTrustEnablementService, workspaceTrustEnablementService); - const workspaceTrustManagementService = new WorkspaceTrustManagementService(configurationService, remoteAuthorityResolverService, storageService, uriIdentityService, environmentService, configurationService, workspaceTrustEnablementService); + const workspaceTrustManagementService = new WorkspaceTrustManagementService(configurationService, remoteAuthorityResolverService, storageService, uriIdentityService, environmentService, configurationService, workspaceTrustEnablementService, logService); serviceCollection.set(IWorkspaceTrustManagementService, workspaceTrustManagementService); // Update workspace trust so that configuration is updated accordingly diff --git a/src/vs/workbench/services/workspaces/common/workspaceTrust.ts b/src/vs/workbench/services/workspaces/common/workspaceTrust.ts index 6350502d33b..2d52bf4edc9 100644 --- a/src/vs/workbench/services/workspaces/common/workspaceTrust.ts +++ b/src/vs/workbench/services/workspaces/common/workspaceTrust.ts @@ -21,6 +21,8 @@ import { Memento, MementoObject } from 'vs/workbench/common/memento'; import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService'; import { IUriIdentityService } from 'vs/platform/uriIdentity/common/uriIdentity'; import { isEqualAuthority } from 'vs/base/common/resources'; +import { ILogService } from 'vs/platform/log/common/log'; +import { isCI } from 'vs/base/common/platform'; export const WORKSPACE_TRUST_ENABLED = 'security.workspace.trust.enabled'; export const WORKSPACE_TRUST_STARTUP_PROMPT = 'security.workspace.trust.startupPrompt'; @@ -117,7 +119,8 @@ export class WorkspaceTrustManagementService extends Disposable implements IWork @IUriIdentityService private readonly uriIdentityService: IUriIdentityService, @IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService, @IWorkspaceContextService private readonly workspaceService: IWorkspaceContextService, - @IWorkspaceTrustEnablementService private readonly workspaceTrustEnablementService: IWorkspaceTrustEnablementService + @IWorkspaceTrustEnablementService private readonly workspaceTrustEnablementService: IWorkspaceTrustEnablementService, + @ILogService protected readonly _logService: ILogService, ) { super(); @@ -144,6 +147,10 @@ export class WorkspaceTrustManagementService extends Disposable implements IWork //#region initialize private initializeWorkspaceTrust(): void { + if (isCI) { + this._logService.info(`Enter initializeWorkspaceTrust()...`); + } + // Resolve canonical Uris this.resolveCanonicalUris() .then(async () => { @@ -151,8 +158,16 @@ export class WorkspaceTrustManagementService extends Disposable implements IWork await this.updateWorkspaceTrust(); }) .finally(() => { + if (isCI) { + this._logService.info(`Open workspaceResolved gate...`); + } + this._workspaceResolvedPromiseResolve(); if (!this.environmentService.remoteAuthority) { + if (isCI) { + this._logService.info(`Open workspaceTrustInitialized gate...`); + } + this._workspaceTrustInitializedPromiseResolve(); } }); @@ -212,6 +227,10 @@ export class WorkspaceTrustManagementService extends Disposable implements IWork } private async resolveCanonicalUris(): Promise { + if (isCI) { + this._logService.info('Enter resolveCanonicalUris()...'); + } + // Open editors const filesToOpen: IPath[] = []; if (this.environmentService.filesToOpenOrCreate) { @@ -239,6 +258,10 @@ export class WorkspaceTrustManagementService extends Disposable implements IWork } this._canonicalWorkspace = new CanonicalWorkspace(this.workspaceService.getWorkspace(), canonicalWorkspaceFolders, canonicalWorkspaceConfiguration); + + if (isCI) { + this._logService.info('Exit resolveCanonicalUris()...'); + } } private loadTrustInfo(): IWorkspaceTrustInfo { @@ -320,7 +343,15 @@ export class WorkspaceTrustManagementService extends Disposable implements IWork } private async updateWorkspaceTrust(trusted?: boolean): Promise { + if (isCI) { + this._logService.info(`Enter updateWorkspaceTrust()...`); + } + if (!this.workspaceTrustEnablementService.isWorkspaceTrustEnabled()) { + if (isCI) { + this._logService.info(`Workspace trust is disabled.`); + } + return; } diff --git a/src/vs/workbench/services/workspaces/test/common/workspaceTrust.test.ts b/src/vs/workbench/services/workspaces/test/common/workspaceTrust.test.ts index cb8808efc50..da388396897 100644 --- a/src/vs/workbench/services/workspaces/test/common/workspaceTrust.test.ts +++ b/src/vs/workbench/services/workspaces/test/common/workspaceTrust.test.ts @@ -10,7 +10,7 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService'; import { FileService } from 'vs/platform/files/common/fileService'; import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock'; -import { NullLogService } from 'vs/platform/log/common/log'; +import { ILogService, NullLogService } from 'vs/platform/log/common/log'; import { IRemoteAuthorityResolverService } from 'vs/platform/remote/common/remoteAuthorityResolver'; import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage'; import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace'; @@ -28,6 +28,7 @@ suite('Workspace Trust', () => { let instantiationService: TestInstantiationService; let configurationService: TestConfigurationService; let environmentService: IWorkbenchEnvironmentService; + let logService: ILogService; setup(async () => { instantiationService = new TestInstantiationService(); @@ -38,7 +39,10 @@ suite('Workspace Trust', () => { environmentService = {} as IWorkbenchEnvironmentService; instantiationService.stub(IWorkbenchEnvironmentService, environmentService); - instantiationService.stub(IUriIdentityService, new UriIdentityService(new FileService(new NullLogService()))); + logService = new NullLogService(); + instantiationService.stub(ILogService, logService); + + instantiationService.stub(IUriIdentityService, new UriIdentityService(new FileService(logService))); instantiationService.stub(IRemoteAuthorityResolverService, new class extends mock() { }); });