chore(vscode): update to 1.53.2
These conflicts will be resolved in the following commits. We do it this way so that PR review is possible.
This commit is contained in:
@ -7,9 +7,9 @@
|
||||
|
||||
const path = require('path');
|
||||
const glob = require('glob');
|
||||
const fs = require('fs');
|
||||
const events = require('events');
|
||||
const mocha = require('mocha');
|
||||
const createStatsCollector = require('../../../node_modules/mocha/lib/stats-collector');
|
||||
const MochaJUnitReporter = require('mocha-junit-reporter');
|
||||
const url = require('url');
|
||||
const minimatch = require('minimatch');
|
||||
@ -186,6 +186,7 @@ class EchoRunner extends events.EventEmitter {
|
||||
|
||||
constructor(event, title = '') {
|
||||
super();
|
||||
createStatsCollector(this);
|
||||
event.on('start', () => this.emit('start'));
|
||||
event.on('end', () => this.emit('end'));
|
||||
event.on('suite', (suite) => this.emit('suite', EchoRunner.deserializeSuite(suite, title)));
|
||||
@ -205,10 +206,10 @@ class EchoRunner extends events.EventEmitter {
|
||||
suites: suite.suites,
|
||||
tests: suite.tests,
|
||||
title: titleExtra && suite.title ? `${suite.title} - /${titleExtra}/` : suite.title,
|
||||
titlePath: () => suite.titlePath,
|
||||
fullTitle: () => suite.fullTitle,
|
||||
timeout: () => suite.timeout,
|
||||
retries: () => suite.retries,
|
||||
enableTimeouts: () => suite.enableTimeouts,
|
||||
slow: () => suite.slow,
|
||||
bail: () => suite.bail
|
||||
};
|
||||
@ -218,6 +219,7 @@ class EchoRunner extends events.EventEmitter {
|
||||
return {
|
||||
title: runnable.title,
|
||||
fullTitle: () => titleExtra && runnable.fullTitle ? `${runnable.fullTitle} - /${titleExtra}/` : runnable.fullTitle,
|
||||
titlePath: () => runnable.titlePath,
|
||||
async: runnable.async,
|
||||
slow: () => runnable.slow,
|
||||
speed: runnable.speed,
|
||||
|
@ -69,9 +69,9 @@
|
||||
tests: suite.tests.map(serializeRunnable),
|
||||
title: suite.title,
|
||||
fullTitle: suite.fullTitle(),
|
||||
titlePath: suite.titlePath(),
|
||||
timeout: suite.timeout(),
|
||||
retries: suite.retries(),
|
||||
enableTimeouts: suite.enableTimeouts(),
|
||||
slow: suite.slow(),
|
||||
bail: suite.bail()
|
||||
};
|
||||
@ -79,6 +79,7 @@
|
||||
function serializeRunnable(runnable) {
|
||||
return {
|
||||
title: runnable.title,
|
||||
titlePath: runnable.titlePath(),
|
||||
fullTitle: runnable.fullTitle(),
|
||||
async: runnable.async,
|
||||
slow: runnable.slow(),
|
||||
|
@ -3,6 +3,10 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
// mocha disables running through electron by default. Note that this must
|
||||
// come before any mocha imports.
|
||||
process.env.MOCHA_COLORS = '1';
|
||||
|
||||
const { app, BrowserWindow, ipcMain } = require('electron');
|
||||
const { tmpdir } = require('os');
|
||||
const { join } = require('path');
|
||||
@ -11,13 +15,13 @@ const mocha = require('mocha');
|
||||
const events = require('events');
|
||||
const MochaJUnitReporter = require('mocha-junit-reporter');
|
||||
const url = require('url');
|
||||
const createStatsCollector = require('mocha/lib/stats-collector');
|
||||
const FullJsonStreamReporter = require('../fullJsonStreamReporter');
|
||||
|
||||
// Disable render process reuse, we still have
|
||||
// non-context aware native modules in the renderer.
|
||||
app.allowRendererProcessReuse = false;
|
||||
|
||||
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')
|
||||
@ -25,7 +29,7 @@ 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', defaultReporterName)
|
||||
.describe('reporter', 'the mocha reporter').string('reporter').default('reporter', 'spec')
|
||||
.describe('reporter-options', 'the mocha reporter options').string('reporter-options').default('reporter-options', '')
|
||||
.describe('tfs').string('tfs')
|
||||
.describe('help', 'show the help').alias('help', 'h');
|
||||
@ -47,10 +51,10 @@ function deserializeSuite(suite) {
|
||||
suites: suite.suites,
|
||||
tests: suite.tests,
|
||||
title: suite.title,
|
||||
titlePath: () => suite.titlePath,
|
||||
fullTitle: () => suite.fullTitle,
|
||||
timeout: () => suite.timeout,
|
||||
retries: () => suite.retries,
|
||||
enableTimeouts: () => suite.enableTimeouts,
|
||||
slow: () => suite.slow,
|
||||
bail: () => suite.bail
|
||||
};
|
||||
@ -59,6 +63,7 @@ function deserializeSuite(suite) {
|
||||
function deserializeRunnable(runnable) {
|
||||
return {
|
||||
title: runnable.title,
|
||||
titlePath: () => runnable.titlePath,
|
||||
fullTitle: () => runnable.fullTitle,
|
||||
async: runnable.async,
|
||||
slow: () => runnable.slow,
|
||||
@ -68,6 +73,15 @@ function deserializeRunnable(runnable) {
|
||||
};
|
||||
}
|
||||
|
||||
function importMochaReporter(name) {
|
||||
if (name === 'full-json-stream') {
|
||||
return FullJsonStreamReporter;
|
||||
}
|
||||
|
||||
const reporterPath = path.join(path.dirname(require.resolve('mocha')), 'lib', 'reporters', name);
|
||||
return require(reporterPath);
|
||||
}
|
||||
|
||||
function deserializeError(err) {
|
||||
const inspect = err.inspect;
|
||||
err.inspect = () => inspect;
|
||||
@ -138,6 +152,7 @@ app.on('ready', () => {
|
||||
win.loadURL(url.format({ pathname: path.join(__dirname, 'renderer.html'), protocol: 'file:', slashes: true }));
|
||||
|
||||
const runner = new IPCRunner();
|
||||
createStatsCollector(runner);
|
||||
|
||||
if (argv.tfs) {
|
||||
new mocha.reporters.Spec(runner);
|
||||
@ -148,11 +163,19 @@ app.on('ready', () => {
|
||||
}
|
||||
});
|
||||
} else {
|
||||
const reporterPath = path.join(path.dirname(require.resolve('mocha')), 'lib', 'reporters', argv.reporter);
|
||||
let Reporter;
|
||||
// mocha patches symbols to use windows escape codes, but it seems like
|
||||
// Electron mangles these in its output.
|
||||
if (process.platform === 'win32') {
|
||||
Object.assign(importMochaReporter('base').symbols, {
|
||||
ok: '+',
|
||||
err: 'X',
|
||||
dot: '.',
|
||||
});
|
||||
}
|
||||
|
||||
let Reporter;
|
||||
try {
|
||||
Reporter = require(reporterPath);
|
||||
Reporter = importMochaReporter(argv.reporter);
|
||||
} catch (err) {
|
||||
try {
|
||||
Reporter = require(argv.reporter);
|
||||
|
@ -35,7 +35,8 @@
|
||||
|
||||
mocha.setup({
|
||||
ui: 'tdd',
|
||||
timeout: 5000
|
||||
timeout: 5000,
|
||||
forbidOnly: typeof process.env['BUILD_ARTIFACTSTAGINGDIRECTORY'] === 'string' // disallow .only() when running on build machine
|
||||
});
|
||||
require('./renderer');
|
||||
</script>
|
||||
|
@ -5,6 +5,60 @@
|
||||
|
||||
/*eslint-env mocha*/
|
||||
|
||||
(function() {
|
||||
const fs = require('fs');
|
||||
const originals = {};
|
||||
let logging = false;
|
||||
let withStacks = false;
|
||||
|
||||
self.beginLoggingFS = (_withStacks) => {
|
||||
logging = true;
|
||||
withStacks = _withStacks || false;
|
||||
};
|
||||
self.endLoggingFS = () => {
|
||||
logging = false;
|
||||
withStacks = false;
|
||||
};
|
||||
|
||||
function createSpy(element, cnt) {
|
||||
return function(...args) {
|
||||
if (logging) {
|
||||
console.log(`calling ${element}: ` + args.slice(0, cnt).join(',') + (withStacks ? (`\n` + new Error().stack.split('\n').slice(2).join('\n')) : ''));
|
||||
}
|
||||
return originals[element].call(this, ...args);
|
||||
};
|
||||
}
|
||||
|
||||
function intercept(element, cnt) {
|
||||
originals[element] = fs[element];
|
||||
fs[element] = createSpy(element, cnt);
|
||||
}
|
||||
|
||||
[
|
||||
['realpathSync', 1],
|
||||
['readFileSync', 1],
|
||||
['openSync', 3],
|
||||
['readSync', 1],
|
||||
['closeSync', 1],
|
||||
['readFile', 2],
|
||||
['mkdir', 1],
|
||||
['lstat', 1],
|
||||
['stat', 1],
|
||||
['watch', 1],
|
||||
['readdir', 1],
|
||||
['access', 2],
|
||||
['open', 2],
|
||||
['write', 1],
|
||||
['fdatasync', 1],
|
||||
['close', 1],
|
||||
['read', 1],
|
||||
['unlink', 1],
|
||||
['rmdir', 1],
|
||||
].forEach((element) => {
|
||||
intercept(element[0], element[1]);
|
||||
})
|
||||
})();
|
||||
|
||||
const { ipcRenderer } = require('electron');
|
||||
const assert = require('assert');
|
||||
const path = require('path');
|
||||
@ -135,9 +189,9 @@ function serializeSuite(suite) {
|
||||
tests: suite.tests.map(serializeRunnable),
|
||||
title: suite.title,
|
||||
fullTitle: suite.fullTitle(),
|
||||
titlePath: suite.titlePath(),
|
||||
timeout: suite.timeout(),
|
||||
retries: suite.retries(),
|
||||
enableTimeouts: suite.enableTimeouts(),
|
||||
slow: suite.slow(),
|
||||
bail: suite.bail()
|
||||
};
|
||||
@ -147,6 +201,7 @@ function serializeRunnable(runnable) {
|
||||
return {
|
||||
title: runnable.title,
|
||||
fullTitle: runnable.fullTitle(),
|
||||
titlePath: runnable.titlePath(),
|
||||
async: runnable.async,
|
||||
slow: runnable.slow(),
|
||||
speed: runnable.speed,
|
||||
|
52
lib/vscode/test/unit/fullJsonStreamReporter.js
Normal file
52
lib/vscode/test/unit/fullJsonStreamReporter.js
Normal file
@ -0,0 +1,52 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
const { constants } = require('mocha/lib/runner');
|
||||
const BaseRunner = require('mocha/lib/reporters/base');
|
||||
|
||||
const {
|
||||
EVENT_TEST_PASS,
|
||||
EVENT_TEST_FAIL,
|
||||
EVENT_RUN_BEGIN,
|
||||
EVENT_RUN_END,
|
||||
} = constants;
|
||||
|
||||
/**
|
||||
* Similar to the mocha JSON stream, but includes additional information
|
||||
* on failure. Specifically, the mocha json-stream does not include unmangled
|
||||
* expected versus actual results.
|
||||
*
|
||||
* Writes a superset of the data that json-stream normally would.
|
||||
*/
|
||||
module.exports = class FullJsonStreamReporter extends BaseRunner {
|
||||
constructor(runner, options) {
|
||||
super(runner, options);
|
||||
|
||||
const total = runner.total;
|
||||
runner.once(EVENT_RUN_BEGIN, () => writeEvent(['start', { total }]));
|
||||
runner.once(EVENT_RUN_END, () => writeEvent(['end', this.stats]));
|
||||
|
||||
runner.on(EVENT_TEST_PASS, test => writeEvent(['pass', clean(test)]));
|
||||
runner.on(EVENT_TEST_FAIL, (test, err) => {
|
||||
test = clean(test);
|
||||
test.actual = err.actual;
|
||||
test.expected = err.expected;
|
||||
test.err = err.message;
|
||||
test.stack = err.stack || null;
|
||||
writeEvent(['fail', test]);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function writeEvent(event) {
|
||||
process.stdout.write(JSON.stringify(event) + '\n');
|
||||
}
|
||||
|
||||
const clean = test => ({
|
||||
title: test.title,
|
||||
fullTitle: test.fullTitle(),
|
||||
duration: test.duration,
|
||||
currentRetry: test.currentRetry()
|
||||
});
|
Reference in New Issue
Block a user