Merge VS Code 1.23.1 (#1520)

This commit is contained in:
Matt Irvine
2018-06-05 11:24:51 -07:00
committed by GitHub
parent e3baf5c443
commit 0c58f09e59
3651 changed files with 74249 additions and 48599 deletions

View File

@@ -5,30 +5,17 @@
'use strict';
import assert = require('assert');
import os = require('os');
import * as assert from 'assert';
import * as os from 'os';
import path = require('path');
import fs = require('fs');
import extfs = require('vs/base/node/extfs');
import uuid = require('vs/base/common/uuid');
import * as path from 'path';
import * as fs from 'fs';
import * as uuid from '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';
import { testFile } from 'vs/base/test/node/utils';
suite('Config', () => {
function testFile(callback: (error: Error, path: string, cleanUp: (callback: () => void) => void) => void): void {
const id = uuid.generateUuid();
const parentDir = path.join(os.tmpdir(), 'vsctests', id);
const newDir = path.join(parentDir, 'config', id);
const testFile = path.join(newDir, 'config.json');
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 () {
const id = uuid.generateUuid();
const parentDir = path.join(os.tmpdir(), 'vsctests', id);
@@ -52,15 +39,11 @@ suite('Config', () => {
watcher.dispose();
});
test('getConfig / getValue', function (done: () => void) {
testFile((error, testFile, cleanUp) => {
if (error) {
return onError(error, done);
}
test('getConfig / getValue', function () {
return testFile('config', 'config.json').then(res => {
fs.writeFileSync(res.testFile, '// my comment\n{ "foo": "bar" }');
fs.writeFileSync(testFile, '// my comment\n{ "foo": "bar" }');
let watcher = new ConfigWatcher<{ foo: string; }>(testFile);
let watcher = new ConfigWatcher<{ foo: string; }>(res.testFile);
let config = watcher.getConfig();
assert.ok(config);
@@ -72,19 +55,15 @@ suite('Config', () => {
watcher.dispose();
cleanUp(done);
return res.cleanUp();
});
});
test('getConfig / getValue - broken JSON', function (done: () => void) {
testFile((error, testFile, cleanUp) => {
if (error) {
return onError(error, done);
}
test('getConfig / getValue - broken JSON', function () {
return testFile('config', 'config.json').then(res => {
fs.writeFileSync(res.testFile, '// my comment\n "foo": "bar ... ');
fs.writeFileSync(testFile, '// my comment\n "foo": "bar ... ');
let watcher = new ConfigWatcher<{ foo: string; }>(testFile);
let watcher = new ConfigWatcher<{ foo: string; }>(res.testFile);
let config = watcher.getConfig();
assert.ok(config);
@@ -94,24 +73,20 @@ suite('Config', () => {
watcher.dispose();
cleanUp(done);
return res.cleanUp();
});
});
test('watching', function (done: () => void) {
test('watching', function (done) {
this.timeout(10000); // watching is timing intense
testFile((error, testFile, cleanUp) => {
if (error) {
return onError(error, done);
}
testFile('config', 'config.json').then(res => {
fs.writeFileSync(res.testFile, '// my comment\n{ "foo": "bar" }');
fs.writeFileSync(testFile, '// my comment\n{ "foo": "bar" }');
let watcher = new ConfigWatcher<{ foo: string; }>(testFile);
let watcher = new ConfigWatcher<{ foo: string; }>(res.testFile);
watcher.getConfig(); // ensure we are in sync
fs.writeFileSync(testFile, '// my comment\n{ "foo": "changed" }');
fs.writeFileSync(res.testFile, '// my comment\n{ "foo": "changed" }');
watcher.onDidUpdateConfiguration(event => {
assert.ok(event);
@@ -120,24 +95,19 @@ suite('Config', () => {
watcher.dispose();
cleanUp(done);
res.cleanUp().then(done, done);
});
});
}, done);
});
test('watching also works when file created later', function (done: () => void) {
test('watching also works when file created later', function (done) {
this.timeout(10000); // watching is timing intense
testFile((error, testFile, cleanUp) => {
if (error) {
return onError(error, done);
}
let watcher = new ConfigWatcher<{ foo: string; }>(testFile);
testFile('config', 'config.json').then(res => {
let watcher = new ConfigWatcher<{ foo: string; }>(res.testFile);
watcher.getConfig(); // ensure we are in sync
fs.writeFileSync(testFile, '// my comment\n{ "foo": "changed" }');
fs.writeFileSync(res.testFile, '// my comment\n{ "foo": "changed" }');
watcher.onDidUpdateConfiguration(event => {
assert.ok(event);
@@ -146,23 +116,18 @@ suite('Config', () => {
watcher.dispose();
cleanUp(done);
res.cleanUp().then(done, done);
});
});
}, done);
});
test('watching detects the config file getting deleted', function (done: () => void) {
test('watching detects the config file getting deleted', function (done) {
this.timeout(10000); // watching is timing intense
testFile((error, testFile, cleanUp) => {
if (error) {
return onError(error, done);
}
testFile('config', 'config.json').then(res => {
fs.writeFileSync(res.testFile, '// my comment\n{ "foo": "bar" }');
fs.writeFileSync(testFile, '// my comment\n{ "foo": "bar" }');
let watcher = new ConfigWatcher<{ foo: string; }>(testFile);
let watcher = new ConfigWatcher<{ foo: string; }>(res.testFile);
watcher.getConfig(); // ensure we are in sync
watcher.onDidUpdateConfiguration(event => {
@@ -170,25 +135,21 @@ suite('Config', () => {
watcher.dispose();
cleanUp(done);
res.cleanUp().then(done, done);
});
fs.unlinkSync(testFile);
});
fs.unlinkSync(res.testFile);
}, done);
});
test('reload', function (done: () => void) {
testFile((error, testFile, cleanUp) => {
if (error) {
return onError(error, done);
}
test('reload', function (done) {
testFile('config', 'config.json').then(res => {
fs.writeFileSync(res.testFile, '// my comment\n{ "foo": "bar" }');
fs.writeFileSync(testFile, '// my comment\n{ "foo": "bar" }');
let watcher = new ConfigWatcher<{ foo: string; }>(testFile, { changeBufferDelay: 100, onError: console.error });
let watcher = new ConfigWatcher<{ foo: string; }>(res.testFile, { changeBufferDelay: 100, onError: console.error });
watcher.getConfig(); // ensure we are in sync
fs.writeFileSync(testFile, '// my comment\n{ "foo": "changed" }');
fs.writeFileSync(res.testFile, '// my comment\n{ "foo": "changed" }');
// still old values because change is not bubbling yet
assert.equal(watcher.getConfig().foo, 'bar');
@@ -202,8 +163,8 @@ suite('Config', () => {
watcher.dispose();
cleanUp(done);
res.cleanUp().then(done, done);
});
});
}, done);
});
});