mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-09 01:32:34 -05:00
Merge from master
This commit is contained in:
@@ -3,8 +3,6 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import * as assert from 'assert';
|
||||
import * as os from 'os';
|
||||
|
||||
@@ -16,7 +14,7 @@ import { testFile } from 'vs/base/test/node/utils';
|
||||
|
||||
suite('Config', () => {
|
||||
|
||||
test('defaults', function () {
|
||||
test('defaults', () => {
|
||||
const id = uuid.generateUuid();
|
||||
const parentDir = path.join(os.tmpdir(), 'vsctests', id);
|
||||
const newDir = path.join(parentDir, 'config', id);
|
||||
@@ -48,9 +46,6 @@ suite('Config', () => {
|
||||
let config = watcher.getConfig();
|
||||
assert.ok(config);
|
||||
assert.equal(config.foo, 'bar');
|
||||
assert.equal(watcher.getValue('foo'), 'bar');
|
||||
assert.equal(watcher.getValue('bar'), void 0);
|
||||
assert.equal(watcher.getValue('bar', 'fallback'), 'fallback');
|
||||
assert.ok(!watcher.hasParseErrors);
|
||||
|
||||
watcher.dispose();
|
||||
@@ -146,20 +141,18 @@ suite('Config', () => {
|
||||
testFile('config', 'config.json').then(res => {
|
||||
fs.writeFileSync(res.testFile, '// my comment\n{ "foo": "bar" }');
|
||||
|
||||
let watcher = new ConfigWatcher<{ foo: string; }>(res.testFile, { changeBufferDelay: 100, onError: console.error });
|
||||
let watcher = new ConfigWatcher<{ foo: string; }>(res.testFile, { changeBufferDelay: 100, onError: console.error, defaultConfig: void 0 });
|
||||
watcher.getConfig(); // ensure we are in sync
|
||||
|
||||
fs.writeFileSync(res.testFile, '// my comment\n{ "foo": "changed" }');
|
||||
|
||||
// still old values because change is not bubbling yet
|
||||
assert.equal(watcher.getConfig().foo, 'bar');
|
||||
assert.equal(watcher.getValue('foo'), 'bar');
|
||||
|
||||
// force a load from disk
|
||||
watcher.reload(config => {
|
||||
assert.equal(config.foo, 'changed');
|
||||
assert.equal(watcher.getConfig().foo, 'changed');
|
||||
assert.equal(watcher.getValue('foo'), 'changed');
|
||||
|
||||
watcher.dispose();
|
||||
|
||||
|
||||
@@ -3,15 +3,13 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { getFirstFrame } from 'vs/base/node/console';
|
||||
import { normalize } from 'path';
|
||||
|
||||
suite('Console', () => {
|
||||
|
||||
test('getFirstFrame', function () {
|
||||
test('getFirstFrame', () => {
|
||||
let stack = 'at vscode.commands.registerCommand (/Users/someone/Desktop/test-ts/out/src/extension.js:18:17)';
|
||||
let frame = getFirstFrame(stack);
|
||||
|
||||
|
||||
@@ -3,14 +3,12 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import * as assert from 'assert';
|
||||
import * as decoder from 'vs/base/node/decoder';
|
||||
|
||||
suite('Decoder', () => {
|
||||
|
||||
test('decoding', function () {
|
||||
test('decoding', () => {
|
||||
const lineDecoder = new decoder.LineDecoder();
|
||||
let res = lineDecoder.write(Buffer.from('hello'));
|
||||
assert.equal(res.length, 0);
|
||||
|
||||
@@ -3,153 +3,133 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import * as assert from 'assert';
|
||||
import * as fs from 'fs';
|
||||
import * as encoding from 'vs/base/node/encoding';
|
||||
import { readExactlyByFile } from 'vs/base/node/stream';
|
||||
import { Readable } from 'stream';
|
||||
import { getPathFromAmdModule } from 'vs/base/common/amd';
|
||||
|
||||
suite('Encoding', () => {
|
||||
test('detectBOM UTF-8', () => {
|
||||
const file = require.toUrl('./fixtures/some_utf8.css');
|
||||
test('detectBOM UTF-8', async () => {
|
||||
const file = getPathFromAmdModule(require, './fixtures/some_utf8.css');
|
||||
|
||||
return encoding.detectEncodingByBOM(file).then((encoding: string) => {
|
||||
assert.equal(encoding, 'utf8');
|
||||
});
|
||||
const detectedEncoding = await encoding.detectEncodingByBOM(file);
|
||||
assert.equal(detectedEncoding, 'utf8');
|
||||
});
|
||||
|
||||
test('detectBOM UTF-16 LE', () => {
|
||||
const file = require.toUrl('./fixtures/some_utf16le.css');
|
||||
test('detectBOM UTF-16 LE', async () => {
|
||||
const file = getPathFromAmdModule(require, './fixtures/some_utf16le.css');
|
||||
|
||||
return encoding.detectEncodingByBOM(file).then((encoding: string) => {
|
||||
assert.equal(encoding, 'utf16le');
|
||||
});
|
||||
const detectedEncoding = await encoding.detectEncodingByBOM(file);
|
||||
assert.equal(detectedEncoding, 'utf16le');
|
||||
});
|
||||
|
||||
test('detectBOM UTF-16 BE', () => {
|
||||
const file = require.toUrl('./fixtures/some_utf16be.css');
|
||||
test('detectBOM UTF-16 BE', async () => {
|
||||
const file = getPathFromAmdModule(require, './fixtures/some_utf16be.css');
|
||||
|
||||
return encoding.detectEncodingByBOM(file).then((encoding: string) => {
|
||||
assert.equal(encoding, 'utf16be');
|
||||
});
|
||||
const detectedEncoding = await encoding.detectEncodingByBOM(file);
|
||||
assert.equal(detectedEncoding, 'utf16be');
|
||||
});
|
||||
|
||||
test('detectBOM ANSI', function () {
|
||||
const file = require.toUrl('./fixtures/some_ansi.css');
|
||||
test('detectBOM ANSI', async function () {
|
||||
const file = getPathFromAmdModule(require, './fixtures/some_ansi.css');
|
||||
|
||||
return encoding.detectEncodingByBOM(file).then((encoding: string) => {
|
||||
assert.equal(encoding, null);
|
||||
});
|
||||
const detectedEncoding = await encoding.detectEncodingByBOM(file);
|
||||
assert.equal(detectedEncoding, null);
|
||||
});
|
||||
|
||||
test('detectBOM ANSI', function () {
|
||||
const file = require.toUrl('./fixtures/empty.txt');
|
||||
test('detectBOM ANSI', async function () {
|
||||
const file = getPathFromAmdModule(require, './fixtures/empty.txt');
|
||||
|
||||
return encoding.detectEncodingByBOM(file).then((encoding: string) => {
|
||||
assert.equal(encoding, null);
|
||||
});
|
||||
const detectedEncoding = await encoding.detectEncodingByBOM(file);
|
||||
assert.equal(detectedEncoding, null);
|
||||
});
|
||||
|
||||
test('resolve terminal encoding (detect)', function () {
|
||||
return encoding.resolveTerminalEncoding().then(enc => {
|
||||
assert.ok(encoding.encodingExists(enc));
|
||||
});
|
||||
test('resolve terminal encoding (detect)', async function () {
|
||||
const enc = await encoding.resolveTerminalEncoding();
|
||||
assert.ok(encoding.encodingExists(enc));
|
||||
});
|
||||
|
||||
test('resolve terminal encoding (environment)', function () {
|
||||
test('resolve terminal encoding (environment)', async function () {
|
||||
process.env['VSCODE_CLI_ENCODING'] = 'utf16le';
|
||||
|
||||
return encoding.resolveTerminalEncoding().then(enc => {
|
||||
assert.ok(encoding.encodingExists(enc));
|
||||
assert.equal(enc, 'utf16le');
|
||||
});
|
||||
const enc = await encoding.resolveTerminalEncoding();
|
||||
assert.ok(encoding.encodingExists(enc));
|
||||
assert.equal(enc, 'utf16le');
|
||||
});
|
||||
|
||||
test('detectEncodingFromBuffer (JSON saved as PNG)', function () {
|
||||
const file = require.toUrl('./fixtures/some.json.png');
|
||||
test('detectEncodingFromBuffer (JSON saved as PNG)', async function () {
|
||||
const file = getPathFromAmdModule(require, './fixtures/some.json.png');
|
||||
|
||||
return readExactlyByFile(file, 512).then(buffer => {
|
||||
const mimes = encoding.detectEncodingFromBuffer(buffer);
|
||||
assert.equal(mimes.seemsBinary, false);
|
||||
});
|
||||
const buffer = await readExactlyByFile(file, 512);
|
||||
const mimes = encoding.detectEncodingFromBuffer(buffer);
|
||||
assert.equal(mimes.seemsBinary, false);
|
||||
});
|
||||
|
||||
test('detectEncodingFromBuffer (PNG saved as TXT)', function () {
|
||||
const file = require.toUrl('./fixtures/some.png.txt');
|
||||
return readExactlyByFile(file, 512).then(buffer => {
|
||||
const mimes = encoding.detectEncodingFromBuffer(buffer);
|
||||
assert.equal(mimes.seemsBinary, true);
|
||||
});
|
||||
test('detectEncodingFromBuffer (PNG saved as TXT)', async function () {
|
||||
const file = getPathFromAmdModule(require, './fixtures/some.png.txt');
|
||||
const buffer = await readExactlyByFile(file, 512);
|
||||
const mimes = encoding.detectEncodingFromBuffer(buffer);
|
||||
assert.equal(mimes.seemsBinary, true);
|
||||
});
|
||||
|
||||
test('detectEncodingFromBuffer (XML saved as PNG)', function () {
|
||||
const file = require.toUrl('./fixtures/some.xml.png');
|
||||
return readExactlyByFile(file, 512).then(buffer => {
|
||||
const mimes = encoding.detectEncodingFromBuffer(buffer);
|
||||
assert.equal(mimes.seemsBinary, false);
|
||||
});
|
||||
test('detectEncodingFromBuffer (XML saved as PNG)', async function () {
|
||||
const file = getPathFromAmdModule(require, './fixtures/some.xml.png');
|
||||
const buffer = await readExactlyByFile(file, 512);
|
||||
const mimes = encoding.detectEncodingFromBuffer(buffer);
|
||||
assert.equal(mimes.seemsBinary, false);
|
||||
});
|
||||
|
||||
test('detectEncodingFromBuffer (QWOFF saved as TXT)', function () {
|
||||
const file = require.toUrl('./fixtures/some.qwoff.txt');
|
||||
return readExactlyByFile(file, 512).then(buffer => {
|
||||
const mimes = encoding.detectEncodingFromBuffer(buffer);
|
||||
assert.equal(mimes.seemsBinary, true);
|
||||
});
|
||||
test('detectEncodingFromBuffer (QWOFF saved as TXT)', async function () {
|
||||
const file = getPathFromAmdModule(require, './fixtures/some.qwoff.txt');
|
||||
const buffer = await readExactlyByFile(file, 512);
|
||||
const mimes = encoding.detectEncodingFromBuffer(buffer);
|
||||
assert.equal(mimes.seemsBinary, true);
|
||||
});
|
||||
|
||||
test('detectEncodingFromBuffer (CSS saved as QWOFF)', function () {
|
||||
const file = require.toUrl('./fixtures/some.css.qwoff');
|
||||
return readExactlyByFile(file, 512).then(buffer => {
|
||||
const mimes = encoding.detectEncodingFromBuffer(buffer);
|
||||
assert.equal(mimes.seemsBinary, false);
|
||||
});
|
||||
test('detectEncodingFromBuffer (CSS saved as QWOFF)', async function () {
|
||||
const file = getPathFromAmdModule(require, './fixtures/some.css.qwoff');
|
||||
const buffer = await readExactlyByFile(file, 512);
|
||||
const mimes = encoding.detectEncodingFromBuffer(buffer);
|
||||
assert.equal(mimes.seemsBinary, false);
|
||||
});
|
||||
|
||||
test('detectEncodingFromBuffer (PDF)', function () {
|
||||
const file = require.toUrl('./fixtures/some.pdf');
|
||||
return readExactlyByFile(file, 512).then(buffer => {
|
||||
const mimes = encoding.detectEncodingFromBuffer(buffer);
|
||||
assert.equal(mimes.seemsBinary, true);
|
||||
});
|
||||
test('detectEncodingFromBuffer (PDF)', async function () {
|
||||
const file = getPathFromAmdModule(require, './fixtures/some.pdf');
|
||||
const buffer = await readExactlyByFile(file, 512);
|
||||
const mimes = encoding.detectEncodingFromBuffer(buffer);
|
||||
assert.equal(mimes.seemsBinary, true);
|
||||
});
|
||||
|
||||
test('detectEncodingFromBuffer (guess UTF-16 LE from content without BOM)', function () {
|
||||
const file = require.toUrl('./fixtures/utf16_le_nobom.txt');
|
||||
return readExactlyByFile(file, 512).then(buffer => {
|
||||
const mimes = encoding.detectEncodingFromBuffer(buffer);
|
||||
assert.equal(mimes.encoding, encoding.UTF16le);
|
||||
assert.equal(mimes.seemsBinary, false);
|
||||
});
|
||||
test('detectEncodingFromBuffer (guess UTF-16 LE from content without BOM)', async function () {
|
||||
const file = getPathFromAmdModule(require, './fixtures/utf16_le_nobom.txt');
|
||||
const buffer = await readExactlyByFile(file, 512);
|
||||
const mimes = encoding.detectEncodingFromBuffer(buffer);
|
||||
assert.equal(mimes.encoding, encoding.UTF16le);
|
||||
assert.equal(mimes.seemsBinary, false);
|
||||
});
|
||||
|
||||
test('detectEncodingFromBuffer (guess UTF-16 BE from content without BOM)', function () {
|
||||
const file = require.toUrl('./fixtures/utf16_be_nobom.txt');
|
||||
return readExactlyByFile(file, 512).then(buffer => {
|
||||
const mimes = encoding.detectEncodingFromBuffer(buffer);
|
||||
assert.equal(mimes.encoding, encoding.UTF16be);
|
||||
assert.equal(mimes.seemsBinary, false);
|
||||
});
|
||||
test('detectEncodingFromBuffer (guess UTF-16 BE from content without BOM)', async function () {
|
||||
const file = getPathFromAmdModule(require, './fixtures/utf16_be_nobom.txt');
|
||||
const buffer = await readExactlyByFile(file, 512);
|
||||
const mimes = encoding.detectEncodingFromBuffer(buffer);
|
||||
assert.equal(mimes.encoding, encoding.UTF16be);
|
||||
assert.equal(mimes.seemsBinary, false);
|
||||
});
|
||||
|
||||
test('autoGuessEncoding (ShiftJIS)', function () {
|
||||
const file = require.toUrl('./fixtures/some.shiftjis.txt');
|
||||
return readExactlyByFile(file, 512 * 8).then(buffer => {
|
||||
return encoding.detectEncodingFromBuffer(buffer, true).then(mimes => {
|
||||
assert.equal(mimes.encoding, 'shiftjis');
|
||||
});
|
||||
});
|
||||
test('autoGuessEncoding (ShiftJIS)', async function () {
|
||||
const file = getPathFromAmdModule(require, './fixtures/some.shiftjis.txt');
|
||||
const buffer = await readExactlyByFile(file, 512 * 8);
|
||||
const mimes = await encoding.detectEncodingFromBuffer(buffer, true);
|
||||
assert.equal(mimes.encoding, 'shiftjis');
|
||||
});
|
||||
|
||||
test('autoGuessEncoding (CP1252)', function () {
|
||||
const file = require.toUrl('./fixtures/some.cp1252.txt');
|
||||
return readExactlyByFile(file, 512 * 8).then(buffer => {
|
||||
return encoding.detectEncodingFromBuffer(buffer, true).then(mimes => {
|
||||
assert.equal(mimes.encoding, 'windows1252');
|
||||
});
|
||||
});
|
||||
test('autoGuessEncoding (CP1252)', async function () {
|
||||
const file = getPathFromAmdModule(require, './fixtures/some.cp1252.txt');
|
||||
const buffer = await readExactlyByFile(file, 512 * 8);
|
||||
const mimes = await encoding.detectEncodingFromBuffer(buffer, true);
|
||||
assert.equal(mimes.encoding, 'windows1252');
|
||||
});
|
||||
|
||||
async function readAndDecodeFromDisk(path, _encoding) {
|
||||
@@ -238,7 +218,7 @@ suite('Encoding', () => {
|
||||
|
||||
test('toDecodeStream - encoding, utf16be', async function () {
|
||||
|
||||
let path = require.toUrl('./fixtures/some_utf16be.css');
|
||||
let path = getPathFromAmdModule(require, './fixtures/some_utf16be.css');
|
||||
let source = fs.createReadStream(path);
|
||||
|
||||
let { detected, stream } = await encoding.toDecodeStream(source, { minBytesRequiredForDetection: 64 });
|
||||
@@ -254,7 +234,7 @@ suite('Encoding', () => {
|
||||
|
||||
test('toDecodeStream - empty file', async function () {
|
||||
|
||||
let path = require.toUrl('./fixtures/empty.txt');
|
||||
let path = getPathFromAmdModule(require, './fixtures/empty.txt');
|
||||
let source = fs.createReadStream(path);
|
||||
let { detected, stream } = await encoding.toDecodeStream(source, {});
|
||||
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import * as assert from 'assert';
|
||||
import * as fs from 'fs';
|
||||
import * as os from 'os';
|
||||
@@ -14,13 +12,13 @@ import { canNormalize } from 'vs/base/common/normalization';
|
||||
import { isLinux, isWindows } from 'vs/base/common/platform';
|
||||
import * as uuid from 'vs/base/common/uuid';
|
||||
import * as extfs from 'vs/base/node/extfs';
|
||||
|
||||
|
||||
import { getPathFromAmdModule } from 'vs/base/common/amd';
|
||||
import { CancellationTokenSource } from 'vs/base/common/cancellation';
|
||||
|
||||
const ignore = () => { };
|
||||
|
||||
const mkdirp = (path: string, mode: number, callback: (error) => void) => {
|
||||
extfs.mkdirp(path, mode).done(() => callback(null), error => callback(error));
|
||||
extfs.mkdirp(path, mode).then(() => callback(null), error => callback(error));
|
||||
};
|
||||
|
||||
const chunkSize = 64 * 1024;
|
||||
@@ -169,7 +167,7 @@ suite('Extfs', () => {
|
||||
test('copy, move and delete', function (done) {
|
||||
const id = uuid.generateUuid();
|
||||
const id2 = uuid.generateUuid();
|
||||
const sourceDir = require.toUrl('./fixtures');
|
||||
const sourceDir = getPathFromAmdModule(require, './fixtures');
|
||||
const parentDir = path.join(os.tmpdir(), 'vsctests', 'extfs');
|
||||
const targetDir = path.join(parentDir, id);
|
||||
const targetDir2 = path.join(parentDir, id2);
|
||||
@@ -320,7 +318,7 @@ suite('Extfs', () => {
|
||||
test('writeFileAndFlush (file stream)', function (done) {
|
||||
const id = uuid.generateUuid();
|
||||
const parentDir = path.join(os.tmpdir(), 'vsctests', id);
|
||||
const sourceFile = require.toUrl('./fixtures/index.html');
|
||||
const sourceFile = getPathFromAmdModule(require, './fixtures/index.html');
|
||||
const newDir = path.join(parentDir, 'extfs', id);
|
||||
const testFile = path.join(newDir, 'flushed.txt');
|
||||
|
||||
@@ -453,7 +451,7 @@ suite('Extfs', () => {
|
||||
test('writeFileAndFlush (file stream, error handling)', function (done) {
|
||||
const id = uuid.generateUuid();
|
||||
const parentDir = path.join(os.tmpdir(), 'vsctests', id);
|
||||
const sourceFile = require.toUrl('./fixtures/index.html');
|
||||
const sourceFile = getPathFromAmdModule(require, './fixtures/index.html');
|
||||
const newDir = path.join(parentDir, 'extfs', id);
|
||||
const testFile = path.join(newDir, 'flushed.txt');
|
||||
|
||||
@@ -564,4 +562,57 @@ suite('Extfs', () => {
|
||||
extfs.del(parentDir, os.tmpdir(), done, ignore);
|
||||
});
|
||||
});
|
||||
|
||||
test('mkdirp cancellation', (done) => {
|
||||
const id = uuid.generateUuid();
|
||||
const parentDir = path.join(os.tmpdir(), 'vsctests', id);
|
||||
const newDir = path.join(parentDir, 'extfs', id);
|
||||
|
||||
const source = new CancellationTokenSource();
|
||||
|
||||
const mkdirpPromise = extfs.mkdirp(newDir, 493, source.token);
|
||||
source.cancel();
|
||||
|
||||
return mkdirpPromise.then(res => {
|
||||
assert.equal(res, false);
|
||||
|
||||
extfs.del(parentDir, os.tmpdir(), done, ignore);
|
||||
});
|
||||
});
|
||||
|
||||
test('sanitizeFilePath', () => {
|
||||
if (isWindows) {
|
||||
assert.equal(extfs.sanitizeFilePath('.', 'C:\\the\\cwd'), 'C:\\the\\cwd');
|
||||
assert.equal(extfs.sanitizeFilePath('', 'C:\\the\\cwd'), 'C:\\the\\cwd');
|
||||
|
||||
assert.equal(extfs.sanitizeFilePath('C:', 'C:\\the\\cwd'), 'C:\\');
|
||||
assert.equal(extfs.sanitizeFilePath('C:\\', 'C:\\the\\cwd'), 'C:\\');
|
||||
assert.equal(extfs.sanitizeFilePath('C:\\\\', 'C:\\the\\cwd'), 'C:\\');
|
||||
|
||||
assert.equal(extfs.sanitizeFilePath('C:\\folder\\my.txt', 'C:\\the\\cwd'), 'C:\\folder\\my.txt');
|
||||
assert.equal(extfs.sanitizeFilePath('C:\\folder\\my', 'C:\\the\\cwd'), 'C:\\folder\\my');
|
||||
assert.equal(extfs.sanitizeFilePath('C:\\folder\\..\\my', 'C:\\the\\cwd'), 'C:\\my');
|
||||
assert.equal(extfs.sanitizeFilePath('C:\\folder\\my\\', 'C:\\the\\cwd'), 'C:\\folder\\my');
|
||||
assert.equal(extfs.sanitizeFilePath('C:\\folder\\my\\\\\\', 'C:\\the\\cwd'), 'C:\\folder\\my');
|
||||
|
||||
assert.equal(extfs.sanitizeFilePath('my.txt', 'C:\\the\\cwd'), 'C:\\the\\cwd\\my.txt');
|
||||
assert.equal(extfs.sanitizeFilePath('my.txt\\', 'C:\\the\\cwd'), 'C:\\the\\cwd\\my.txt');
|
||||
|
||||
assert.equal(extfs.sanitizeFilePath('\\\\localhost\\folder\\my', 'C:\\the\\cwd'), '\\\\localhost\\folder\\my');
|
||||
assert.equal(extfs.sanitizeFilePath('\\\\localhost\\folder\\my\\', 'C:\\the\\cwd'), '\\\\localhost\\folder\\my');
|
||||
} else {
|
||||
assert.equal(extfs.sanitizeFilePath('.', '/the/cwd'), '/the/cwd');
|
||||
assert.equal(extfs.sanitizeFilePath('', '/the/cwd'), '/the/cwd');
|
||||
assert.equal(extfs.sanitizeFilePath('/', '/the/cwd'), '/');
|
||||
|
||||
assert.equal(extfs.sanitizeFilePath('/folder/my.txt', '/the/cwd'), '/folder/my.txt');
|
||||
assert.equal(extfs.sanitizeFilePath('/folder/my', '/the/cwd'), '/folder/my');
|
||||
assert.equal(extfs.sanitizeFilePath('/folder/../my', '/the/cwd'), '/my');
|
||||
assert.equal(extfs.sanitizeFilePath('/folder/my/', '/the/cwd'), '/folder/my');
|
||||
assert.equal(extfs.sanitizeFilePath('/folder/my///', '/the/cwd'), '/folder/my');
|
||||
|
||||
assert.equal(extfs.sanitizeFilePath('my.txt', '/the/cwd'), '/the/cwd/my.txt');
|
||||
assert.equal(extfs.sanitizeFilePath('my.txt/', '/the/cwd'), '/the/cwd/my.txt');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import * as assert from 'assert';
|
||||
import * as flow from 'vs/base/node/flow';
|
||||
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import * as assert from 'assert';
|
||||
import * as path from 'path';
|
||||
import * as glob from 'vs/base/common/glob';
|
||||
@@ -11,7 +9,7 @@ import { isWindows } from 'vs/base/common/platform';
|
||||
|
||||
suite('Glob', () => {
|
||||
|
||||
// test('perf', function () {
|
||||
// test('perf', () => {
|
||||
|
||||
// let patterns = [
|
||||
// '{**/*.cs,**/*.json,**/*.csproj,**/*.sln}',
|
||||
@@ -71,7 +69,7 @@ suite('Glob', () => {
|
||||
assert(!glob.match(pattern, input), `${pattern} should not match ${input}`);
|
||||
}
|
||||
|
||||
test('simple', function () {
|
||||
test('simple', () => {
|
||||
let p = 'node_modules';
|
||||
|
||||
assertGlobMatch(p, 'node_modules');
|
||||
@@ -175,7 +173,7 @@ suite('Glob', () => {
|
||||
assertNoGlobMatch(p, 'some.js/test');
|
||||
});
|
||||
|
||||
test('star', function () {
|
||||
test('star', () => {
|
||||
let p = 'node*modules';
|
||||
|
||||
assertGlobMatch(p, 'node_modules');
|
||||
@@ -203,7 +201,7 @@ suite('Glob', () => {
|
||||
assertGlobMatch(p, 'foo/node_modules/foo/bar');
|
||||
});
|
||||
|
||||
test('questionmark', function () {
|
||||
test('questionmark', () => {
|
||||
let p = 'node?modules';
|
||||
|
||||
assertGlobMatch(p, 'node_modules');
|
||||
@@ -220,7 +218,7 @@ suite('Glob', () => {
|
||||
assertNoGlobMatch(p, '/node_modules/foo.js');
|
||||
});
|
||||
|
||||
test('globstar', function () {
|
||||
test('globstar', () => {
|
||||
let p = '**/*.js';
|
||||
|
||||
assertGlobMatch(p, 'foo.js');
|
||||
@@ -483,7 +481,7 @@ suite('Glob', () => {
|
||||
assert.strictEqual(glob.match(expression, 'test.foo', hasSibling), null);
|
||||
});
|
||||
|
||||
test('brackets', function () {
|
||||
test('brackets', () => {
|
||||
let p = 'foo.[0-9]';
|
||||
|
||||
assertGlobMatch(p, 'foo.5');
|
||||
@@ -999,4 +997,16 @@ suite('Glob', () => {
|
||||
test('pattern with "base" does not explode - #36081', function () {
|
||||
assert.ok(glob.match({ 'base': true }, 'base'));
|
||||
});
|
||||
|
||||
test('relative pattern - #57475', function () {
|
||||
if (isWindows) {
|
||||
let p: glob.IRelativePattern = { base: 'C:\\DNXConsoleApp\\foo', pattern: 'styles/style.css', pathToRelative: (from, to) => path.relative(from, to) };
|
||||
assertGlobMatch(p, 'C:\\DNXConsoleApp\\foo\\styles\\style.css');
|
||||
assertNoGlobMatch(p, 'C:\\DNXConsoleApp\\foo\\Program.cs');
|
||||
} else {
|
||||
let p: glob.IRelativePattern = { base: '/DNXConsoleApp/foo', pattern: 'styles/style.css', pathToRelative: (from, to) => path.relative(from, to) };
|
||||
assertGlobMatch(p, '/DNXConsoleApp/foo/styles/style.css');
|
||||
assertNoGlobMatch(p, '/DNXConsoleApp/foo/Program.cs');
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -2,21 +2,19 @@
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import * as assert from 'assert';
|
||||
import * as getmac from 'getmac';
|
||||
import { getMachineId } from 'vs/base/node/id';
|
||||
|
||||
suite('ID', () => {
|
||||
|
||||
test('getMachineId', function () {
|
||||
test('getMachineId', () => {
|
||||
return getMachineId().then(id => {
|
||||
assert.ok(id);
|
||||
});
|
||||
});
|
||||
|
||||
test('getMac', function () {
|
||||
test('getMac', () => {
|
||||
return new Promise<string>((resolve, reject) => {
|
||||
getmac.getMac((err, macAddress) => err ? reject(err) : resolve(macAddress));
|
||||
}).then(macAddress => {
|
||||
|
||||
@@ -2,9 +2,6 @@
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
|
||||
import * as assert from 'assert';
|
||||
import * as os from 'os';
|
||||
@@ -18,7 +15,7 @@ import { timeout } from 'vs/base/common/async';
|
||||
|
||||
suite('PFS', () => {
|
||||
|
||||
test('writeFile', function () {
|
||||
test('writeFile', () => {
|
||||
const id = uuid.generateUuid();
|
||||
const parentDir = path.join(os.tmpdir(), 'vsctests', id);
|
||||
const newDir = path.join(parentDir, 'pfs', id);
|
||||
@@ -48,7 +45,7 @@ suite('PFS', () => {
|
||||
return pfs.mkdirp(newDir, 493).then(() => {
|
||||
assert.ok(fs.existsSync(newDir));
|
||||
|
||||
return TPromise.join([
|
||||
return Promise.all([
|
||||
pfs.writeFile(testFile1, 'Hello World 1', null),
|
||||
pfs.writeFile(testFile2, 'Hello World 2', null),
|
||||
pfs.writeFile(testFile3, 'Hello World 3', null),
|
||||
@@ -75,7 +72,7 @@ suite('PFS', () => {
|
||||
return pfs.mkdirp(newDir, 493).then(() => {
|
||||
assert.ok(fs.existsSync(newDir));
|
||||
|
||||
return TPromise.join([
|
||||
return Promise.all([
|
||||
pfs.writeFile(testFile, 'Hello World 1', null),
|
||||
pfs.writeFile(testFile, 'Hello World 2', null),
|
||||
timeout(10).then(() => pfs.writeFile(testFile, 'Hello World 3', null)),
|
||||
@@ -121,4 +118,38 @@ suite('PFS', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test('unlinkIgnoreError', function () {
|
||||
const id = uuid.generateUuid();
|
||||
const parentDir = path.join(os.tmpdir(), 'vsctests', id);
|
||||
const newDir = path.join(parentDir, 'extfs', id);
|
||||
|
||||
return pfs.mkdirp(newDir, 493).then(() => {
|
||||
return pfs.unlinkIgnoreError(path.join(newDir, 'foo')).then(() => {
|
||||
|
||||
return pfs.del(parentDir, os.tmpdir());
|
||||
}, error => {
|
||||
assert.fail(error);
|
||||
|
||||
return Promise.reject(error);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test('moveIgnoreError', function () {
|
||||
const id = uuid.generateUuid();
|
||||
const parentDir = path.join(os.tmpdir(), 'vsctests', id);
|
||||
const newDir = path.join(parentDir, 'extfs', id);
|
||||
|
||||
return pfs.mkdirp(newDir, 493).then(() => {
|
||||
return pfs.renameIgnoreError(path.join(newDir, 'foo'), path.join(newDir, 'bar')).then(() => {
|
||||
|
||||
return pfs.del(parentDir, os.tmpdir());
|
||||
}, error => {
|
||||
assert.fail(error);
|
||||
|
||||
return Promise.reject(error);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import * as assert from 'assert';
|
||||
import * as net from 'net';
|
||||
import * as ports from 'vs/base/node/ports';
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import * as processes from 'vs/base/node/processes';
|
||||
|
||||
const sender = processes.createQueuedSender(<any>process);
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import * as processes from 'vs/base/node/processes';
|
||||
|
||||
const sender = processes.createQueuedSender(<any>process);
|
||||
|
||||
@@ -3,14 +3,12 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import * as assert from 'assert';
|
||||
import * as cp from 'child_process';
|
||||
import * as objects from 'vs/base/common/objects';
|
||||
import * as platform from 'vs/base/common/platform';
|
||||
import URI from 'vs/base/common/uri';
|
||||
import * as processes from 'vs/base/node/processes';
|
||||
import { getPathFromAmdModule } from 'vs/base/common/amd';
|
||||
|
||||
function fork(id: string): cp.ChildProcess {
|
||||
const opts: any = {
|
||||
@@ -21,7 +19,7 @@ function fork(id: string): cp.ChildProcess {
|
||||
})
|
||||
};
|
||||
|
||||
return cp.fork(URI.parse(require.toUrl('bootstrap')).fsPath, ['--type=processTests'], opts);
|
||||
return cp.fork(getPathFromAmdModule(require, 'bootstrap-fork'), ['--type=processTests'], opts);
|
||||
}
|
||||
|
||||
suite('Processes', () => {
|
||||
|
||||
635
src/vs/base/test/node/storage/storage.test.ts
Normal file
635
src/vs/base/test/node/storage/storage.test.ts
Normal file
File diff suppressed because one or more lines are too long
@@ -3,15 +3,14 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import * as assert from 'assert';
|
||||
|
||||
import * as stream from 'vs/base/node/stream';
|
||||
import { getPathFromAmdModule } from 'vs/base/common/amd';
|
||||
|
||||
suite('Stream', () => {
|
||||
test('readExactlyByFile - ANSI', function () {
|
||||
const file = require.toUrl('./fixtures/file.css');
|
||||
const file = getPathFromAmdModule(require, './fixtures/file.css');
|
||||
|
||||
return stream.readExactlyByFile(file, 10).then(({ buffer, bytesRead }) => {
|
||||
assert.equal(bytesRead, 10);
|
||||
@@ -20,7 +19,7 @@ suite('Stream', () => {
|
||||
});
|
||||
|
||||
test('readExactlyByFile - empty', function () {
|
||||
const file = require.toUrl('./fixtures/empty.txt');
|
||||
const file = getPathFromAmdModule(require, './fixtures/empty.txt');
|
||||
|
||||
return stream.readExactlyByFile(file, 10).then(({ bytesRead }) => {
|
||||
assert.equal(bytesRead, 0);
|
||||
@@ -28,7 +27,7 @@ suite('Stream', () => {
|
||||
});
|
||||
|
||||
test('readToMatchingString - ANSI', function () {
|
||||
const file = require.toUrl('./fixtures/file.css');
|
||||
const file = getPathFromAmdModule(require, './fixtures/file.css');
|
||||
|
||||
return stream.readToMatchingString(file, '\n', 10, 100).then((result: string) => {
|
||||
// \r may be present on Windows
|
||||
@@ -37,10 +36,10 @@ suite('Stream', () => {
|
||||
});
|
||||
|
||||
test('readToMatchingString - empty', function () {
|
||||
const file = require.toUrl('./fixtures/empty.txt');
|
||||
const file = getPathFromAmdModule(require, './fixtures/empty.txt');
|
||||
|
||||
return stream.readToMatchingString(file, '\n', 10, 100).then((result: string) => {
|
||||
assert.equal(result, null);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2299,8 +2299,8 @@
|
||||
/users/foo/src/vs/base/parts/ipc/test/node/ipc.test.ts
|
||||
/users/foo/src/vs/base/parts/ipc/test/node/testService.ts
|
||||
/users/foo/src/vs/base/parts/ipc/common
|
||||
/users/foo/src/vs/base/parts/ipc/common/ipc.electron.ts
|
||||
/users/foo/src/vs/base/parts/ipc/common/ipc.ts
|
||||
/users/foo/src/vs/base/parts/ipc/node/ipc.electron.ts
|
||||
/users/foo/src/vs/base/parts/ipc/node/ipc.ts
|
||||
/users/foo/src/vs/base/parts/ipc/electron-browser
|
||||
/users/foo/src/vs/base/parts/ipc/electron-browser/ipc.electron-browser.ts
|
||||
/users/foo/src/vs/base/parts/ipc/node
|
||||
|
||||
@@ -2,18 +2,18 @@
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import * as assert from 'assert';
|
||||
import URI from 'vs/base/common/uri';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { readFileSync } from 'fs';
|
||||
import { getPathFromAmdModule } from 'vs/base/common/amd';
|
||||
|
||||
suite('URI - perf', function () {
|
||||
|
||||
let manyFileUris: URI[];
|
||||
setup(function () {
|
||||
manyFileUris = [];
|
||||
let data = readFileSync(URI.parse(require.toUrl('./uri.test.data.txt')).fsPath).toString();
|
||||
let data = readFileSync(getPathFromAmdModule(require, './uri.test.data.txt')).toString();
|
||||
let lines = data.split('\n');
|
||||
for (let line of lines) {
|
||||
manyFileUris.push(URI.file(line));
|
||||
|
||||
@@ -3,9 +3,6 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { generateUuid } from 'vs/base/common/uuid';
|
||||
import { join } from 'path';
|
||||
import { tmpdir } from 'os';
|
||||
@@ -13,10 +10,10 @@ import { mkdirp, del } from 'vs/base/node/pfs';
|
||||
|
||||
export interface ITestFileResult {
|
||||
testFile: string;
|
||||
cleanUp: () => TPromise<void>;
|
||||
cleanUp: () => Thenable<void>;
|
||||
}
|
||||
|
||||
export function testFile(folder: string, file: string): TPromise<ITestFileResult> {
|
||||
export function testFile(folder: string, file: string): Thenable<ITestFileResult> {
|
||||
const id = generateUuid();
|
||||
const parentDir = join(tmpdir(), 'vsctests', id);
|
||||
const newDir = join(parentDir, 'config', id);
|
||||
@@ -28,4 +25,4 @@ export function testFile(folder: string, file: string): TPromise<ITestFileResult
|
||||
cleanUp: () => del(parentDir, tmpdir())
|
||||
} as ITestFileResult;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -1,30 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import * as assert from 'assert';
|
||||
import * as path from 'path';
|
||||
import * as os from 'os';
|
||||
import URI from 'vs/base/common/uri';
|
||||
import { extract } from 'vs/base/node/zip';
|
||||
import { generateUuid } from 'vs/base/common/uuid';
|
||||
import { rimraf, exists } from 'vs/base/node/pfs';
|
||||
import { NullLogService } from 'vs/platform/log/common/log';
|
||||
|
||||
const fixtures = URI.parse(require.toUrl('./fixtures')).fsPath;
|
||||
|
||||
suite('Zip', () => {
|
||||
|
||||
test('extract should handle directories', () => {
|
||||
const fixture = path.join(fixtures, 'extract.zip');
|
||||
const target = path.join(os.tmpdir(), generateUuid());
|
||||
|
||||
return extract(fixture, target, {}, new NullLogService())
|
||||
.then(() => exists(path.join(target, 'extension')))
|
||||
.then(exists => assert(exists))
|
||||
.then(() => rimraf(target));
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user