tests - reduce output of integration tests (#84283)

This commit is contained in:
Benjamin Pasero 2020-01-15 12:56:15 +01:00
parent a3a53d730c
commit 2585092dbe
10 changed files with 87 additions and 53 deletions

View file

@ -5,7 +5,7 @@
import * as assert from 'assert';
import * as vscode from 'vscode';
import { createRandomFile } from '../utils';
import { createRandomFile, withLogDisabled } from '../utils';
suite('workspace-event', () => {
@ -66,7 +66,7 @@ suite('workspace-event', () => {
assert.equal(baseDoc.getText(), 'HALLO_NEW');
});
test('onWillCreate/onDidCreate, make changes, edit new file fails', async function () {
test('onWillCreate/onDidCreate, make changes, edit new file fails', withLogDisabled(async function () {
const base = await createRandomFile();
@ -86,7 +86,7 @@ suite('workspace-event', () => {
assert.equal((await vscode.workspace.fs.readFile(newUri)).toString(), '');
assert.equal((await vscode.workspace.openTextDocument(newUri)).getText(), '');
});
}));
test('onWillDelete/onDidDelete', async function () {

View file

@ -5,7 +5,7 @@
import * as assert from 'assert';
import * as vscode from 'vscode';
import { createRandomFile, deleteFile, closeAllEditors, pathEquals, rndName, disposeAll, testFs, delay } from '../utils';
import { createRandomFile, deleteFile, closeAllEditors, pathEquals, rndName, disposeAll, testFs, delay, withLogDisabled } from '../utils';
import { join, posix, basename } from 'path';
import * as fs from 'fs';
@ -598,7 +598,7 @@ suite('workspace-namespace', () => {
assert.equal(doc.isDirty, true);
});
test('applyEdit should fail when editing deleted resource', async () => {
test('applyEdit should fail when editing deleted resource', withLogDisabled(async () => {
const resource = await createRandomFile();
const edit = new vscode.WorkspaceEdit();
@ -607,9 +607,9 @@ suite('workspace-namespace', () => {
let success = await vscode.workspace.applyEdit(edit);
assert.equal(success, false);
});
}));
test('applyEdit should fail when renaming deleted resource', async () => {
test('applyEdit should fail when renaming deleted resource', withLogDisabled(async () => {
const resource = await createRandomFile();
const edit = new vscode.WorkspaceEdit();
@ -618,9 +618,9 @@ suite('workspace-namespace', () => {
let success = await vscode.workspace.applyEdit(edit);
assert.equal(success, false);
});
}));
test('applyEdit should fail when editing renamed from resource', async () => {
test('applyEdit should fail when editing renamed from resource', withLogDisabled(async () => {
const resource = await createRandomFile();
const newResource = vscode.Uri.file(resource.fsPath + '.1');
const edit = new vscode.WorkspaceEdit();
@ -629,7 +629,7 @@ suite('workspace-namespace', () => {
let success = await vscode.workspace.applyEdit(edit);
assert.equal(success, false);
});
}));
test('applyEdit "edit A -> rename A to B -> edit B"', async () => {
await testEditRenameEdit(oldUri => oldUri.with({ path: oldUri.path + 'NEW' }));
@ -662,7 +662,7 @@ suite('workspace-namespace', () => {
return uri.with({ path: posix.join(posix.dirname(uri.path), `_${posix.basename(uri.path)}`) });
}
test('WorkspaceEdit: applying edits before and after rename duplicates resource #42633', async function () {
test('WorkspaceEdit: applying edits before and after rename duplicates resource #42633', withLogDisabled(async function () {
let docUri = await createRandomFile();
let newUri = nameWithUnderscore(docUri);
@ -675,9 +675,9 @@ suite('workspace-namespace', () => {
assert.ok(await vscode.workspace.applyEdit(we));
let doc = await vscode.workspace.openTextDocument(newUri);
assert.equal(doc.getText(), 'BarHelloFoo');
});
}));
test('WorkspaceEdit: Problem recreating a renamed resource #42634', async function () {
test('WorkspaceEdit: Problem recreating a renamed resource #42634', withLogDisabled(async function () {
let docUri = await createRandomFile();
let newUri = nameWithUnderscore(docUri);
@ -695,9 +695,9 @@ suite('workspace-namespace', () => {
assert.equal(newDoc.getText(), 'HelloFoo');
let doc = await vscode.workspace.openTextDocument(docUri);
assert.equal(doc.getText(), 'Bar');
});
}));
test('WorkspaceEdit api - after saving a deleted file, it still shows up as deleted. #42667', async function () {
test('WorkspaceEdit api - after saving a deleted file, it still shows up as deleted. #42667', withLogDisabled(async function () {
let docUri = await createRandomFile();
let we = new vscode.WorkspaceEdit();
we.deleteFile(docUri);
@ -710,7 +710,7 @@ suite('workspace-namespace', () => {
} catch (e) {
assert.ok(true);
}
});
}));
test('WorkspaceEdit: edit and rename parent folder duplicates resource #42641', async function () {
@ -741,7 +741,7 @@ suite('workspace-namespace', () => {
assert.equal(doc.getText(), 'Hello');
});
test('WorkspaceEdit: rename resource followed by edit does not work #42638', async function () {
test('WorkspaceEdit: rename resource followed by edit does not work #42638', withLogDisabled(async function () {
let docUri = await createRandomFile();
let newUri = nameWithUnderscore(docUri);
@ -753,9 +753,9 @@ suite('workspace-namespace', () => {
let doc = await vscode.workspace.openTextDocument(newUri);
assert.equal(doc.getText(), 'Hello');
});
}));
test('WorkspaceEdit: create & override', async function () {
test('WorkspaceEdit: create & override', withLogDisabled(async function () {
let docUri = await createRandomFile('before');
@ -768,9 +768,9 @@ suite('workspace-namespace', () => {
we.createFile(docUri, { overwrite: true });
assert.ok(await vscode.workspace.applyEdit(we));
assert.equal((await vscode.workspace.openTextDocument(docUri)).getText(), '');
});
}));
test('WorkspaceEdit: create & ignoreIfExists', async function () {
test('WorkspaceEdit: create & ignoreIfExists', withLogDisabled(async function () {
let docUri = await createRandomFile('before');
let we = new vscode.WorkspaceEdit();
@ -782,9 +782,9 @@ suite('workspace-namespace', () => {
we.createFile(docUri, { overwrite: true, ignoreIfExists: true });
assert.ok(await vscode.workspace.applyEdit(we));
assert.equal((await vscode.workspace.openTextDocument(docUri)).getText(), '');
});
}));
test('WorkspaceEdit: rename & ignoreIfExists', async function () {
test('WorkspaceEdit: rename & ignoreIfExists', withLogDisabled(async function () {
let aUri = await createRandomFile('aaa');
let bUri = await createRandomFile('bbb');
@ -803,9 +803,9 @@ suite('workspace-namespace', () => {
we = new vscode.WorkspaceEdit();
we.renameFile(aUri, bUri, { overwrite: true, ignoreIfExists: true });
assert.ok(await vscode.workspace.applyEdit(we));
});
}));
test('WorkspaceEdit: delete & ignoreIfNotExists', async function () {
test('WorkspaceEdit: delete & ignoreIfNotExists', withLogDisabled(async function () {
let docUri = await createRandomFile();
let we = new vscode.WorkspaceEdit();
@ -819,7 +819,7 @@ suite('workspace-namespace', () => {
we = new vscode.WorkspaceEdit();
we.deleteFile(docUri, { ignoreIfNotExists: true });
assert.ok(await vscode.workspace.applyEdit(we));
});
}));
test('WorkspaceEdit: insert & rename multiple', async function () {

View file

@ -70,3 +70,16 @@ function isTestTypeActive(): boolean {
export function delay(ms: number) {
return new Promise(resolve => setTimeout(resolve, ms));
}
export function withLogDisabled(runnable: () => Promise<any>): () => Promise<void> {
return async (): Promise<void> => {
const logLevel = await vscode.commands.executeCommand('_extensionTests.getLogLevel');
await vscode.commands.executeCommand('_extensionTests.setLogLevel', 6 /* critical */);
try {
await runnable();
} finally {
await vscode.commands.executeCommand('_extensionTests.setLogLevel', logLevel);
}
};
}

View file

@ -1007,22 +1007,22 @@ export class CodeWindow extends Disposable implements ICodeWindow {
switch (visibility) {
case ('default'):
this._win.setMenuBarVisibility(!isFullscreen);
this._win.setAutoHideMenuBar(isFullscreen);
this._win.autoHideMenuBar = isFullscreen;
break;
case ('visible'):
this._win.setMenuBarVisibility(true);
this._win.setAutoHideMenuBar(false);
this._win.autoHideMenuBar = false;
break;
case ('toggle'):
this._win.setMenuBarVisibility(false);
this._win.setAutoHideMenuBar(true);
this._win.autoHideMenuBar = true;
break;
case ('hidden'):
this._win.setMenuBarVisibility(false);
this._win.setAutoHideMenuBar(false);
this._win.autoHideMenuBar = false;
break;
}
}

View file

@ -77,6 +77,8 @@ export class FollowerLogService extends DelegatedLogService implements ILogServi
}
setLevel(level: LogLevel): void {
super.setLevel(level);
this.master.setLevel(level);
}
}

View file

@ -50,6 +50,10 @@ export abstract class AbstractUpdateService implements IUpdateService {
@IRequestService protected requestService: IRequestService,
@ILogService protected logService: ILogService,
) {
if (!this.environmentService.isBuilt) {
return; // updates are never enabled when running out of sources
}
if (this.environmentService.disableUpdates) {
this.logService.info('update#ctor - updates are disabled by the environment');
return;

View file

@ -14,6 +14,8 @@ import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation
import { IOpenWindowOptions, IWindowOpenable, IOpenEmptyWindowOptions } from 'vs/platform/windows/common/windows';
import { IWorkspacesService, hasWorkspaceFileExtension, IRecent } from 'vs/platform/workspaces/common/workspaces';
import { Schemas } from 'vs/base/common/network';
import { ILogService } from 'vs/platform/log/common/log';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
// -----------------------------------------------------------------
// The following commands are registered on both sides separately.
@ -237,3 +239,18 @@ CommandsRegistry.registerCommand({
}]
}
});
CommandsRegistry.registerCommand('_extensionTests.setLogLevel', function (accessor: ServicesAccessor, level: number) {
const logService = accessor.get(ILogService);
const environmentService = accessor.get(IEnvironmentService);
if (environmentService.isExtensionDevelopment && !!environmentService.extensionTestsLocationURI) {
logService.setLevel(level);
}
});
CommandsRegistry.registerCommand('_extensionTests.getLogLevel', function (accessor: ServicesAccessor) {
const logService = accessor.get(ILogService);
return logService.getLevel();
});

View file

@ -32,10 +32,6 @@ export function registerFileProtocol(
}
return callback({ error: -2 /* FAILED: https://cs.chromium.org/chromium/src/net/base/net_error_list.h */ });
}, (error) => {
if (error) {
console.error(`Failed to register '${protocol}' protocol`);
}
});
}

View file

@ -34,6 +34,6 @@ export function parseExtensionDevOptions(environmentService: IEnvironmentService
isExtensionDevHost,
isExtensionDevDebug,
isExtensionDevDebugBrk,
isExtensionDevTestFromCli,
isExtensionDevTestFromCli
};
}

View file

@ -199,7 +199,7 @@ export class ExtensionHostProcessWorker implements IExtensionHostStarter {
onDebouncedOutput(output => {
const inspectorUrlMatch = output.data && output.data.match(/ws:\/\/([^\s]+:(\d+)\/[^\s]+)/);
if (inspectorUrlMatch) {
if (!this._environmentService.isBuilt) {
if (!this._environmentService.isBuilt && !this._isExtensionDevTestFromCli) {
console.log(`%c[Extension Host] %cdebugger inspector at chrome-devtools://devtools/bundled/inspector.html?experiments=true&v8only=true&ws=${inspectorUrlMatch[1]}`, 'color: blue', 'color:');
}
if (!this._inspectPort) {
@ -207,9 +207,11 @@ export class ExtensionHostProcessWorker implements IExtensionHostStarter {
this._onDidSetInspectPort.fire();
}
} else {
console.group('Extension Host');
console.log(output.data, ...output.format);
console.groupEnd();
if (!this._isExtensionDevTestFromCli) {
console.group('Extension Host');
console.log(output.data, ...output.format);
console.groupEnd();
}
}
});
@ -292,22 +294,22 @@ export class ExtensionHostProcessWorker implements IExtensionHostStarter {
const expected = this._environmentService.debugExtensionHost.port;
const port = await findFreePort(expected, 10 /* try 10 ports */, 5000 /* try up to 5 seconds */);
if (!port) {
console.warn('%c[Extension Host] %cCould not find a free port for debugging', 'color: blue', 'color:');
return 0;
if (!this._isExtensionDevTestFromCli) {
if (!port) {
console.warn('%c[Extension Host] %cCould not find a free port for debugging', 'color: blue', 'color:');
} else {
if (port !== expected) {
console.warn(`%c[Extension Host] %cProvided debugging port ${expected} is not free, using ${port} instead.`, 'color: blue', 'color:');
}
if (this._isExtensionDevDebugBrk) {
console.warn(`%c[Extension Host] %cSTOPPED on first line for debugging on port ${port}`, 'color: blue', 'color:');
} else {
console.info(`%c[Extension Host] %cdebugger listening on port ${port}`, 'color: blue', 'color:');
}
}
}
if (port !== expected) {
console.warn(`%c[Extension Host] %cProvided debugging port ${expected} is not free, using ${port} instead.`, 'color: blue', 'color:');
}
if (this._isExtensionDevDebugBrk) {
console.warn(`%c[Extension Host] %cSTOPPED on first line for debugging on port ${port}`, 'color: blue', 'color:');
} else {
console.info(`%c[Extension Host] %cdebugger listening on port ${port}`, 'color: blue', 'color:');
}
return port;
return port || 0;
}
private _tryExtHostHandshake(): Promise<PersistentProtocol> {