mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
VS Code merge to df8fe74bd55313de0dd2303bc47a4aab0ca56b0e (#17979)
* Merge from vscode 504f934659740e9d41501cad9f162b54d7745ad9 * delete unused folders * distro * Bump build node version * update chokidar * FIx hygiene errors * distro * Fix extension lint issues * Remove strict-vscode * Add copyright header exemptions * Bump vscode-extension-telemetry to fix webpacking issue with zone.js * distro * Fix failing tests (revert marked.js back to current one until we decide to update) * Skip searchmodel test * Fix mac build * temp debug script loading * Try disabling coverage * log error too * Revert "log error too" This reverts commit af0183e5d4ab458fdf44b88fbfab9908d090526f. * Revert "temp debug script loading" This reverts commit 3d687d541c76db2c5b55626c78ae448d3c25089c. * Add comments explaining coverage disabling * Fix ansi_up loading issue * Merge latest from ads * Use newer option * Fix compile * add debug logging warn * Always log stack * log more * undo debug * Update to use correct base path (+cleanup) * distro * fix compile errors * Remove strict-vscode * Fix sql editors not showing * Show db dropdown input & fix styling * Fix more info in gallery * Fix gallery asset requests * Delete unused workflow * Fix tapable resolutions for smoke test compile error * Fix smoke compile * Disable crash reporting * Disable interactive Co-authored-by: ADS Merger <karlb@microsoft.com>
This commit is contained in:
@@ -14,6 +14,7 @@ const MochaJUnitReporter = require('mocha-junit-reporter');
|
||||
const url = require('url');
|
||||
const minimatch = require('minimatch');
|
||||
const playwright = require('playwright');
|
||||
const { applyReporter } = require('../reporter');
|
||||
|
||||
// opts
|
||||
const defaultReporterName = process.platform === 'win32' ? 'list' : 'spec';
|
||||
@@ -21,8 +22,8 @@ const optimist = require('optimist')
|
||||
// .describe('grep', 'only run tests matching <pattern>').alias('grep', 'g').alias('grep', 'f').string('grep')
|
||||
.describe('build', 'run with build output (out-build)').boolean('build')
|
||||
.describe('run', 'only run tests matching <relative_file_path>').string('run')
|
||||
.describe('glob', 'only run tests matching <glob_pattern>').string('glob')
|
||||
.describe('debug', 'do not run browsers headless').boolean('debug')
|
||||
.describe('grep', 'only run tests matching <pattern>').alias('grep', 'g').alias('grep', 'f').string('grep')
|
||||
.describe('debug', 'do not run browsers headless').alias('debug', ['debug-browser']).boolean('debug')
|
||||
.describe('browser', 'browsers in which tests should run').string('browser').default('browser', ['chromium', 'firefox', 'webkit'])
|
||||
.describe('reporter', 'the mocha reporter').string('reporter').default('reporter', defaultReporterName)
|
||||
.describe('reporter-options', 'the mocha reporter options').string('reporter-options').default('reporter-options', '')
|
||||
@@ -51,30 +52,7 @@ const withReporter = (function () {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const reporterPath = path.join(path.dirname(require.resolve('mocha')), 'lib', 'reporters', argv.reporter);
|
||||
let ctor;
|
||||
|
||||
try {
|
||||
ctor = require(reporterPath);
|
||||
} catch (err) {
|
||||
try {
|
||||
ctor = require(argv.reporter);
|
||||
} catch (err) {
|
||||
ctor = process.platform === 'win32' ? mocha.reporters.List : mocha.reporters.Spec;
|
||||
console.warn(`could not load reporter: ${argv.reporter}, using ${ctor.name}`);
|
||||
}
|
||||
}
|
||||
|
||||
function parseReporterOption(value) {
|
||||
let r = /^([^=]+)=(.*)$/.exec(value);
|
||||
return r ? { [r[1]]: r[2] } : {};
|
||||
}
|
||||
|
||||
let reporterOptions = argv['reporter-options'];
|
||||
reporterOptions = typeof reporterOptions === 'string' ? [reporterOptions] : reporterOptions;
|
||||
reporterOptions = reporterOptions.reduce((r, o) => Object.assign(r, parseReporterOption(o)), {});
|
||||
|
||||
return (_, runner) => new ctor(runner, { reporterOptions })
|
||||
return (_, runner) => applyReporter(runner, argv);
|
||||
}
|
||||
})()
|
||||
|
||||
@@ -103,7 +81,7 @@ const testModules = (async function () {
|
||||
} else {
|
||||
// glob patterns (--glob)
|
||||
const defaultGlob = '**/*.test.js';
|
||||
const pattern = argv.glob || defaultGlob
|
||||
const pattern = argv.run || defaultGlob
|
||||
isDefaultModules = pattern === defaultGlob;
|
||||
|
||||
promise = new Promise((resolve, reject) => {
|
||||
@@ -146,8 +124,7 @@ function consoleLogFn(msg) {
|
||||
}
|
||||
|
||||
async function runTestsInBrowser(testModules, browserType) {
|
||||
const args = process.platform === 'linux' && browserType === 'chromium' ? ['--disable-setuid-sandbox'] : undefined; // setuid sandboxes requires root and is used in containers so we disable this to support our CI
|
||||
const browser = await playwright[browserType].launch({ headless: !Boolean(argv.debug), args });
|
||||
const browser = await playwright[browserType].launch({ headless: !Boolean(argv.debug), devtools: Boolean(argv.debug) });
|
||||
const context = await browser.newContext();
|
||||
const page = await context.newPage();
|
||||
const target = url.pathToFileURL(path.join(__dirname, 'renderer.html'));
|
||||
@@ -184,7 +161,10 @@ async function runTestsInBrowser(testModules, browserType) {
|
||||
|
||||
try {
|
||||
// @ts-expect-error
|
||||
await page.evaluate(modules => loadAndRun(modules), testModules);
|
||||
await page.evaluate(opts => loadAndRun(opts), {
|
||||
modules: testModules,
|
||||
grep: argv.grep,
|
||||
});
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
@@ -236,7 +216,8 @@ class EchoRunner extends events.EventEmitter {
|
||||
async: runnable.async,
|
||||
slow: () => runnable.slow,
|
||||
speed: runnable.speed,
|
||||
duration: runnable.duration
|
||||
duration: runnable.duration,
|
||||
currentRetry: () => runnable.currentRetry,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -86,7 +86,8 @@
|
||||
async: runnable.async,
|
||||
slow: runnable.slow(),
|
||||
speed: runnable.speed,
|
||||
duration: runnable.duration
|
||||
duration: runnable.duration,
|
||||
currentRetry: runnable.currentRetry(),
|
||||
};
|
||||
}
|
||||
function serializeError(err) {
|
||||
@@ -114,7 +115,7 @@
|
||||
runner.on('pending', test => window.mocha_report('pending', serializeRunnable(test)));
|
||||
};
|
||||
|
||||
window.loadAndRun = async function loadAndRun(modules, manual = false) {
|
||||
window.loadAndRun = async function loadAndRun({ modules, grep }, manual = false) {
|
||||
// load
|
||||
await Promise.all(modules.map(module => new Promise((resolve, reject) => {
|
||||
require([module], resolve, err => {
|
||||
@@ -132,6 +133,10 @@
|
||||
|
||||
// run
|
||||
return new Promise((resolve, reject) => {
|
||||
if (grep) {
|
||||
mocha.grep(grep);
|
||||
}
|
||||
|
||||
if (!manual) {
|
||||
mocha.reporter(PlaywrightReporter);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ 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');
|
||||
const { applyReporter, importMochaReporter } = require('../reporter');
|
||||
|
||||
// Disable render process reuse, we still have
|
||||
// non-context aware native modules in the renderer.
|
||||
@@ -85,15 +85,6 @@ 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;
|
||||
@@ -134,11 +125,6 @@ class IPCRunner extends events.EventEmitter {
|
||||
}
|
||||
}
|
||||
|
||||
function parseReporterOption(value) {
|
||||
let r = /^([^=]+)=(.*)$/.exec(value);
|
||||
return r ? { [r[1]]: r[2] } : {};
|
||||
}
|
||||
|
||||
app.on('ready', () => {
|
||||
|
||||
ipcMain.on('error', (_, err) => {
|
||||
@@ -178,8 +164,7 @@ app.on('ready', () => {
|
||||
contextIsolation: false,
|
||||
enableWebSQL: false,
|
||||
spellcheck: false,
|
||||
nativeWindowOpen: true,
|
||||
webviewTag: true
|
||||
nativeWindowOpen: true
|
||||
}
|
||||
});
|
||||
|
||||
@@ -214,7 +199,7 @@ app.on('ready', () => {
|
||||
timeout = setTimeout(() => {
|
||||
console.error('timed out waiting for before starting tests debugger');
|
||||
resolve();
|
||||
}, 7000);
|
||||
}, 15000);
|
||||
}).finally(() => {
|
||||
if (socket) {
|
||||
socket.end();
|
||||
@@ -259,23 +244,7 @@ app.on('ready', () => {
|
||||
});
|
||||
}
|
||||
|
||||
let Reporter;
|
||||
try {
|
||||
Reporter = importMochaReporter(argv.reporter);
|
||||
} 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 });
|
||||
applyReporter(runner, argv);
|
||||
}
|
||||
|
||||
if (!argv.debug) {
|
||||
|
||||
@@ -250,6 +250,10 @@ function serializeError(err) {
|
||||
function safeStringify(obj) {
|
||||
const seen = new Set();
|
||||
return JSON.stringify(obj, (key, value) => {
|
||||
if (value === undefined) {
|
||||
return '[undefined]';
|
||||
}
|
||||
|
||||
if (isObject(value) || Array.isArray(value)) {
|
||||
if (seen.has(value)) {
|
||||
return '[Circular]';
|
||||
|
||||
@@ -7,6 +7,7 @@ const { constants } = require('mocha/lib/runner');
|
||||
const BaseRunner = require('mocha/lib/reporters/base');
|
||||
|
||||
const {
|
||||
EVENT_TEST_BEGIN,
|
||||
EVENT_TEST_PASS,
|
||||
EVENT_TEST_FAIL,
|
||||
EVENT_RUN_BEGIN,
|
||||
@@ -28,6 +29,7 @@ module.exports = class FullJsonStreamReporter extends BaseRunner {
|
||||
runner.once(EVENT_RUN_BEGIN, () => writeEvent(['start', { total }]));
|
||||
runner.once(EVENT_RUN_END, () => writeEvent(['end', this.stats]));
|
||||
|
||||
runner.on(EVENT_TEST_BEGIN, test => writeEvent(['testStart', clean(test)]));
|
||||
runner.on(EVENT_TEST_PASS, test => writeEvent(['pass', clean(test)]));
|
||||
runner.on(EVENT_TEST_FAIL, (test, err) => {
|
||||
test = clean(test);
|
||||
|
||||
42
test/unit/reporter.js
Normal file
42
test/unit/reporter.js
Normal file
@@ -0,0 +1,42 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
const mocha = require('mocha');
|
||||
const FullJsonStreamReporter = require('./fullJsonStreamReporter');
|
||||
const path = require('path');
|
||||
|
||||
function parseReporterOption(value) {
|
||||
let r = /^([^=]+)=(.*)$/.exec(value);
|
||||
return r ? { [r[1]]: r[2] } : {};
|
||||
}
|
||||
|
||||
exports.importMochaReporter = name => {
|
||||
if (name === 'full-json-stream') {
|
||||
return FullJsonStreamReporter;
|
||||
}
|
||||
|
||||
const reporterPath = path.join(path.dirname(require.resolve('mocha')), 'lib', 'reporters', name);
|
||||
return require(reporterPath);
|
||||
}
|
||||
|
||||
exports.applyReporter = (runner, argv) => {
|
||||
let Reporter;
|
||||
try {
|
||||
Reporter = exports.importMochaReporter(argv.reporter);
|
||||
} 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)), {});
|
||||
|
||||
return new Reporter(runner, { reporterOptions });
|
||||
}
|
||||
Reference in New Issue
Block a user