mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-23 01:25:38 -05:00
Merge from vscode a5cf1da01d5db3d2557132be8d30f89c38019f6c (#8525)
* Merge from vscode a5cf1da01d5db3d2557132be8d30f89c38019f6c * remove files we don't want * fix hygiene * update distro * update distro * fix hygiene * fix strict nulls * distro * distro * fix tests * fix tests * add another edit * fix viewlet icon * fix azure dialog * fix some padding * fix more padding issues
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { VSBuffer, bufferToReadable, readableToBuffer, bufferToStream, streamToBuffer, writeableBufferStream } from 'vs/base/common/buffer';
|
||||
import { VSBuffer, bufferToReadable, readableToBuffer, bufferToStream, streamToBuffer, newWriteableBufferStream } from 'vs/base/common/buffer';
|
||||
import { timeout } from 'vs/base/common/async';
|
||||
|
||||
suite('Buffer', () => {
|
||||
@@ -30,7 +30,7 @@ suite('Buffer', () => {
|
||||
});
|
||||
|
||||
test('bufferWriteableStream - basics (no error)', async () => {
|
||||
const stream = writeableBufferStream();
|
||||
const stream = newWriteableBufferStream();
|
||||
|
||||
let chunks: VSBuffer[] = [];
|
||||
stream.on('data', data => {
|
||||
@@ -60,7 +60,7 @@ suite('Buffer', () => {
|
||||
});
|
||||
|
||||
test('bufferWriteableStream - basics (error)', async () => {
|
||||
const stream = writeableBufferStream();
|
||||
const stream = newWriteableBufferStream();
|
||||
|
||||
let chunks: VSBuffer[] = [];
|
||||
stream.on('data', data => {
|
||||
@@ -89,7 +89,7 @@ suite('Buffer', () => {
|
||||
});
|
||||
|
||||
test('bufferWriteableStream - buffers data when no listener', async () => {
|
||||
const stream = writeableBufferStream();
|
||||
const stream = newWriteableBufferStream();
|
||||
|
||||
await timeout(0);
|
||||
stream.write(VSBuffer.fromString('Hello'));
|
||||
@@ -118,7 +118,7 @@ suite('Buffer', () => {
|
||||
});
|
||||
|
||||
test('bufferWriteableStream - buffers errors when no listener', async () => {
|
||||
const stream = writeableBufferStream();
|
||||
const stream = newWriteableBufferStream();
|
||||
|
||||
await timeout(0);
|
||||
stream.write(VSBuffer.fromString('Hello'));
|
||||
@@ -149,7 +149,7 @@ suite('Buffer', () => {
|
||||
});
|
||||
|
||||
test('bufferWriteableStream - buffers end when no listener', async () => {
|
||||
const stream = writeableBufferStream();
|
||||
const stream = newWriteableBufferStream();
|
||||
|
||||
await timeout(0);
|
||||
stream.write(VSBuffer.fromString('Hello'));
|
||||
@@ -178,7 +178,7 @@ suite('Buffer', () => {
|
||||
});
|
||||
|
||||
test('bufferWriteableStream - nothing happens after end()', async () => {
|
||||
const stream = writeableBufferStream();
|
||||
const stream = newWriteableBufferStream();
|
||||
|
||||
let chunks: VSBuffer[] = [];
|
||||
stream.on('data', data => {
|
||||
@@ -222,7 +222,7 @@ suite('Buffer', () => {
|
||||
});
|
||||
|
||||
test('bufferWriteableStream - pause/resume (simple)', async () => {
|
||||
const stream = writeableBufferStream();
|
||||
const stream = newWriteableBufferStream();
|
||||
|
||||
let chunks: VSBuffer[] = [];
|
||||
stream.on('data', data => {
|
||||
@@ -259,7 +259,7 @@ suite('Buffer', () => {
|
||||
});
|
||||
|
||||
test('bufferWriteableStream - pause/resume (pause after first write)', async () => {
|
||||
const stream = writeableBufferStream();
|
||||
const stream = newWriteableBufferStream();
|
||||
|
||||
let chunks: VSBuffer[] = [];
|
||||
stream.on('data', data => {
|
||||
@@ -299,7 +299,7 @@ suite('Buffer', () => {
|
||||
});
|
||||
|
||||
test('bufferWriteableStream - pause/resume (error)', async () => {
|
||||
const stream = writeableBufferStream();
|
||||
const stream = newWriteableBufferStream();
|
||||
|
||||
let chunks: VSBuffer[] = [];
|
||||
stream.on('data', data => {
|
||||
@@ -336,7 +336,7 @@ suite('Buffer', () => {
|
||||
});
|
||||
|
||||
test('bufferWriteableStream - destroy', async () => {
|
||||
const stream = writeableBufferStream();
|
||||
const stream = newWriteableBufferStream();
|
||||
|
||||
let chunks: VSBuffer[] = [];
|
||||
stream.on('data', data => {
|
||||
|
||||
@@ -9,7 +9,7 @@ import * as encoding from 'vs/base/node/encoding';
|
||||
import { Readable } from 'stream';
|
||||
import { getPathFromAmdModule } from 'vs/base/common/amd';
|
||||
|
||||
export async function detectEncodingByBOM(file: string): Promise<string | null> {
|
||||
export async function detectEncodingByBOM(file: string): Promise<typeof encoding.UTF16be | typeof encoding.UTF16le | typeof encoding.UTF8_with_bom | null> {
|
||||
try {
|
||||
const { buffer, bytesRead } = await readExactlyByFile(file, 3);
|
||||
|
||||
@@ -86,7 +86,7 @@ suite('Encoding', () => {
|
||||
const file = getPathFromAmdModule(require, './fixtures/some_utf8.css');
|
||||
|
||||
const detectedEncoding = await detectEncodingByBOM(file);
|
||||
assert.equal(detectedEncoding, 'utf8');
|
||||
assert.equal(detectedEncoding, 'utf8bom');
|
||||
});
|
||||
|
||||
test('detectBOM UTF-16 LE', async () => {
|
||||
@@ -189,6 +189,20 @@ suite('Encoding', () => {
|
||||
assert.equal(mimes.seemsBinary, false);
|
||||
});
|
||||
|
||||
test('autoGuessEncoding (UTF8)', async function () {
|
||||
const file = getPathFromAmdModule(require, './fixtures/some_file.css');
|
||||
const buffer = await readExactlyByFile(file, 512 * 8);
|
||||
const mimes = await encoding.detectEncodingFromBuffer(buffer, true);
|
||||
assert.equal(mimes.encoding, 'utf8');
|
||||
});
|
||||
|
||||
test('autoGuessEncoding (ASCII)', async function () {
|
||||
const file = getPathFromAmdModule(require, './fixtures/some_ansi.css');
|
||||
const buffer = await readExactlyByFile(file, 512 * 8);
|
||||
const mimes = await encoding.detectEncodingFromBuffer(buffer, true);
|
||||
assert.equal(mimes.encoding, null);
|
||||
});
|
||||
|
||||
test('autoGuessEncoding (ShiftJIS)', async function () {
|
||||
const file = getPathFromAmdModule(require, './fixtures/some.shiftjis.txt');
|
||||
const buffer = await readExactlyByFile(file, 512 * 8);
|
||||
|
||||
42
src/vs/base/test/node/encoding/fixtures/some_file.css
Normal file
42
src/vs/base/test/node/encoding/fixtures/some_file.css
Normal file
@@ -0,0 +1,42 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
/*----------------------------------------------------------
|
||||
The base color for this template is #5c87b2. If you'd like
|
||||
to use a different color start by replacing all instances of
|
||||
#5c87b2 with your new color.
|
||||
|
||||
öäüßßß
|
||||
----------------------------------------------------------*/
|
||||
body
|
||||
{
|
||||
background-color: #5c87b2;
|
||||
font-size: .75em;
|
||||
font-family: Segoe UI, Verdana, Helvetica, Sans-Serif;
|
||||
margin: 8px;
|
||||
padding: 0;
|
||||
color: #696969;
|
||||
}
|
||||
|
||||
h1, h2, h3, h4, h5, h6
|
||||
{
|
||||
color: #000;
|
||||
font-size: 40px;
|
||||
margin: 0px;
|
||||
}
|
||||
|
||||
textarea
|
||||
{
|
||||
font-family: Consolas
|
||||
}
|
||||
|
||||
#results
|
||||
{
|
||||
margin-top: 2em;
|
||||
margin-left: 2em;
|
||||
color: black;
|
||||
font-size: medium;
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -7,6 +7,8 @@
|
||||
The base color for this template is #5c87b2. If you'd like
|
||||
to use a different color start by replacing all instances of
|
||||
#5c87b2 with your new color.
|
||||
|
||||
öäüßßß
|
||||
----------------------------------------------------------*/
|
||||
body
|
||||
{
|
||||
@@ -25,12 +27,12 @@ h1, h2, h3, h4, h5, h6
|
||||
margin: 0px;
|
||||
}
|
||||
|
||||
textarea
|
||||
textarea
|
||||
{
|
||||
font-family: Consolas
|
||||
}
|
||||
|
||||
#results
|
||||
#results
|
||||
{
|
||||
margin-top: 2em;
|
||||
margin-left: 2em;
|
||||
|
||||
@@ -14,12 +14,12 @@ suite('Glob', () => {
|
||||
// let patterns = [
|
||||
// '{**/*.cs,**/*.json,**/*.csproj,**/*.sln}',
|
||||
// '{**/*.cs,**/*.csproj,**/*.sln}',
|
||||
// '{**/*.ts,**/*.tsx,**/*.js,**/*.jsx,**/*.es6,**/*.mjs}',
|
||||
// '{**/*.ts,**/*.tsx,**/*.js,**/*.jsx,**/*.es6,**/*.mjs,**/*.cjs}',
|
||||
// '**/*.go',
|
||||
// '{**/*.ps,**/*.ps1}',
|
||||
// '{**/*.c,**/*.cpp,**/*.h}',
|
||||
// '{**/*.fsx,**/*.fsi,**/*.fs,**/*.ml,**/*.mli}',
|
||||
// '{**/*.js,**/*.jsx,**/*.es6,**/*.mjs}',
|
||||
// '{**/*.js,**/*.jsx,**/*.es6,**/*.mjs,**/*.cjs}',
|
||||
// '{**/*.ts,**/*.tsx}',
|
||||
// '{**/*.php}',
|
||||
// '{**/*.php}',
|
||||
@@ -1015,4 +1015,4 @@ suite('Glob', () => {
|
||||
assertNoGlobMatch(p, '/DNXConsoleApp/foo/Program.cs');
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -12,7 +12,6 @@ import * as uuid from 'vs/base/common/uuid';
|
||||
import * as pfs from 'vs/base/node/pfs';
|
||||
import { timeout } from 'vs/base/common/async';
|
||||
import { getPathFromAmdModule } from 'vs/base/common/amd';
|
||||
import { CancellationTokenSource } from 'vs/base/common/cancellation';
|
||||
import { isWindows, isLinux } from 'vs/base/common/platform';
|
||||
import { canNormalize } from 'vs/base/common/normalization';
|
||||
import { VSBuffer } from 'vs/base/common/buffer';
|
||||
@@ -50,7 +49,13 @@ function toReadable(value: string, throwError?: boolean): Readable {
|
||||
});
|
||||
}
|
||||
|
||||
suite('PFS', () => {
|
||||
suite('PFS', function () {
|
||||
|
||||
// Given issues such as https://github.com/microsoft/vscode/issues/84066
|
||||
// we see random test failures when accessing the native file system. To
|
||||
// diagnose further, we retry node.js file access tests up to 3 times to
|
||||
// rule out any random disk issue.
|
||||
this.retries(3);
|
||||
|
||||
test('writeFile', async () => {
|
||||
const id = uuid.generateUuid();
|
||||
@@ -253,7 +258,7 @@ suite('PFS', () => {
|
||||
}
|
||||
catch (error) {
|
||||
assert.fail(error);
|
||||
return Promise.reject(error);
|
||||
throw error;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -306,23 +311,6 @@ suite('PFS', () => {
|
||||
return pfs.rimraf(parentDir, pfs.RimRafMode.MOVE);
|
||||
});
|
||||
|
||||
test('mkdirp cancellation', async () => {
|
||||
const id = uuid.generateUuid();
|
||||
const parentDir = path.join(os.tmpdir(), 'vsctests', id);
|
||||
const newDir = path.join(parentDir, 'pfs', id);
|
||||
|
||||
const source = new CancellationTokenSource();
|
||||
|
||||
const mkdirpPromise = pfs.mkdirp(newDir, 493, source.token);
|
||||
source.cancel();
|
||||
|
||||
await mkdirpPromise;
|
||||
|
||||
assert.ok(!fs.existsSync(newDir));
|
||||
|
||||
return pfs.rimraf(parentDir, pfs.RimRafMode.MOVE);
|
||||
});
|
||||
|
||||
test('readDirsInDir', async () => {
|
||||
const id = uuid.generateUuid();
|
||||
const parentDir = path.join(os.tmpdir(), 'vsctests', id);
|
||||
@@ -525,7 +513,7 @@ suite('PFS', () => {
|
||||
}
|
||||
|
||||
if (!expectedError || (<any>expectedError).code !== 'EISDIR') {
|
||||
return Promise.reject(new Error('Expected EISDIR error for writing to folder but got: ' + (expectedError ? (<any>expectedError).code : 'no error')));
|
||||
throw new Error('Expected EISDIR error for writing to folder but got: ' + (expectedError ? (<any>expectedError).code : 'no error'));
|
||||
}
|
||||
|
||||
// verify that the stream is still consumable (for https://github.com/Microsoft/vscode/issues/42542)
|
||||
@@ -551,7 +539,7 @@ suite('PFS', () => {
|
||||
}
|
||||
|
||||
if (!expectedError || expectedError.message !== readError) {
|
||||
return Promise.reject(new Error('Expected error for writing to folder'));
|
||||
throw new Error('Expected error for writing to folder');
|
||||
}
|
||||
|
||||
await pfs.rimraf(parentDir);
|
||||
@@ -582,7 +570,7 @@ suite('PFS', () => {
|
||||
}
|
||||
|
||||
if (!expectedError || !((<any>expectedError).code !== 'EACCES' || (<any>expectedError).code !== 'EPERM')) {
|
||||
return Promise.reject(new Error('Expected EACCES/EPERM error for writing to folder but got: ' + (expectedError ? (<any>expectedError).code : 'no error')));
|
||||
throw new Error('Expected EACCES/EPERM error for writing to folder but got: ' + (expectedError ? (<any>expectedError).code : 'no error'));
|
||||
}
|
||||
|
||||
await pfs.rimraf(parentDir);
|
||||
@@ -609,7 +597,7 @@ suite('PFS', () => {
|
||||
}
|
||||
|
||||
if (!expectedError) {
|
||||
return Promise.reject(new Error('Expected error for writing to folder'));
|
||||
throw new Error('Expected error for writing to folder');
|
||||
}
|
||||
|
||||
await pfs.rimraf(parentDir);
|
||||
|
||||
BIN
src/vs/base/test/node/zip/fixtures/extract.zip
Normal file
BIN
src/vs/base/test/node/zip/fixtures/extract.zip
Normal file
Binary file not shown.
28
src/vs/base/test/node/zip/zip.test.ts
Normal file
28
src/vs/base/test/node/zip/zip.test.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import * as path from 'vs/base/common/path';
|
||||
import * as os from 'os';
|
||||
import { extract } from 'vs/base/node/zip';
|
||||
import { generateUuid } from 'vs/base/common/uuid';
|
||||
import { rimraf, exists } from 'vs/base/node/pfs';
|
||||
import { getPathFromAmdModule } from 'vs/base/common/amd';
|
||||
import { createCancelablePromise } from 'vs/base/common/async';
|
||||
|
||||
const fixtures = getPathFromAmdModule(require, './fixtures');
|
||||
|
||||
suite('Zip', () => {
|
||||
|
||||
test('extract should handle directories', () => {
|
||||
const fixture = path.join(fixtures, 'extract.zip');
|
||||
const target = path.join(os.tmpdir(), generateUuid());
|
||||
|
||||
return createCancelablePromise(token => extract(fixture, target, {}, token)
|
||||
.then(() => exists(path.join(target, 'extension')))
|
||||
.then(exists => assert(exists))
|
||||
.then(() => rimraf(target)));
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user