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

@@ -10,6 +10,8 @@ const path = require('path');
const mocha = require('mocha');
const events = require('events');
const defaultReporterName = process.platform === 'win32' ? 'list' : 'spec';
const optimist = require('optimist')
.describe('grep', 'only run tests matching <pattern>').alias('grep', 'g').alias('grep', 'f').string('grep')
.describe('run', 'only run tests from <file>').string('run')
@@ -17,7 +19,9 @@ const optimist = require('optimist')
.describe('build', 'run with build output (out-build)').boolean('build')
.describe('coverage', 'generate coverage report').boolean('coverage')
.describe('debug', 'open dev tools, keep window open, reuse app data').string('debug')
.describe('reporter', 'the mocha reporter').string('reporter').default('reporter', process.platform === 'win32' ? 'dot' : 'spec')
.describe('reporter', 'the mocha reporter').string('reporter').default('reporter', defaultReporterName)
.describe('reporter-options', 'the mocha reporter options').string('reporter-options').default('reporter-options', '')
.describe('tfs').boolean('tfs')
.describe('help', 'show the help').alias('help', 'h');
const argv = optimist.argv;
@@ -33,6 +37,9 @@ if (!argv.debug) {
function deserializeSuite(suite) {
return {
root: suite.root,
suites: suite.suites,
tests: suite.tests,
title: suite.title,
fullTitle: () => suite.fullTitle,
timeout: () => suite.timeout,
@@ -84,6 +91,31 @@ class IPCRunner extends events.EventEmitter {
}
}
function parseReporterOption(value) {
let r = /^([^=]+)=(.*)$/.exec(value);
return r ? { [r[1]]: r[2] } : {};
}
class TFSReporter extends mocha.reporters.Base {
constructor(runner) {
super(runner);
runner.on('pending', test => {
console.log('PEND', test.fullTitle());
});
runner.on('pass', test => {
console.log('OK ', test.fullTitle(), `(${test.duration}ms)`);
});
runner.on('fail', test => {
console.log('FAIL', test.fullTitle(), `(${test.duration}ms)`);
});
runner.once('end', () => {
this.epilogue();
});
}
}
app.on('ready', () => {
const win = new BrowserWindow({
@@ -99,25 +131,38 @@ app.on('ready', () => {
win.webContents.on('did-finish-load', () => {
if (argv.debug) {
win.show();
win.webContents.openDevTools('right');
win.webContents.openDevTools({ mode: 'right' });
}
win.webContents.send('run', argv);
});
win.loadURL(`file://${__dirname}/renderer.html`);
const reporterPath = path.join(path.dirname(require.resolve('mocha')), 'lib', 'reporters', argv.reporter);
let Reporter;
try {
Reporter = require(reporterPath);
} catch (err) {
console.warn(`could not load reporter: ${argv.reporter}`);
Reporter = process.platform === 'win32' ? mocha.reporters.Dot : mocha.reporters.Spec;
}
const runner = new IPCRunner();
new Reporter(runner);
if (argv.tfs) {
new TFSReporter(runner);
} else {
const reporterPath = path.join(path.dirname(require.resolve('mocha')), 'lib', 'reporters', argv.reporter);
let Reporter;
try {
Reporter = require(reporterPath);
} catch (err) {
try {
Reporter = require(argv.reporter);
} catch (err) {
Reporter = process.platform === 'win32' ? mocha.reporters.List : mocha.reporters.Spec;
console.warn(`could not load reporter: ${argv.reporter}, using ${Reporter.name}`);
}
}
let reporterOptions = argv['reporter-options'];
reporterOptions = typeof reporterOptions === 'string' ? [reporterOptions] : reporterOptions;
reporterOptions = reporterOptions.reduce((r, o) => Object.assign(r, parseReporterOption(o)), {});
new Reporter(runner, { reporterOptions });
}
if (!argv.debug) {
ipcMain.on('all done', () => app.exit(runner.didFail ? 1 : 0));

View File

@@ -11,7 +11,10 @@
<script src="../../node_modules/mocha/mocha.js"></script>
<script>
mocha.setup('tdd');
mocha.setup({
ui: 'tdd',
timeout: 5000
});
require('./renderer');
</script>
</body>

View File

@@ -187,6 +187,9 @@ function loadTests(opts) {
function serializeSuite(suite) {
return {
root: suite.root,
suites: suite.suites.map(serializeSuite),
tests: suite.tests.map(serializeRunnable),
title: suite.title,
fullTitle: suite.fullTitle(),
timeout: suite.timeout(),