a bunch of failing tests

This commit is contained in:
Johannes Rieken 2021-01-29 16:33:25 +01:00
parent 930b5686ff
commit 46cf57b264
17 changed files with 106 additions and 74 deletions

View file

@ -7,9 +7,12 @@ import 'mocha';
import * as assert from 'assert';
import { join } from 'path';
import { commands, workspace, window, Uri, Range, Position, ViewColumn } from 'vscode';
import { assertNoRpc } from '../utils';
suite('vscode API - commands', () => {
teardown(assertNoRpc);
test('getCommands', function (done) {
let p1 = commands.getCommands().then(commands => {

View file

@ -6,9 +6,12 @@
import 'mocha';
import * as assert from 'assert';
import * as vscode from 'vscode';
import { assertNoRpc } from '../utils';
suite('vscode API - configuration', () => {
teardown(assertNoRpc);
test('configurations, language defaults', function () {
const defaultLanguageSettings = vscode.workspace.getConfiguration().get('[abcLang]');

View file

@ -5,11 +5,13 @@
import * as assert from 'assert';
import { debug, workspace, Disposable, commands, window } from 'vscode';
import { disposeAll } from '../utils';
import { assertNoRpc, disposeAll } from '../utils';
import { basename } from 'path';
suite('vscode API - debug', function () {
teardown(assertNoRpc);
test('breakpoints', async function () {
assert.equal(debug.breakpoints.length, 0);
let onDidChangeBreakpointsCounter = 0;

View file

@ -5,11 +5,14 @@
import * as assert from 'assert';
import { workspace, window, Position, Range, commands, TextEditor, TextDocument, TextEditorCursorStyle, TextEditorLineNumbersStyle, SnippetString, Selection, Uri, env } from 'vscode';
import { createRandomFile, deleteFile, closeAllEditors } from '../utils';
import { createRandomFile, deleteFile, closeAllEditors, assertNoRpc } from '../utils';
suite('vscode API - editors', () => {
teardown(closeAllEditors);
teardown(async function () {
assertNoRpc();
await closeAllEditors();
});
function withRandomFileEditor(initialContents: string, run: (editor: TextEditor, doc: TextDocument) => Thenable<void>): Thenable<boolean> {
return createRandomFile(initialContents).then(file => {

View file

@ -5,9 +5,12 @@
import * as assert from 'assert';
import { env, extensions, ExtensionKind, UIKind, Uri } from 'vscode';
import { assertNoRpc } from '../utils';
suite('vscode API - env', () => {
teardown(assertNoRpc);
test('env is set', function () {
assert.equal(typeof env.language, 'string');
assert.equal(typeof env.appRoot, 'string');

View file

@ -6,10 +6,12 @@
import * as assert from 'assert';
import { join } from 'path';
import * as vscode from 'vscode';
import { createRandomFile, testFs } from '../utils';
import { assertNoRpc, createRandomFile, testFs } from '../utils';
suite('vscode API - languages', () => {
teardown(assertNoRpc);
const isWindows = process.platform === 'win32';
function positionToString(p: vscode.Position) {

View file

@ -5,7 +5,7 @@
import * as assert from 'assert';
import { window, commands } from 'vscode';
import { closeAllEditors } from '../utils';
import { assertNoRpc, closeAllEditors } from '../utils';
interface QuickPickExpected {
events: string[];
@ -20,7 +20,10 @@ interface QuickPickExpected {
suite('vscode API - quick input', function () {
teardown(closeAllEditors);
teardown(async function () {
assertNoRpc();
await closeAllEditors();
});
test('createQuickPick, select second', function (_done) {
let done = (err?: any) => {

View file

@ -3,54 +3,11 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as assert from 'assert';
import * as vscode from 'vscode';
import { assertNoRpc } from '../utils';
suite('vscode', function () {
test('rpc protocol, proxies not reachable', function () {
const symProxy = Symbol.for('rpcProxy');
const symProtocol = Symbol.for('rpcProtocol');
const proxyPaths: string[] = [];
const rpcPaths: string[] = [];
function walk(obj: any, path: string, seen: Set<any>) {
if (!obj) {
return;
}
if (typeof obj !== 'object' && typeof obj !== 'function') {
return;
}
if (seen.has(obj)) {
return;
}
seen.add(obj);
if (obj[symProtocol]) {
rpcPaths.push(`PROTOCOL via ${path}`);
}
if (obj[symProxy]) {
proxyPaths.push(`PROXY '${obj[symProxy]}' via ${path}`);
}
for (const key in obj) {
walk(obj[key], `${path}.${String(key)}`, seen);
}
}
try {
walk(vscode, 'vscode', new Set());
} catch (err) {
assert.fail(err);
}
assert.strictEqual(rpcPaths.length, 0, rpcPaths.join('\n'));
assert.strictEqual(proxyPaths.length, 0, proxyPaths.join('\n'));
// todo@jrieken
// this should be run after/before each test because some objects are short lived,
// like notebook-editor, documents etc.
test('no rpc', function () {
assertNoRpc();
});
});

View file

@ -5,6 +5,7 @@
import { window, Pseudoterminal, EventEmitter, TerminalDimensions, workspace, ConfigurationTarget, Disposable, UIKind, env, EnvironmentVariableMutatorType, EnvironmentVariableMutator, extensions, ExtensionContext, TerminalOptions, ExtensionTerminalOptions } from 'vscode';
import { doesNotThrow, equal, ok, deepEqual, throws } from 'assert';
import { assertNoRpc } from '../utils';
// Disable terminal tests:
// - Web https://github.com/microsoft/vscode/issues/92826
@ -30,6 +31,7 @@ import { doesNotThrow, equal, ok, deepEqual, throws } from 'assert';
let disposables: Disposable[] = [];
teardown(() => {
assertNoRpc();
disposables.forEach(d => d.dispose());
disposables.length = 0;
});

View file

@ -6,9 +6,12 @@
import 'mocha';
import * as assert from 'assert';
import * as vscode from 'vscode';
import { assertNoRpc } from '../utils';
suite('vscode API - types', () => {
teardown(assertNoRpc);
test('static properties, es5 compat class', function () {
assert.ok(vscode.ThemeIcon.File instanceof vscode.ThemeIcon);
assert.ok(vscode.ThemeIcon.Folder instanceof vscode.ThemeIcon);

View file

@ -7,7 +7,7 @@ import * as assert from 'assert';
import 'mocha';
import * as os from 'os';
import * as vscode from 'vscode';
import { closeAllEditors, delay, disposeAll } from '../utils';
import { assertNoRpc, closeAllEditors, delay, disposeAll } from '../utils';
const webviewId = 'myWebview';
@ -26,8 +26,8 @@ suite.skip('vscode API - webview', () => {
}
teardown(async () => {
assertNoRpc();
await closeAllEditors();
disposeAll(disposables);
});

View file

@ -6,12 +6,15 @@
import * as assert from 'assert';
import { workspace, window, commands, ViewColumn, TextEditorViewColumnChangeEvent, Uri, Selection, Position, CancellationTokenSource, TextEditorSelectionChangeKind, QuickPickItem, TextEditor } from 'vscode';
import { join } from 'path';
import { closeAllEditors, pathEquals, createRandomFile } from '../utils';
import { closeAllEditors, pathEquals, createRandomFile, assertNoRpc } from '../utils';
suite('vscode API - window', () => {
teardown(closeAllEditors);
teardown(async function () {
assertNoRpc();
await closeAllEditors();
});
test('editor, active text editor', async () => {
const doc = await workspace.openTextDocument(join(workspace.rootPath || '', './far.js'));
@ -429,8 +432,8 @@ suite('vscode API - window', () => {
});
test('showQuickPick, select first two', async function () {
const label = 'showQuickPick, select first two';
let i = 0;
// const label = 'showQuickPick, select first two';
// let i = 0;
const resolves: ((value: string) => void)[] = [];
let done: () => void;
const unexpected = new Promise<void>((resolve, reject) => {
@ -442,26 +445,26 @@ suite('vscode API - window', () => {
canPickMany: true
});
const first = new Promise(resolve => resolves.push(resolve));
console.log(`${label}: ${++i}`);
// console.log(`${label}: ${++i}`);
await new Promise(resolve => setTimeout(resolve, 100)); // Allow UI to update.
console.log(`${label}: ${++i}`);
// console.log(`${label}: ${++i}`);
await commands.executeCommand('workbench.action.quickOpenSelectNext');
console.log(`${label}: ${++i}`);
// console.log(`${label}: ${++i}`);
assert.equal(await first, 'eins');
console.log(`${label}: ${++i}`);
// console.log(`${label}: ${++i}`);
await commands.executeCommand('workbench.action.quickPickManyToggle');
console.log(`${label}: ${++i}`);
// console.log(`${label}: ${++i}`);
const second = new Promise(resolve => resolves.push(resolve));
await commands.executeCommand('workbench.action.quickOpenSelectNext');
console.log(`${label}: ${++i}`);
// console.log(`${label}: ${++i}`);
assert.equal(await second, 'zwei');
console.log(`${label}: ${++i}`);
// console.log(`${label}: ${++i}`);
await commands.executeCommand('workbench.action.quickPickManyToggle');
console.log(`${label}: ${++i}`);
// console.log(`${label}: ${++i}`);
await commands.executeCommand('workbench.action.acceptSelectedQuickOpenItem');
console.log(`${label}: ${++i}`);
// console.log(`${label}: ${++i}`);
assert.deepStrictEqual(await picks, ['eins', 'zwei']);
console.log(`${label}: ${++i}`);
// console.log(`${label}: ${++i}`);
done!();
return unexpected;
});

View file

@ -5,16 +5,15 @@
import * as assert from 'assert';
import * as vscode from 'vscode';
import { createRandomFile, withLogDisabled } from '../utils';
import { assertNoRpc, createRandomFile, disposeAll, withLogDisabled } from '../utils';
suite('vscode API - workspace events', () => {
const disposables: vscode.Disposable[] = [];
teardown(() => {
for (const dispo of disposables) {
dispo.dispose();
}
assertNoRpc();
disposeAll(disposables);
disposables.length = 0;
});

View file

@ -6,6 +6,7 @@
import * as assert from 'assert';
import * as vscode from 'vscode';
import { posix } from 'path';
import { assertNoRpc } from '../utils';
suite('vscode API - workspace-fs', () => {
@ -15,6 +16,8 @@ suite('vscode API - workspace-fs', () => {
root = vscode.workspace.workspaceFolders![0]!.uri;
});
teardown(assertNoRpc);
test('fs.stat', async function () {
const stat = await vscode.workspace.fs.stat(root);
assert.equal(stat.type, vscode.FileType.Directory);

View file

@ -5,6 +5,7 @@
import * as assert from 'assert';
import { window, tasks, Disposable, TaskDefinition, Task, EventEmitter, CustomExecution, Pseudoterminal, TaskScope, commands, env, UIKind, ShellExecution, TaskExecution, Terminal, Event } from 'vscode';
import { assertNoRpc } from '../utils';
// Disable tasks tests:
// - Web https://github.com/microsoft/vscode/issues/90528
@ -14,6 +15,7 @@ import { window, tasks, Disposable, TaskDefinition, Task, EventEmitter, CustomEx
let disposables: Disposable[] = [];
teardown(() => {
assertNoRpc();
disposables.forEach(d => d.dispose());
disposables.length = 0;
});

View file

@ -5,14 +5,17 @@
import * as assert from 'assert';
import * as vscode from 'vscode';
import { createRandomFile, deleteFile, closeAllEditors, pathEquals, rndName, disposeAll, testFs, delay, withLogDisabled, revertAllDirty } from '../utils';
import { createRandomFile, deleteFile, closeAllEditors, pathEquals, rndName, disposeAll, testFs, delay, withLogDisabled, revertAllDirty, assertNoRpc } from '../utils';
import { join, posix, basename } from 'path';
import * as fs from 'fs';
import { TestFS } from '../memfs';
suite('vscode API - workspace', () => {
teardown(closeAllEditors);
teardown(async function () {
assertNoRpc();
await closeAllEditors();
});
test('MarkdownString', function () {
let md = new vscode.MarkdownString();

View file

@ -72,3 +72,44 @@ export function withLogDisabled(runnable: () => Promise<any>): () => Promise<voi
}
};
}
export function assertNoRpc() {
const symProxy = Symbol.for('rpcProxy');
const symProtocol = Symbol.for('rpcProtocol');
const proxyPaths: string[] = [];
const rpcPaths: string[] = [];
function walk(obj: any, path: string, seen: Set<any>) {
if (!obj) {
return;
}
if (typeof obj !== 'object' && typeof obj !== 'function') {
return;
}
if (seen.has(obj)) {
return;
}
seen.add(obj);
if (obj[symProtocol]) {
rpcPaths.push(`PROTOCOL via ${path}`);
}
if (obj[symProxy]) {
proxyPaths.push(`PROXY '${obj[symProxy]}' via ${path}`);
}
for (const key in obj) {
walk(obj[key], `${path}.${String(key)}`, seen);
}
}
try {
walk(vscode, 'vscode', new Set());
} catch (err) {
assert.fail(err);
}
assert.strictEqual(rpcPaths.length, 0, rpcPaths.join('\n'));
assert.strictEqual(proxyPaths.length, 0, proxyPaths.join('\n')); // happens...
}