Merge remote-tracking branch 'origin/master' into alex/node-modules-vscode

This commit is contained in:
Alexandru Dima
2020-12-17 22:02:47 +01:00
23 changed files with 440 additions and 320 deletions

5
test/.mocharc.json Normal file
View File

@@ -0,0 +1,5 @@
{
"$schema": "https://json.schemastore.org/mocharc",
"ui": "tdd",
"timeout": 10000
}

View File

@@ -1,6 +1,6 @@
{
"name": "vscode-automation",
"version": "1.39.0",
"version": "1.53.0",
"description": "VS Code UI automation driver",
"author": {
"name": "Microsoft Corporation"
@@ -36,4 +36,4 @@
"vscode-uri": "^2.0.3",
"watch": "^1.0.2"
}
}
}

View File

@@ -1,2 +0,0 @@
--ui tdd
--timeout 10000

View File

@@ -205,10 +205,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
};

View File

@@ -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(),

View File

@@ -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,12 @@ 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');
// 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 +28,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 +50,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 +62,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 +72,11 @@ function deserializeRunnable(runnable) {
};
}
function importMochaReporter(name) {
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 +147,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 +158,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);

View File

@@ -135,9 +135,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 +147,7 @@ function serializeRunnable(runnable) {
return {
title: runnable.title,
fullTitle: runnable.fullTitle(),
titlePath: runnable.titlePath(),
async: runnable.async,
slow: runnable.slow(),
speed: runnable.speed,