chore(vscode): update to 1.54.2
This commit is contained in:
@@ -17,7 +17,7 @@ vscode.workspace.registerFileSystemProvider(testFs.scheme, testFs, { isCaseSensi
|
||||
export async function createRandomFile(contents = '', dir: vscode.Uri | undefined = undefined, ext = ''): Promise<vscode.Uri> {
|
||||
let fakeFile: vscode.Uri;
|
||||
if (dir) {
|
||||
assert.equal(dir.scheme, testFs.scheme);
|
||||
assert.strictEqual(dir.scheme, testFs.scheme);
|
||||
fakeFile = dir.with({ path: dir.path + '/' + rndName() + ext });
|
||||
} else {
|
||||
fakeFile = vscode.Uri.parse(`${testFs.scheme}:/${rndName() + ext}`);
|
||||
@@ -48,6 +48,10 @@ export function closeAllEditors(): Thenable<any> {
|
||||
return vscode.commands.executeCommand('workbench.action.closeAllEditors');
|
||||
}
|
||||
|
||||
export function saveAllEditors(): Thenable<any> {
|
||||
return vscode.commands.executeCommand('workbench.action.files.saveAll');
|
||||
}
|
||||
|
||||
export async function revertAllDirty(): Promise<void> {
|
||||
return vscode.commands.executeCommand('_workbench.revertAllDirty');
|
||||
}
|
||||
@@ -72,3 +76,64 @@ export function withLogDisabled(runnable: () => Promise<any>): () => Promise<voi
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export function assertNoRpc() {
|
||||
assertNoRpcFromEntry([vscode, 'vscode']);
|
||||
}
|
||||
|
||||
export function assertNoRpcFromEntry(entry: [obj: any, name: string]) {
|
||||
|
||||
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(entry[0], entry[1], new Set());
|
||||
} catch (err) {
|
||||
assert.fail(err);
|
||||
}
|
||||
assert.strictEqual(rpcPaths.length, 0, rpcPaths.join('\n'));
|
||||
assert.strictEqual(proxyPaths.length, 0, proxyPaths.join('\n')); // happens...
|
||||
}
|
||||
|
||||
export async function asPromise<T>(event: vscode.Event<T>, timeout = 5000): Promise<T> {
|
||||
return new Promise<T>((resolve, reject) => {
|
||||
|
||||
const handle = setTimeout(() => {
|
||||
sub.dispose();
|
||||
reject(new Error('asPromise TIMEOUT reached'));
|
||||
}, timeout);
|
||||
|
||||
const sub = event(e => {
|
||||
clearTimeout(handle);
|
||||
sub.dispose();
|
||||
resolve(e);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user