chore(vscode): update to 1.56.0
This commit is contained in:
@ -15,6 +15,7 @@ const mocha = require('mocha');
|
||||
const events = require('events');
|
||||
const MochaJUnitReporter = require('mocha-junit-reporter');
|
||||
const url = require('url');
|
||||
const net = require('net');
|
||||
const createStatsCollector = require('mocha/lib/stats-collector');
|
||||
const FullJsonStreamReporter = require('../fullJsonStreamReporter');
|
||||
|
||||
@ -31,6 +32,8 @@ const optimist = require('optimist')
|
||||
.describe('debug', 'open dev tools, keep window open, reuse app data').string('debug')
|
||||
.describe('reporter', 'the mocha reporter').string('reporter').default('reporter', 'spec')
|
||||
.describe('reporter-options', 'the mocha reporter options').string('reporter-options').default('reporter-options', '')
|
||||
.describe('wait-server', 'port to connect to and wait before running tests')
|
||||
.describe('timeout', 'timeout for tests')
|
||||
.describe('tfs').string('tfs')
|
||||
.describe('help', 'show the help').alias('help', 'h');
|
||||
|
||||
@ -85,6 +88,12 @@ function importMochaReporter(name) {
|
||||
function deserializeError(err) {
|
||||
const inspect = err.inspect;
|
||||
err.inspect = () => inspect;
|
||||
if (err.actual) {
|
||||
err.actual = JSON.parse(err.actual).value;
|
||||
}
|
||||
if (err.expected) {
|
||||
err.expected = JSON.parse(err.expected).value;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
@ -94,9 +103,13 @@ class IPCRunner extends events.EventEmitter {
|
||||
super();
|
||||
|
||||
this.didFail = false;
|
||||
this.didEnd = false;
|
||||
|
||||
ipcMain.on('start', () => this.emit('start'));
|
||||
ipcMain.on('end', () => this.emit('end'));
|
||||
ipcMain.on('end', () => {
|
||||
this.didEnd = true;
|
||||
this.emit('end');
|
||||
});
|
||||
ipcMain.on('suite', (e, suite) => this.emit('suite', deserializeSuite(suite)));
|
||||
ipcMain.on('suite end', (e, suite) => this.emit('suite end', deserializeSuite(suite)));
|
||||
ipcMain.on('test', (e, test) => this.emit('test', deserializeRunnable(test)));
|
||||
@ -126,13 +139,34 @@ app.on('ready', () => {
|
||||
}
|
||||
});
|
||||
|
||||
// We need to provide a basic `ISandboxConfiguration`
|
||||
// for our preload script to function properly because
|
||||
// some of our types depend on it (e.g. product.ts).
|
||||
ipcMain.handle('vscode:test-vscode-window-config', async () => {
|
||||
return {
|
||||
product: {
|
||||
version: '1.x.y',
|
||||
nameShort: 'Code - OSS Dev',
|
||||
nameLong: 'Code - OSS Dev',
|
||||
applicationName: 'code-oss',
|
||||
dataFolderName: '.vscode-oss',
|
||||
urlProtocol: 'code-oss',
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
// No-op since invoke the IPC as part of IIFE in the preload.
|
||||
ipcMain.handle('vscode:fetchShellEnv', event => { });
|
||||
|
||||
const win = new BrowserWindow({
|
||||
height: 600,
|
||||
width: 800,
|
||||
show: false,
|
||||
webPreferences: {
|
||||
preload: path.join(__dirname, '..', '..', '..', 'src', 'vs', 'base', 'parts', 'sandbox', 'electron-browser', 'preload.js'), // ensure similar environment as VSCode as tests may depend on this
|
||||
additionalArguments: [`--vscode-window-config=vscode:test-vscode-window-config`],
|
||||
nodeIntegration: true,
|
||||
contextIsolation: false,
|
||||
enableWebSQL: false,
|
||||
enableRemoteModule: false,
|
||||
spellcheck: false,
|
||||
@ -146,14 +180,58 @@ app.on('ready', () => {
|
||||
win.show();
|
||||
win.webContents.openDevTools();
|
||||
}
|
||||
win.webContents.send('run', argv);
|
||||
|
||||
if (argv.waitServer) {
|
||||
waitForServer(Number(argv.waitServer)).then(sendRun);
|
||||
} else {
|
||||
sendRun();
|
||||
}
|
||||
});
|
||||
|
||||
async function waitForServer(port) {
|
||||
let timeout;
|
||||
let socket;
|
||||
|
||||
return new Promise(resolve => {
|
||||
socket = net.connect(port, '127.0.0.1');
|
||||
socket.on('error', e => {
|
||||
console.error('error connecting to waitServer', e);
|
||||
resolve();
|
||||
});
|
||||
|
||||
socket.on('close', () => {
|
||||
resolve();
|
||||
});
|
||||
|
||||
timeout = setTimeout(() => {
|
||||
console.error('timed out waiting for before starting tests debugger');
|
||||
resolve();
|
||||
}, 7000);
|
||||
}).finally(() => {
|
||||
if (socket) {
|
||||
socket.end();
|
||||
}
|
||||
clearTimeout(timeout);
|
||||
});
|
||||
}
|
||||
|
||||
function sendRun() {
|
||||
win.webContents.send('run', argv);
|
||||
}
|
||||
|
||||
win.loadURL(url.format({ pathname: path.join(__dirname, 'renderer.html'), protocol: 'file:', slashes: true }));
|
||||
|
||||
const runner = new IPCRunner();
|
||||
createStatsCollector(runner);
|
||||
|
||||
// Handle renderer crashes, #117068
|
||||
win.webContents.on('render-process-gone', (evt, details) => {
|
||||
if (!runner.didEnd) {
|
||||
console.error(`Renderer process crashed with: ${JSON.stringify(details)}`);
|
||||
app.exit(1);
|
||||
}
|
||||
});
|
||||
|
||||
if (argv.tfs) {
|
||||
new mocha.reporters.Spec(runner);
|
||||
new MochaJUnitReporter(runner, {
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
/*eslint-env mocha*/
|
||||
|
||||
(function() {
|
||||
(function () {
|
||||
const fs = require('fs');
|
||||
const originals = {};
|
||||
let logging = false;
|
||||
@ -21,7 +21,7 @@
|
||||
};
|
||||
|
||||
function createSpy(element, cnt) {
|
||||
return function(...args) {
|
||||
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')) : ''));
|
||||
}
|
||||
@ -213,14 +213,39 @@ function serializeError(err) {
|
||||
return {
|
||||
message: err.message,
|
||||
stack: err.stack,
|
||||
actual: err.actual,
|
||||
expected: err.expected,
|
||||
actual: safeStringify({ value: err.actual }),
|
||||
expected: safeStringify({ value: err.expected }),
|
||||
uncaught: err.uncaught,
|
||||
showDiff: err.showDiff,
|
||||
inspect: typeof err.inspect === 'function' ? err.inspect() : ''
|
||||
};
|
||||
}
|
||||
|
||||
function safeStringify(obj) {
|
||||
const seen = new Set();
|
||||
return JSON.stringify(obj, (key, value) => {
|
||||
if (isObject(value) || Array.isArray(value)) {
|
||||
if (seen.has(value)) {
|
||||
return '[Circular]';
|
||||
} else {
|
||||
seen.add(value);
|
||||
}
|
||||
}
|
||||
return value;
|
||||
});
|
||||
}
|
||||
|
||||
function isObject(obj) {
|
||||
// The method can't do a type cast since there are type (like strings) which
|
||||
// are subclasses of any put not positvely matched by the function. Hence type
|
||||
// narrowing results in wrong results.
|
||||
return typeof obj === 'object'
|
||||
&& obj !== null
|
||||
&& !Array.isArray(obj)
|
||||
&& !(obj instanceof RegExp)
|
||||
&& !(obj instanceof Date);
|
||||
}
|
||||
|
||||
class IPCReporter {
|
||||
|
||||
constructor(runner) {
|
||||
@ -239,6 +264,10 @@ class IPCReporter {
|
||||
}
|
||||
|
||||
function runTests(opts) {
|
||||
// this *must* come before loadTests, or it doesn't work.
|
||||
if (opts.timeout !== undefined) {
|
||||
mocha.timeout(opts.timeout);
|
||||
}
|
||||
|
||||
return loadTests(opts).then(() => {
|
||||
|
||||
|
Reference in New Issue
Block a user