mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-28 01:25:39 -05:00
Initial VS Code 1.19 source merge (#571)
* Initial 1.19 xcopy * Fix yarn build * Fix numerous build breaks * Next batch of build break fixes * More build break fixes * Runtime breaks * Additional post merge fixes * Fix windows setup file * Fix test failures. * Update license header blocks to refer to source eula
This commit is contained in:
@@ -14,6 +14,7 @@ import extfs = require('vs/base/node/extfs');
|
||||
import uuid = require('vs/base/common/uuid');
|
||||
import { ConfigWatcher } from 'vs/base/node/config';
|
||||
import { onError } from 'vs/base/test/common/utils';
|
||||
import { mkdirp } from 'vs/base/node/pfs';
|
||||
|
||||
suite('Config', () => {
|
||||
|
||||
@@ -23,9 +24,9 @@ suite('Config', () => {
|
||||
const newDir = path.join(parentDir, 'config', id);
|
||||
const testFile = path.join(newDir, 'config.json');
|
||||
|
||||
extfs.mkdirp(newDir, 493, error => {
|
||||
callback(error, testFile, (callback) => extfs.del(parentDir, os.tmpdir(), () => { }, callback));
|
||||
});
|
||||
const onMkdirp = error => callback(error, testFile, (callback) => extfs.del(parentDir, os.tmpdir(), () => { }, callback));
|
||||
|
||||
mkdirp(newDir, 493).done(() => onMkdirp(null), error => onMkdirp(error));
|
||||
}
|
||||
|
||||
test('defaults', function () {
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
import assert = require('assert');
|
||||
|
||||
import encoding = require('vs/base/node/encoding');
|
||||
import { encodingExists } from 'vs/base/node/encoding';
|
||||
|
||||
suite('Encoding', () => {
|
||||
test('detectBOM UTF-8', (done: (err?: any) => void) => {
|
||||
@@ -54,4 +55,21 @@ suite('Encoding', () => {
|
||||
done();
|
||||
}, done);
|
||||
});
|
||||
|
||||
test('resolve terminal encoding (detect)', function (done: (err?: any) => void) {
|
||||
encoding.resolveTerminalEncoding().then(encoding => {
|
||||
assert.ok(encodingExists(encoding));
|
||||
done();
|
||||
}, done);
|
||||
});
|
||||
|
||||
test('resolve terminal encoding (environment)', function (done: (err?: any) => void) {
|
||||
process.env['VSCODE_CLI_ENCODING'] = 'utf16le';
|
||||
|
||||
encoding.resolveTerminalEncoding().then(encoding => {
|
||||
assert.ok(encodingExists(encoding));
|
||||
assert.equal(encoding, 'utf16le');
|
||||
done();
|
||||
}, done);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -18,6 +18,10 @@ import { onError } from 'vs/base/test/common/utils';
|
||||
|
||||
const ignore = () => { };
|
||||
|
||||
const mkdirp = (path: string, mode: number, callback: (error) => void) => {
|
||||
extfs.mkdirp(path, mode).done(() => callback(null), error => callback(error));
|
||||
};
|
||||
|
||||
suite('Extfs', () => {
|
||||
|
||||
test('mkdirp', function (done: () => void) {
|
||||
@@ -25,7 +29,7 @@ suite('Extfs', () => {
|
||||
const parentDir = path.join(os.tmpdir(), 'vsctests', id);
|
||||
const newDir = path.join(parentDir, 'extfs', id);
|
||||
|
||||
extfs.mkdirp(newDir, 493, (error) => {
|
||||
mkdirp(newDir, 493, error => {
|
||||
if (error) {
|
||||
return onError(error, done);
|
||||
}
|
||||
@@ -51,7 +55,7 @@ suite('Extfs', () => {
|
||||
const parentDir = path.join(os.tmpdir(), 'vsctests', id);
|
||||
const newDir = path.join(parentDir, 'extfs', id);
|
||||
|
||||
extfs.mkdirp(newDir, 493, (error) => {
|
||||
mkdirp(newDir, 493, error => {
|
||||
if (error) {
|
||||
return onError(error, done);
|
||||
}
|
||||
@@ -71,7 +75,7 @@ suite('Extfs', () => {
|
||||
const parentDir = path.join(os.tmpdir(), 'vsctests', id);
|
||||
const newDir = path.join(parentDir, 'extfs', id);
|
||||
|
||||
extfs.mkdirp(newDir, 493, (error) => {
|
||||
mkdirp(newDir, 493, error => {
|
||||
if (error) {
|
||||
return onError(error, done);
|
||||
}
|
||||
@@ -97,7 +101,7 @@ suite('Extfs', () => {
|
||||
const targetDir = path.join(parentDir, id);
|
||||
const targetDir2 = path.join(parentDir, id2);
|
||||
|
||||
extfs.copy(sourceDir, targetDir, (error) => {
|
||||
extfs.copy(sourceDir, targetDir, error => {
|
||||
if (error) {
|
||||
return onError(error, done);
|
||||
}
|
||||
@@ -109,7 +113,7 @@ suite('Extfs', () => {
|
||||
assert.ok(fs.statSync(path.join(targetDir, 'examples')).isDirectory());
|
||||
assert.ok(fs.existsSync(path.join(targetDir, 'examples', 'small.jxs')));
|
||||
|
||||
extfs.mv(targetDir, targetDir2, (error) => {
|
||||
extfs.mv(targetDir, targetDir2, error => {
|
||||
if (error) {
|
||||
return onError(error, done);
|
||||
}
|
||||
@@ -122,7 +126,7 @@ suite('Extfs', () => {
|
||||
assert.ok(fs.statSync(path.join(targetDir2, 'examples')).isDirectory());
|
||||
assert.ok(fs.existsSync(path.join(targetDir2, 'examples', 'small.jxs')));
|
||||
|
||||
extfs.mv(path.join(targetDir2, 'index.html'), path.join(targetDir2, 'index_moved.html'), (error) => {
|
||||
extfs.mv(path.join(targetDir2, 'index.html'), path.join(targetDir2, 'index_moved.html'), error => {
|
||||
if (error) {
|
||||
return onError(error, done);
|
||||
}
|
||||
@@ -130,11 +134,11 @@ suite('Extfs', () => {
|
||||
assert.ok(!fs.existsSync(path.join(targetDir2, 'index.html')));
|
||||
assert.ok(fs.existsSync(path.join(targetDir2, 'index_moved.html')));
|
||||
|
||||
extfs.del(parentDir, os.tmpdir(), (error) => {
|
||||
extfs.del(parentDir, os.tmpdir(), error => {
|
||||
if (error) {
|
||||
return onError(error, done);
|
||||
}
|
||||
}, (error) => {
|
||||
}, error => {
|
||||
if (error) {
|
||||
return onError(error, done);
|
||||
}
|
||||
@@ -152,7 +156,7 @@ suite('Extfs', () => {
|
||||
const parentDir = path.join(os.tmpdir(), 'vsctests', id);
|
||||
const newDir = path.join(parentDir, 'extfs', id, 'öäü');
|
||||
|
||||
extfs.mkdirp(newDir, 493, (error) => {
|
||||
mkdirp(newDir, 493, error => {
|
||||
if (error) {
|
||||
return onError(error, done);
|
||||
}
|
||||
@@ -176,14 +180,14 @@ suite('Extfs', () => {
|
||||
const newDir = path.join(parentDir, 'extfs', id);
|
||||
const testFile = path.join(newDir, 'flushed.txt');
|
||||
|
||||
extfs.mkdirp(newDir, 493, (error) => {
|
||||
mkdirp(newDir, 493, error => {
|
||||
if (error) {
|
||||
return onError(error, done);
|
||||
}
|
||||
|
||||
assert.ok(fs.existsSync(newDir));
|
||||
|
||||
extfs.writeFileAndFlush(testFile, 'Hello World', null, (error) => {
|
||||
extfs.writeFileAndFlush(testFile, 'Hello World', null, error => {
|
||||
if (error) {
|
||||
return onError(error, done);
|
||||
}
|
||||
@@ -192,7 +196,7 @@ suite('Extfs', () => {
|
||||
|
||||
const largeString = (new Array(100 * 1024)).join('Large String\n');
|
||||
|
||||
extfs.writeFileAndFlush(testFile, largeString, null, (error) => {
|
||||
extfs.writeFileAndFlush(testFile, largeString, null, error => {
|
||||
if (error) {
|
||||
return onError(error, done);
|
||||
}
|
||||
@@ -205,12 +209,37 @@ suite('Extfs', () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('writeFileAndFlushSync', function (done: () => void) {
|
||||
const id = uuid.generateUuid();
|
||||
const parentDir = path.join(os.tmpdir(), 'vsctests', id);
|
||||
const newDir = path.join(parentDir, 'extfs', id);
|
||||
const testFile = path.join(newDir, 'flushed.txt');
|
||||
|
||||
mkdirp(newDir, 493, error => {
|
||||
if (error) {
|
||||
return onError(error, done);
|
||||
}
|
||||
|
||||
assert.ok(fs.existsSync(newDir));
|
||||
|
||||
extfs.writeFileAndFlushSync(testFile, 'Hello World', null);
|
||||
assert.equal(fs.readFileSync(testFile), 'Hello World');
|
||||
|
||||
const largeString = (new Array(100 * 1024)).join('Large String\n');
|
||||
|
||||
extfs.writeFileAndFlushSync(testFile, largeString, null);
|
||||
assert.equal(fs.readFileSync(testFile), largeString);
|
||||
|
||||
extfs.del(parentDir, os.tmpdir(), done, ignore);
|
||||
});
|
||||
});
|
||||
|
||||
test('realcase', (done) => {
|
||||
const id = uuid.generateUuid();
|
||||
const parentDir = path.join(os.tmpdir(), 'vsctests', id);
|
||||
const newDir = path.join(parentDir, 'extfs', id);
|
||||
|
||||
extfs.mkdirp(newDir, 493, (error) => {
|
||||
mkdirp(newDir, 493, error => {
|
||||
|
||||
// assume case insensitive file system
|
||||
if (process.platform === 'win32' || process.platform === 'darwin') {
|
||||
@@ -239,7 +268,7 @@ suite('Extfs', () => {
|
||||
const parentDir = path.join(os.tmpdir(), 'vsctests', id);
|
||||
const newDir = path.join(parentDir, 'extfs', id);
|
||||
|
||||
extfs.mkdirp(newDir, 493, (error) => {
|
||||
mkdirp(newDir, 493, error => {
|
||||
|
||||
extfs.realpath(newDir, (error, realpath) => {
|
||||
assert.ok(realpath);
|
||||
@@ -255,7 +284,7 @@ suite('Extfs', () => {
|
||||
const parentDir = path.join(os.tmpdir(), 'vsctests', id);
|
||||
const newDir = path.join(parentDir, 'extfs', id);
|
||||
|
||||
extfs.mkdirp(newDir, 493, (error) => {
|
||||
mkdirp(newDir, 493, error => {
|
||||
let realpath: string;
|
||||
try {
|
||||
realpath = extfs.realpathSync(newDir);
|
||||
|
||||
@@ -13,45 +13,45 @@ const sequence = flow.sequence;
|
||||
const parallel = flow.parallel;
|
||||
|
||||
suite('Flow', () => {
|
||||
function assertCounterEquals(counter, expected): void {
|
||||
function assertCounterEquals(counter: number, expected: number): void {
|
||||
assert.ok(counter === expected, 'Expected ' + expected + ' assertions, but got ' + counter);
|
||||
}
|
||||
|
||||
function syncThrowsError(callback): void {
|
||||
function syncThrowsError(callback: any): void {
|
||||
callback(new Error('foo'), null);
|
||||
}
|
||||
|
||||
function syncSequenceGetThrowsError(value, callback) {
|
||||
function syncSequenceGetThrowsError(value: any, callback: any) {
|
||||
sequence(
|
||||
function onError(error) {
|
||||
callback(error, null);
|
||||
},
|
||||
|
||||
function getFirst() {
|
||||
function getFirst(this: any) {
|
||||
syncThrowsError(this);
|
||||
},
|
||||
|
||||
function handleFirst(first) {
|
||||
function handleFirst(first: number) {
|
||||
//Foo
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function syncGet(value, callback): void {
|
||||
function syncGet(value: any, callback: any): void {
|
||||
callback(null, value);
|
||||
}
|
||||
|
||||
function syncGetError(value, callback): void {
|
||||
function syncGetError(value: any, callback: any): void {
|
||||
callback(new Error(''), null);
|
||||
}
|
||||
|
||||
function asyncGet(value, callback): void {
|
||||
function asyncGet(value: any, callback: any): void {
|
||||
process.nextTick(function () {
|
||||
callback(null, value);
|
||||
});
|
||||
}
|
||||
|
||||
function asyncGetError(value, callback): void {
|
||||
function asyncGetError(value: any, callback: any): void {
|
||||
process.nextTick(function () {
|
||||
callback(new Error(''), null);
|
||||
});
|
||||
@@ -72,7 +72,7 @@ suite('Flow', () => {
|
||||
});
|
||||
|
||||
test('loopByFunctionSync', function (done: () => void) {
|
||||
const elements = function (callback) {
|
||||
const elements = function (callback: Function) {
|
||||
callback(null, ['1', '2', '3']);
|
||||
};
|
||||
|
||||
@@ -87,7 +87,7 @@ suite('Flow', () => {
|
||||
});
|
||||
|
||||
test('loopByFunctionAsync', function (done: () => void) {
|
||||
const elements = function (callback) {
|
||||
const elements = function (callback: Function) {
|
||||
process.nextTick(function () {
|
||||
callback(null, ['1', '2', '3']);
|
||||
});
|
||||
@@ -176,23 +176,23 @@ suite('Flow', () => {
|
||||
errorCount++;
|
||||
},
|
||||
|
||||
function getFirst() {
|
||||
function getFirst(this: any) {
|
||||
syncGet('1', this);
|
||||
},
|
||||
|
||||
function handleFirst(first) {
|
||||
function handleFirst(this: any, first: number) {
|
||||
assert.deepEqual('1', first);
|
||||
assertionCount++;
|
||||
syncGet('2', this);
|
||||
},
|
||||
|
||||
function handleSecond(second) {
|
||||
function handleSecond(this: any, second: any) {
|
||||
assert.deepEqual('2', second);
|
||||
assertionCount++;
|
||||
syncGet(null, this);
|
||||
},
|
||||
|
||||
function handleThird(third) {
|
||||
function handleThird(third: any) {
|
||||
assert.ok(!third);
|
||||
assertionCount++;
|
||||
|
||||
@@ -212,23 +212,23 @@ suite('Flow', () => {
|
||||
errorCount++;
|
||||
},
|
||||
|
||||
function getFirst() {
|
||||
function getFirst(this: any) {
|
||||
asyncGet('1', this);
|
||||
},
|
||||
|
||||
function handleFirst(first) {
|
||||
function handleFirst(this: any, first: number) {
|
||||
assert.deepEqual('1', first);
|
||||
assertionCount++;
|
||||
asyncGet('2', this);
|
||||
},
|
||||
|
||||
function handleSecond(second) {
|
||||
function handleSecond(this: any, second: number) {
|
||||
assert.deepEqual('2', second);
|
||||
assertionCount++;
|
||||
asyncGet(null, this);
|
||||
},
|
||||
|
||||
function handleThird(third) {
|
||||
function handleThird(third: number) {
|
||||
assert.ok(!third);
|
||||
assertionCount++;
|
||||
|
||||
@@ -252,17 +252,17 @@ suite('Flow', () => {
|
||||
done();
|
||||
},
|
||||
|
||||
function getFirst() {
|
||||
function getFirst(this: any) {
|
||||
syncGet('1', this);
|
||||
},
|
||||
|
||||
function handleFirst(first) {
|
||||
function handleFirst(this: any, first: number) {
|
||||
assert.deepEqual('1', first);
|
||||
assertionCount++;
|
||||
syncGet('2', this);
|
||||
},
|
||||
|
||||
function handleSecond(second) {
|
||||
function handleSecond(second: number) {
|
||||
if (true) {
|
||||
throw new Error('');
|
||||
}
|
||||
@@ -270,7 +270,7 @@ suite('Flow', () => {
|
||||
// syncGet(null, this);
|
||||
},
|
||||
|
||||
function handleThird(third) {
|
||||
function handleThird(third: number) {
|
||||
throw new Error('We should not be here');
|
||||
}
|
||||
);
|
||||
@@ -289,17 +289,17 @@ suite('Flow', () => {
|
||||
done();
|
||||
},
|
||||
|
||||
function getFirst() {
|
||||
function getFirst(this: any) {
|
||||
syncGet('1', this);
|
||||
},
|
||||
|
||||
function handleFirst(first) {
|
||||
function handleFirst(this: any, first: number) {
|
||||
assert.deepEqual('1', first);
|
||||
assertionCount++;
|
||||
syncGetError('2', this);
|
||||
},
|
||||
|
||||
function handleSecond(second) {
|
||||
function handleSecond(second: number) {
|
||||
throw new Error('We should not be here');
|
||||
}
|
||||
);
|
||||
@@ -318,17 +318,17 @@ suite('Flow', () => {
|
||||
done();
|
||||
},
|
||||
|
||||
function getFirst() {
|
||||
function getFirst(this: any) {
|
||||
asyncGet('1', this);
|
||||
},
|
||||
|
||||
function handleFirst(first) {
|
||||
function handleFirst(this: any, first: number) {
|
||||
assert.deepEqual('1', first);
|
||||
assertionCount++;
|
||||
asyncGet('2', this);
|
||||
},
|
||||
|
||||
function handleSecond(second) {
|
||||
function handleSecond(second: number) {
|
||||
if (true) {
|
||||
throw new Error('');
|
||||
}
|
||||
@@ -336,7 +336,7 @@ suite('Flow', () => {
|
||||
// asyncGet(null, this);
|
||||
},
|
||||
|
||||
function handleThird(third) {
|
||||
function handleThird(third: number) {
|
||||
throw new Error('We should not be here');
|
||||
}
|
||||
);
|
||||
@@ -355,17 +355,17 @@ suite('Flow', () => {
|
||||
done();
|
||||
},
|
||||
|
||||
function getFirst() {
|
||||
function getFirst(this: any) {
|
||||
asyncGet('1', this);
|
||||
},
|
||||
|
||||
function handleFirst(first) {
|
||||
function handleFirst(this: any, first: number) {
|
||||
assert.deepEqual('1', first);
|
||||
assertionCount++;
|
||||
asyncGetError('2', this);
|
||||
},
|
||||
|
||||
function handleSecond(second) {
|
||||
function handleSecond(second: number) {
|
||||
throw new Error('We should not be here');
|
||||
}
|
||||
);
|
||||
@@ -377,7 +377,7 @@ suite('Flow', () => {
|
||||
done();
|
||||
},
|
||||
|
||||
function getFirst() {
|
||||
function getFirst(this: any) {
|
||||
syncSequenceGetThrowsError('1', this);
|
||||
}
|
||||
);
|
||||
@@ -392,16 +392,16 @@ suite('Flow', () => {
|
||||
errorCount++;
|
||||
},
|
||||
|
||||
function getFirst() {
|
||||
function getFirst(this: any) {
|
||||
this(true);
|
||||
},
|
||||
|
||||
function getSecond(result) {
|
||||
function getSecond(this: any, result: boolean) {
|
||||
assert.equal(result, true);
|
||||
this(false);
|
||||
},
|
||||
|
||||
function last(result) {
|
||||
function last(result: boolean) {
|
||||
assert.equal(result, false);
|
||||
assertionCount++;
|
||||
|
||||
|
||||
@@ -416,7 +416,7 @@ suite('Glob', () => {
|
||||
|
||||
assert.strictEqual(glob.match(expression, 'test.js', () => siblings), null);
|
||||
|
||||
expression = <any>{
|
||||
expression = {
|
||||
'**/*.js': {
|
||||
}
|
||||
};
|
||||
@@ -460,6 +460,46 @@ suite('Glob', () => {
|
||||
assert(!glob.match(p, 'foo.8'));
|
||||
assert(!glob.match(p, 'bar.5'));
|
||||
assert(glob.match(p, 'foo.f'));
|
||||
|
||||
p = 'foo.[!0-9]';
|
||||
|
||||
assert(!glob.match(p, 'foo.5'));
|
||||
assert(!glob.match(p, 'foo.8'));
|
||||
assert(!glob.match(p, 'bar.5'));
|
||||
assert(glob.match(p, 'foo.f'));
|
||||
|
||||
p = 'foo.[0!^*?]';
|
||||
|
||||
assert(!glob.match(p, 'foo.5'));
|
||||
assert(!glob.match(p, 'foo.8'));
|
||||
assert(glob.match(p, 'foo.0'));
|
||||
assert(glob.match(p, 'foo.!'));
|
||||
assert(glob.match(p, 'foo.^'));
|
||||
assert(glob.match(p, 'foo.*'));
|
||||
assert(glob.match(p, 'foo.?'));
|
||||
|
||||
p = 'foo[/]bar';
|
||||
|
||||
assert(!glob.match(p, 'foo/bar'));
|
||||
|
||||
p = 'foo.[[]';
|
||||
|
||||
assert(glob.match(p, 'foo.['));
|
||||
|
||||
p = 'foo.[]]';
|
||||
|
||||
assert(glob.match(p, 'foo.]'));
|
||||
|
||||
p = 'foo.[][!]';
|
||||
|
||||
assert(glob.match(p, 'foo.]'));
|
||||
assert(glob.match(p, 'foo.['));
|
||||
assert(glob.match(p, 'foo.!'));
|
||||
|
||||
p = 'foo.[]-]';
|
||||
|
||||
assert(glob.match(p, 'foo.]'));
|
||||
assert(glob.match(p, 'foo.-'));
|
||||
});
|
||||
|
||||
test('full path', function () {
|
||||
@@ -867,35 +907,16 @@ suite('Glob', () => {
|
||||
return slashPath.replace(/\//g, path.sep);
|
||||
}
|
||||
|
||||
test('mergeExpressions', () => {
|
||||
// Empty => empty
|
||||
assert.deepEqual(glob.mergeExpressions(), glob.getEmptyExpression());
|
||||
|
||||
// Doesn't modify given expressions
|
||||
const expr1 = { 'a': true };
|
||||
glob.mergeExpressions(expr1, { 'b': true });
|
||||
assert.deepEqual(expr1, { 'a': true });
|
||||
|
||||
// Merges correctly
|
||||
assert.deepEqual(glob.mergeExpressions({ 'a': true }, { 'b': true }), { 'a': true, 'b': true });
|
||||
|
||||
// Ignores null/undefined portions
|
||||
assert.deepEqual(glob.mergeExpressions(undefined, { 'a': true }, null, { 'b': true }), { 'a': true, 'b': true });
|
||||
|
||||
// Later expressions take precedence
|
||||
assert.deepEqual(glob.mergeExpressions({ 'a': true, 'b': false, 'c': true }, { 'a': false, 'b': true }), { 'a': false, 'b': true, 'c': true });
|
||||
});
|
||||
|
||||
test('relative pattern - glob star', function () {
|
||||
if (isWindows) {
|
||||
let p = { base: 'C:\\DNXConsoleApp\\foo', pattern: '**/*.cs' };
|
||||
let p: glob.IRelativePattern = { base: 'C:\\DNXConsoleApp\\foo', pattern: '**/*.cs', pathToRelative: (from, to) => path.relative(from, to) };
|
||||
assert(glob.match(p, 'C:\\DNXConsoleApp\\foo\\Program.cs'));
|
||||
assert(glob.match(p, 'C:\\DNXConsoleApp\\foo\\bar\\Program.cs'));
|
||||
assert(!glob.match(p, 'C:\\DNXConsoleApp\\foo\\Program.ts'));
|
||||
assert(!glob.match(p, 'C:\\DNXConsoleApp\\Program.cs'));
|
||||
assert(!glob.match(p, 'C:\\other\\DNXConsoleApp\\foo\\Program.ts'));
|
||||
} else {
|
||||
let p: glob.IRelativePattern = { base: '/DNXConsoleApp/foo', pattern: '**/*.cs' };
|
||||
let p: glob.IRelativePattern = { base: '/DNXConsoleApp/foo', pattern: '**/*.cs', pathToRelative: (from, to) => path.relative(from, to) };
|
||||
assert(glob.match(p, '/DNXConsoleApp/foo/Program.cs'));
|
||||
assert(glob.match(p, '/DNXConsoleApp/foo/bar/Program.cs'));
|
||||
assert(!glob.match(p, '/DNXConsoleApp/foo/Program.ts'));
|
||||
@@ -906,14 +927,14 @@ suite('Glob', () => {
|
||||
|
||||
test('relative pattern - single star', function () {
|
||||
if (isWindows) {
|
||||
let p = { base: 'C:\\DNXConsoleApp\\foo', pattern: '*.cs' };
|
||||
let p: glob.IRelativePattern = { base: 'C:\\DNXConsoleApp\\foo', pattern: '*.cs', pathToRelative: (from, to) => path.relative(from, to) };
|
||||
assert(glob.match(p, 'C:\\DNXConsoleApp\\foo\\Program.cs'));
|
||||
assert(!glob.match(p, 'C:\\DNXConsoleApp\\foo\\bar\\Program.cs'));
|
||||
assert(!glob.match(p, 'C:\\DNXConsoleApp\\foo\\Program.ts'));
|
||||
assert(!glob.match(p, 'C:\\DNXConsoleApp\\Program.cs'));
|
||||
assert(!glob.match(p, 'C:\\other\\DNXConsoleApp\\foo\\Program.ts'));
|
||||
} else {
|
||||
let p: glob.IRelativePattern = { base: '/DNXConsoleApp/foo', pattern: '*.cs' };
|
||||
let p: glob.IRelativePattern = { base: '/DNXConsoleApp/foo', pattern: '*.cs', pathToRelative: (from, to) => path.relative(from, to) };
|
||||
assert(glob.match(p, '/DNXConsoleApp/foo/Program.cs'));
|
||||
assert(!glob.match(p, '/DNXConsoleApp/foo/bar/Program.cs'));
|
||||
assert(!glob.match(p, '/DNXConsoleApp/foo/Program.ts'));
|
||||
@@ -924,11 +945,11 @@ suite('Glob', () => {
|
||||
|
||||
test('relative pattern - single star with path', function () {
|
||||
if (isWindows) {
|
||||
let p = { base: 'C:\\DNXConsoleApp\\foo', pattern: 'something/*.cs' };
|
||||
let p: glob.IRelativePattern = { base: 'C:\\DNXConsoleApp\\foo', pattern: 'something/*.cs', pathToRelative: (from, to) => path.relative(from, to) };
|
||||
assert(glob.match(p, 'C:\\DNXConsoleApp\\foo\\something\\Program.cs'));
|
||||
assert(!glob.match(p, 'C:\\DNXConsoleApp\\foo\\Program.cs'));
|
||||
} else {
|
||||
let p: glob.IRelativePattern = { base: '/DNXConsoleApp/foo', pattern: 'something/*.cs' };
|
||||
let p: glob.IRelativePattern = { base: '/DNXConsoleApp/foo', pattern: 'something/*.cs', pathToRelative: (from, to) => path.relative(from, to) };
|
||||
assert(glob.match(p, '/DNXConsoleApp/foo/something/Program.cs'));
|
||||
assert(!glob.match(p, '/DNXConsoleApp/foo/Program.cs'));
|
||||
}
|
||||
|
||||
17
src/vs/base/test/node/id.test.ts
Normal file
17
src/vs/base/test/node/id.test.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* 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 { getMachineId } from 'vs/base/node/id';
|
||||
|
||||
suite('ID', () => {
|
||||
|
||||
test('getMachineId', function () {
|
||||
return getMachineId().then(id => {
|
||||
assert.ok(id);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -9,29 +9,34 @@ import assert = require('assert');
|
||||
|
||||
import mimeCommon = require('vs/base/common/mime');
|
||||
import mime = require('vs/base/node/mime');
|
||||
import { readExactlyByFile } from 'vs/base/node/stream';
|
||||
|
||||
suite('Mime', () => {
|
||||
|
||||
test('detectMimesFromFile (JSON saved as PNG)', function (done: (err?: any) => void) {
|
||||
const file = require.toUrl('./fixtures/some.json.png');
|
||||
mime.detectMimesFromFile(file).then(mimes => {
|
||||
|
||||
readExactlyByFile(file, 512).then(buffer => {
|
||||
const mimes = mime.detectMimeAndEncodingFromBuffer(buffer);
|
||||
assert.deepEqual(mimes.mimes, ['text/plain']);
|
||||
done();
|
||||
}, done);
|
||||
});
|
||||
});
|
||||
|
||||
test('detectMimesFromFile (PNG saved as TXT)', function (done: (err?: any) => void) {
|
||||
mimeCommon.registerTextMime({ id: 'text', mime: 'text/plain', extension: '.txt' });
|
||||
const file = require.toUrl('./fixtures/some.png.txt');
|
||||
mime.detectMimesFromFile(file).then(mimes => {
|
||||
assert.deepEqual(mimes.mimes, ['text/plain', 'application/octet-stream']);
|
||||
readExactlyByFile(file, 512).then(buffer => {
|
||||
const mimes = mime.detectMimeAndEncodingFromBuffer(buffer);
|
||||
assert.deepEqual(mimes.mimes, ['application/octet-stream']);
|
||||
done();
|
||||
}, done);
|
||||
});
|
||||
|
||||
test('detectMimesFromFile (XML saved as PNG)', function (done: (err?: any) => void) {
|
||||
const file = require.toUrl('./fixtures/some.xml.png');
|
||||
mime.detectMimesFromFile(file).then(mimes => {
|
||||
readExactlyByFile(file, 512).then(buffer => {
|
||||
const mimes = mime.detectMimeAndEncodingFromBuffer(buffer);
|
||||
assert.deepEqual(mimes.mimes, ['text/plain']);
|
||||
done();
|
||||
}, done);
|
||||
@@ -39,15 +44,17 @@ suite('Mime', () => {
|
||||
|
||||
test('detectMimesFromFile (QWOFF saved as TXT)', function (done: (err?: any) => void) {
|
||||
const file = require.toUrl('./fixtures/some.qwoff.txt');
|
||||
mime.detectMimesFromFile(file).then(mimes => {
|
||||
assert.deepEqual(mimes.mimes, ['text/plain', 'application/octet-stream']);
|
||||
readExactlyByFile(file, 512).then(buffer => {
|
||||
const mimes = mime.detectMimeAndEncodingFromBuffer(buffer);
|
||||
assert.deepEqual(mimes.mimes, ['application/octet-stream']);
|
||||
done();
|
||||
}, done);
|
||||
});
|
||||
|
||||
test('detectMimesFromFile (CSS saved as QWOFF)', function (done: (err?: any) => void) {
|
||||
const file = require.toUrl('./fixtures/some.css.qwoff');
|
||||
mime.detectMimesFromFile(file).then(mimes => {
|
||||
readExactlyByFile(file, 512).then(buffer => {
|
||||
const mimes = mime.detectMimeAndEncodingFromBuffer(buffer);
|
||||
assert.deepEqual(mimes.mimes, ['text/plain']);
|
||||
done();
|
||||
}, done);
|
||||
@@ -55,7 +62,8 @@ suite('Mime', () => {
|
||||
|
||||
test('detectMimesFromFile (PDF)', function (done: () => void) {
|
||||
const file = require.toUrl('./fixtures/some.pdf');
|
||||
mime.detectMimesFromFile(file).then(mimes => {
|
||||
readExactlyByFile(file, 512).then(buffer => {
|
||||
const mimes = mime.detectMimeAndEncodingFromBuffer(buffer);
|
||||
assert.deepEqual(mimes.mimes, ['application/octet-stream']);
|
||||
done();
|
||||
}, done);
|
||||
@@ -63,17 +71,21 @@ suite('Mime', () => {
|
||||
|
||||
test('autoGuessEncoding (ShiftJIS)', function (done: () => void) {
|
||||
const file = require.toUrl('./fixtures/some.shiftjis.txt');
|
||||
mime.detectMimesFromFile(file, { autoGuessEncoding: true }).then(mimes => {
|
||||
assert.equal(mimes.encoding, 'shiftjis');
|
||||
done();
|
||||
readExactlyByFile(file, 512 * 8).then(buffer => {
|
||||
mime.detectMimeAndEncodingFromBuffer(buffer, true).then(mimes => {
|
||||
assert.equal(mimes.encoding, 'shiftjis');
|
||||
done();
|
||||
});
|
||||
}, done);
|
||||
});
|
||||
|
||||
test('autoGuessEncoding (CP1252)', function (done: () => void) {
|
||||
const file = require.toUrl('./fixtures/some.cp1252.txt');
|
||||
mime.detectMimesFromFile(file, { autoGuessEncoding: true }).then(mimes => {
|
||||
assert.equal(mimes.encoding, 'windows1252');
|
||||
done();
|
||||
readExactlyByFile(file, 512 * 8).then(buffer => {
|
||||
mime.detectMimeAndEncodingFromBuffer(buffer, true).then(mimes => {
|
||||
assert.equal(mimes.encoding, 'windows1252');
|
||||
done();
|
||||
});
|
||||
}, done);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -25,7 +25,7 @@ suite('PFS', () => {
|
||||
const newDir = path.join(parentDir, 'pfs', id);
|
||||
const testFile = path.join(newDir, 'writefile.txt');
|
||||
|
||||
extfs.mkdirp(newDir, 493, (error) => {
|
||||
const onMkdirp = error => {
|
||||
if (error) {
|
||||
return onError(error, done);
|
||||
}
|
||||
@@ -37,7 +37,9 @@ suite('PFS', () => {
|
||||
|
||||
extfs.del(parentDir, os.tmpdir(), () => { }, done);
|
||||
}, error => onError(error, done));
|
||||
});
|
||||
};
|
||||
|
||||
pfs.mkdirp(newDir, 493).done(() => onMkdirp(null), error => onMkdirp(error));
|
||||
});
|
||||
|
||||
test('writeFile - parallel write on different files works', function (done: () => void) {
|
||||
@@ -50,7 +52,7 @@ suite('PFS', () => {
|
||||
const testFile4 = path.join(newDir, 'writefile4.txt');
|
||||
const testFile5 = path.join(newDir, 'writefile5.txt');
|
||||
|
||||
extfs.mkdirp(newDir, 493, (error) => {
|
||||
const onMkdirp = error => {
|
||||
if (error) {
|
||||
return onError(error, done);
|
||||
}
|
||||
@@ -72,7 +74,9 @@ suite('PFS', () => {
|
||||
|
||||
extfs.del(parentDir, os.tmpdir(), () => { }, done);
|
||||
}, error => onError(error, done));
|
||||
});
|
||||
};
|
||||
|
||||
pfs.mkdirp(newDir, 493).done(() => onMkdirp(null), error => onMkdirp(error));
|
||||
});
|
||||
|
||||
test('writeFile - parallel write on same files works and is sequentalized', function (done: () => void) {
|
||||
@@ -81,7 +85,7 @@ suite('PFS', () => {
|
||||
const newDir = path.join(parentDir, 'pfs', id);
|
||||
const testFile = path.join(newDir, 'writefile.txt');
|
||||
|
||||
extfs.mkdirp(newDir, 493, (error) => {
|
||||
const onMkdirp = error => {
|
||||
if (error) {
|
||||
return onError(error, done);
|
||||
}
|
||||
@@ -99,7 +103,9 @@ suite('PFS', () => {
|
||||
|
||||
extfs.del(parentDir, os.tmpdir(), () => { }, done);
|
||||
}, error => onError(error, done));
|
||||
});
|
||||
};
|
||||
|
||||
pfs.mkdirp(newDir, 493).done(() => onMkdirp(null), error => onMkdirp(error));
|
||||
});
|
||||
|
||||
test('rimraf - simple', function (done: () => void) {
|
||||
@@ -107,7 +113,7 @@ suite('PFS', () => {
|
||||
const parentDir = path.join(os.tmpdir(), 'vsctests', id);
|
||||
const newDir = path.join(parentDir, 'extfs', id);
|
||||
|
||||
extfs.mkdirp(newDir, 493, (error) => {
|
||||
const onMkdirp = error => {
|
||||
if (error) {
|
||||
return onError(error, done);
|
||||
}
|
||||
@@ -119,7 +125,9 @@ suite('PFS', () => {
|
||||
assert.ok(!fs.existsSync(newDir));
|
||||
done();
|
||||
}, error => onError(error, done));
|
||||
}); // 493 = 0755
|
||||
};
|
||||
|
||||
pfs.mkdirp(newDir, 493).done(() => onMkdirp(null), error => onMkdirp(error));
|
||||
});
|
||||
|
||||
test('rimraf - recursive folder structure', function (done: () => void) {
|
||||
@@ -127,7 +135,7 @@ suite('PFS', () => {
|
||||
const parentDir = path.join(os.tmpdir(), 'vsctests', id);
|
||||
const newDir = path.join(parentDir, 'extfs', id);
|
||||
|
||||
extfs.mkdirp(newDir, 493, (error) => {
|
||||
const onMkdirp = error => {
|
||||
if (error) {
|
||||
return onError(error, done);
|
||||
}
|
||||
@@ -142,6 +150,8 @@ suite('PFS', () => {
|
||||
assert.ok(!fs.existsSync(newDir));
|
||||
done();
|
||||
}, error => onError(error, done));
|
||||
}); // 493 = 0755
|
||||
};
|
||||
|
||||
pfs.mkdirp(newDir, 493).done(() => onMkdirp(null), error => onMkdirp(error));
|
||||
});
|
||||
});
|
||||
@@ -18,7 +18,7 @@ suite('Ports', () => {
|
||||
}
|
||||
|
||||
// get an initial freeport >= 7000
|
||||
ports.findFreePort(7000, 100, 300000, (initialPort) => {
|
||||
ports.findFreePort(7000, 100, 300000).then(initialPort => {
|
||||
assert.ok(initialPort >= 7000);
|
||||
|
||||
// create a server to block this port
|
||||
@@ -26,7 +26,7 @@ suite('Ports', () => {
|
||||
server.listen(initialPort, null, null, () => {
|
||||
|
||||
// once listening, find another free port and assert that the port is different from the opened one
|
||||
ports.findFreePort(7000, 50, 300000, (freePort) => {
|
||||
ports.findFreePort(7000, 50, 300000).then(freePort => {
|
||||
assert.ok(freePort >= 7000 && freePort !== initialPort);
|
||||
server.close();
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import processes = require('vs/base/node/processes');
|
||||
|
||||
function fork(id: string): cp.ChildProcess {
|
||||
const opts: any = {
|
||||
env: objects.mixin(objects.clone(process.env), {
|
||||
env: objects.mixin(objects.deepClone(process.env), {
|
||||
AMD_ENTRYPOINT: id,
|
||||
PIPE_LOGGING: 'true',
|
||||
VERBOSE_LOGGING: true
|
||||
@@ -86,4 +86,4 @@ suite('Processes', () => {
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
'use strict';
|
||||
|
||||
import assert = require('assert');
|
||||
import fs = require('fs');
|
||||
|
||||
import stream = require('vs/base/node/stream');
|
||||
|
||||
@@ -30,25 +29,6 @@ suite('Stream', () => {
|
||||
}, done);
|
||||
});
|
||||
|
||||
test('readExactlyByStream - ANSI', function (done: (err?: any) => void) {
|
||||
const file = require.toUrl('./fixtures/file.css');
|
||||
|
||||
stream.readExactlyByStream(fs.createReadStream(file), 10).then(({ buffer, bytesRead }) => {
|
||||
assert.equal(bytesRead, 10);
|
||||
assert.equal(buffer.toString(), '/*--------');
|
||||
done();
|
||||
}, done);
|
||||
});
|
||||
|
||||
test('readExactlyByStream - empty', function (done: (err?: any) => void) {
|
||||
const file = require.toUrl('./fixtures/empty.txt');
|
||||
|
||||
stream.readExactlyByStream(fs.createReadStream(file), 10).then(({ bytesRead }) => {
|
||||
assert.equal(bytesRead, 0);
|
||||
done();
|
||||
}, done);
|
||||
});
|
||||
|
||||
test('readToMatchingString - ANSI', function (done: (err?: any) => void) {
|
||||
const file = require.toUrl('./fixtures/file.css');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user