chore(vscode): update to 1.55.2

This commit is contained in:
Akash Satheesan
2021-04-09 11:32:27 +05:30
1102 changed files with 39988 additions and 23544 deletions

View File

@@ -49,80 +49,6 @@ suite('Arrays', () => {
assertMedian(13, [13, 4, 8], 2);
});
test('stableSort', () => {
function fill<T>(num: number, valueFn: () => T, arr: T[] = []): T[] {
for (let i = 0; i < num; i++) {
arr[i] = valueFn();
}
return arr;
}
let counter = 0;
let data = fill(10000, () => ({ n: 1, m: counter++ }));
arrays.mergeSort(data, (a, b) => a.n - b.n);
let lastM = -1;
for (const element of data) {
assert.ok(lastM < element.m);
lastM = element.m;
}
});
test('mergeSort', () => {
let data = arrays.mergeSort([6, 5, 3, 1, 8, 7, 2, 4], (a, b) => a - b);
assert.deepStrictEqual(data, [1, 2, 3, 4, 5, 6, 7, 8]);
});
test('mergeSort, sorted array', function () {
let data = arrays.mergeSort([1, 2, 3, 4, 5, 6], (a, b) => a - b);
assert.deepStrictEqual(data, [1, 2, 3, 4, 5, 6]);
});
test('mergeSort, is stable', function () {
let numbers = arrays.mergeSort([33, 22, 11, 4, 99, 1], (a, b) => 0);
assert.deepStrictEqual(numbers, [33, 22, 11, 4, 99, 1]);
});
test('mergeSort, many random numbers', function () {
function compare(a: number, b: number) {
if (a < b) {
return -1;
} else if (a > b) {
return 1;
} else {
return 0;
}
}
function assertSorted(array: number[]) {
let last = array[0];
for (let i = 1; i < array.length; i++) {
let n = array[i];
if (last > n) {
assert.fail(JSON.stringify(array.slice(i - 10, i + 10)));
}
}
}
const MAX = 101;
const data: number[][] = [];
for (let i = 1; i < MAX; i++) {
let array: number[] = [];
for (let j = 0; j < 10 + i; j++) {
array.push(Math.random() * 10e8 | 0);
}
data.push(array);
}
for (const array of data) {
arrays.mergeSort(array, compare);
assertSorted(array);
}
});
test('sortedDiff', () => {
function compare(a: number, b: number): number {
return a - b;

View File

@@ -88,7 +88,8 @@ suite('Buffer', () => {
await timeout(0);
stream.write(VSBuffer.fromString('Hello'));
await timeout(0);
stream.end(new Error());
stream.error(new Error());
stream.end();
assert.strictEqual(chunks.length, 1);
assert.strictEqual(chunks[0].toString(), 'Hello');
@@ -329,7 +330,8 @@ suite('Buffer', () => {
await timeout(0);
stream.write(VSBuffer.fromString('Hello'));
await timeout(0);
stream.end(new Error());
stream.error(new Error());
stream.end();
assert.strictEqual(chunks.length, 0);
assert.strictEqual(ended, false);

View File

@@ -66,6 +66,10 @@ suite('Stream', () => {
stream.error(new Error());
assert.strictEqual(error, true);
error = false;
stream.error(new Error());
assert.strictEqual(error, true);
stream.end('Final Bit');
assert.strictEqual(chunks.length, 4);
assert.strictEqual(chunks[3], 'Final Bit');
@@ -86,6 +90,15 @@ suite('Stream', () => {
assert.strictEqual(result, '');
});
test('WriteableStream - end with error works', async () => {
const reducer = (errors: Error[]) => errors.length > 0 ? errors[0] : null as unknown as Error;
const stream = newWriteableStream<Error>(reducer);
stream.end(new Error('error'));
const result = await consumeStream(stream, reducer);
assert.ok(result instanceof Error);
});
test('WriteableStream - removeListener', () => {
const stream = newWriteableStream<string>(strings => strings.join());

View File

@@ -28,3 +28,14 @@ export function testRepeat(n: number, description: string, callback: (this: any)
test(`${description} (iteration ${i})`, callback);
}
}
export async function assertThrowsAsync(block: () => any, message: string | Error = 'Missing expected exception'): Promise<void> {
try {
await block();
} catch {
return;
}
const err = message instanceof Error ? message : new Error(message);
throw err;
}

View File

@@ -8,9 +8,9 @@ import { join } from 'vs/base/common/path';
import { tmpdir } from 'os';
import { promises } from 'fs';
import { rimraf, writeFile } from 'vs/base/node/pfs';
import { getRandomTestPath } from 'vs/base/test/node/testUtils';
import { flakySuite, getRandomTestPath } from 'vs/base/test/node/testUtils';
suite('Crypto', () => {
flakySuite('Crypto', () => {
let testDir: string;

View File

@@ -10,10 +10,9 @@ import { join, sep } from 'vs/base/common/path';
import { generateUuid } from 'vs/base/common/uuid';
import { copy, exists, move, readdir, readDirsInDir, rimraf, RimRafMode, rimrafSync, SymlinkSupport, writeFile, writeFileSync } from 'vs/base/node/pfs';
import { timeout } from 'vs/base/common/async';
import { getPathFromAmdModule } from 'vs/base/common/amd';
import { canNormalize } from 'vs/base/common/normalization';
import { VSBuffer } from 'vs/base/common/buffer';
import { flakySuite, getRandomTestPath } from 'vs/base/test/node/testUtils';
import { flakySuite, getRandomTestPath, getPathFromAmdModule } from 'vs/base/test/node/testUtils';
import { isWindows } from 'vs/base/common/platform';
flakySuite('PFS', function () {
@@ -232,14 +231,19 @@ flakySuite('PFS', function () {
assert.ok(!symbolicLink2);
}
// Copy ignores dangling symlinks
// Copy does not fail over dangling symlinks
await rimraf(copyTarget);
await rimraf(symbolicLinkTarget);
await copy(symLink, copyTarget, { preserveSymlinks: true }); // this should not throw
assert.ok(!fs.existsSync(copyTarget));
if (!isWindows) {
const { symbolicLink } = await SymlinkSupport.stat(copyTarget);
assert.ok(symbolicLink?.dangling);
} else {
assert.ok(!fs.existsSync(copyTarget));
}
});
test('copy handles symbolic links when the reference is inside source', async () => {

View File

@@ -8,7 +8,7 @@ import * as cp from 'child_process';
import * as objects from 'vs/base/common/objects';
import * as platform from 'vs/base/common/platform';
import * as processes from 'vs/base/node/processes';
import { getPathFromAmdModule } from 'vs/base/common/amd';
import { getPathFromAmdModule } from 'vs/base/test/node/testUtils';
function fork(id: string): cp.ChildProcess {
const opts: any = {

View File

@@ -5,12 +5,17 @@
import type { Suite } from 'mocha';
import { join } from 'vs/base/common/path';
import { URI } from 'vs/base/common/uri';
import { generateUuid } from 'vs/base/common/uuid';
export function getRandomTestPath(tmpdir: string, ...segments: string[]): string {
return join(tmpdir, ...segments, generateUuid());
}
export function getPathFromAmdModule(requirefn: typeof require, relativePath: string): string {
return URI.parse(requirefn.toUrl(relativePath)).fsPath;
}
export function flakySuite(title: string, fn: (this: Suite) => void): Suite {
return suite(title, function () {

View File

@@ -6,7 +6,7 @@
import * as assert from 'assert';
import { URI } from 'vs/base/common/uri';
import { readFileSync } from 'fs';
import { getPathFromAmdModule } from 'vs/base/common/amd';
import { getPathFromAmdModule } from 'vs/base/test/node/testUtils';
suite('URI - perf', function () {

View File

@@ -1,15 +0,0 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as assert from 'assert';
import { getDefaultUserDataPath } from 'vs/base/node/userDataPath';
suite('User data path', () => {
test('getDefaultUserDataPath', () => {
const path = getDefaultUserDataPath();
assert.ok(path.length > 0);
});
});

View File

@@ -9,9 +9,8 @@ import { tmpdir } from 'os';
import { promises } from 'fs';
import { extract } from 'vs/base/node/zip';
import { rimraf, exists } from 'vs/base/node/pfs';
import { getPathFromAmdModule } from 'vs/base/common/amd';
import { createCancelablePromise } from 'vs/base/common/async';
import { getRandomTestPath } from 'vs/base/test/node/testUtils';
import { getRandomTestPath, getPathFromAmdModule } from 'vs/base/test/node/testUtils';
suite('Zip', () => {