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:
Charles Gagnon
2022-01-06 09:06:56 -08:00
committed by GitHub
parent fd2736b6a6
commit 2bc6a0cd01
2099 changed files with 79520 additions and 43813 deletions

View File

@@ -3,10 +3,15 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import minimist = require('minimist');
import { Application } from '../../../../automation';
import { afterSuite, beforeSuite } from '../../utils';
export function setup() {
export function setup(opts: minimist.ParsedArgs) {
describe('Editor', () => {
beforeSuite(opts);
afterSuite(opts);
it('shows correct quick outline', async function () {
const app = this.app as Application;
await app.workbench.quickaccess.openFile('www');
@@ -14,21 +19,5 @@ export function setup() {
await app.workbench.quickaccess.openQuickOutline();
await app.workbench.quickinput.waitForQuickInputElements(names => names.length >= 6);
});
// it('folds/unfolds the code correctly', async function () {
// await app.workbench.quickaccess.openFile('www');
// // Fold
// await app.workbench.editor.foldAtLine(3);
// await app.workbench.editor.waitUntilShown(3);
// await app.workbench.editor.waitUntilHidden(4);
// await app.workbench.editor.waitUntilHidden(5);
// // Unfold
// await app.workbench.editor.unfoldAtLine(3);
// await app.workbench.editor.waitUntilShown(3);
// await app.workbench.editor.waitUntilShown(4);
// await app.workbench.editor.waitUntilShown(5);
// });
});
}

View File

@@ -3,10 +3,15 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import minimist = require('minimist');
import { Application, Quality } from '../../../../automation';
import { afterSuite, beforeSuite } from '../../utils';
export function setup() {
export function setup(opts: minimist.ParsedArgs) {
describe('Extensions', () => {
beforeSuite(opts);
afterSuite(opts);
it(`install and enable vscode-smoketest-check extension`, async function () {
const app = this.app as Application;
@@ -16,7 +21,7 @@ export function setup() {
await app.workbench.extensions.openExtensionsViewlet();
await app.workbench.extensions.installExtension('michelkaporin.vscode-smoketest-check', true);
await app.workbench.extensions.installExtension('ms-vscode.vscode-smoketest-check', true);
// Close extension editor because keybindings dispatch is not working when web views are opened and focused
// https://github.com/microsoft/vscode/issues/110276

View File

@@ -3,10 +3,15 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import minimist = require('minimist');
import { Application, ProblemSeverity, Problems } from '../../../../automation/out';
import { afterSuite, beforeSuite } from '../../utils';
export function setup() {
export function setup(opts: minimist.ParsedArgs) {
describe('Language Features', () => {
beforeSuite(opts);
afterSuite(opts);
it('verifies quick outline', async function () {
const app = this.app as Application;
await app.workbench.quickaccess.openFile('style.css');

View File

@@ -4,8 +4,10 @@
*--------------------------------------------------------------------------------------------*/
import * as fs from 'fs';
import minimist = require('minimist');
import * as path from 'path';
import { Application } from '../../../../automation';
import { afterSuite, beforeSuite } from '../../utils';
function toUri(path: string): string {
if (process.platform === 'win32') {
@@ -34,19 +36,15 @@ async function createWorkspaceFile(workspacePath: string): Promise<string> {
return workspaceFilePath;
}
export function setup() {
export function setup(opts: minimist.ParsedArgs) {
describe('Multiroot', () => {
before(async function () {
const app = this.app as Application;
const workspaceFilePath = await createWorkspaceFile(app.workspacePathOrFolder);
// restart with preventing additional windows from restoring
// to ensure the window after restart is the multi-root workspace
await app.restart({ workspaceOrFolder: workspaceFilePath });
beforeSuite(opts, async opts => {
const workspacePath = await createWorkspaceFile(opts.workspacePath);
return { ...opts, workspacePath };
});
afterSuite(opts);
it('shows results from all folders', async function () {
const app = this.app as Application;
await app.workbench.quickaccess.openQuickAccess('*.*');

View File

@@ -4,20 +4,13 @@
*--------------------------------------------------------------------------------------------*/
import * as cp from 'child_process';
import minimist = require('minimist');
import { Application } from '../../../../automation';
import { afterSuite, beforeSuite } from '../../utils';
// function wait(ms: number): Promise<void> {
// return new Promise(r => setTimeout(r, ms));
// }
export function setup() {
describe('Notebooks', () => {
after(async function () {
const app = this.app as Application;
cp.execSync('git checkout . --quiet', { cwd: app.workspacePathOrFolder });
cp.execSync('git reset --hard HEAD --quiet', { cwd: app.workspacePathOrFolder });
});
export function setup(opts: minimist.ParsedArgs) {
describe.skip('Notebooks', () => {
beforeSuite(opts);
afterEach(async function () {
const app = this.app as Application;
@@ -25,34 +18,42 @@ export function setup() {
await app.workbench.quickaccess.runCommand('workbench.action.closeActiveEditor');
});
// it('inserts/edits code cell', async function () {
// const app = this.app as Application;
// await app.workbench.notebook.openNotebook();
// await app.workbench.notebook.focusNextCell();
// await app.workbench.notebook.insertNotebookCell('code');
// await app.workbench.notebook.waitForTypeInEditor('// some code');
// await app.workbench.notebook.stopEditingCell();
// });
after(async function () {
const app = this.app as Application;
cp.execSync('git checkout . --quiet', { cwd: app.workspacePathOrFolder });
cp.execSync('git reset --hard HEAD --quiet', { cwd: app.workspacePathOrFolder });
});
// it('inserts/edits markdown cell', async function () {
// const app = this.app as Application;
// await app.workbench.notebook.openNotebook();
// await app.workbench.notebook.focusNextCell();
// await app.workbench.notebook.insertNotebookCell('markdown');
// await app.workbench.notebook.waitForTypeInEditor('## hello2! ');
// await app.workbench.notebook.stopEditingCell();
// await app.workbench.notebook.waitForMarkdownContents('h2', 'hello2!');
// });
afterSuite(opts);
// it('moves focus as it inserts/deletes a cell', async function () {
// const app = this.app as Application;
// await app.workbench.notebook.openNotebook();
// await app.workbench.notebook.insertNotebookCell('code');
// await app.workbench.notebook.waitForActiveCellEditorContents('');
// await app.workbench.notebook.stopEditingCell();
// await app.workbench.notebook.deleteActiveCell();
// await app.workbench.notebook.waitForMarkdownContents('p', 'Markdown Cell');
// });
it.skip('inserts/edits code cell', async function () {
const app = this.app as Application;
await app.workbench.notebook.openNotebook();
await app.workbench.notebook.focusNextCell();
await app.workbench.notebook.insertNotebookCell('code');
await app.workbench.notebook.waitForTypeInEditor('// some code');
await app.workbench.notebook.stopEditingCell();
});
it.skip('inserts/edits markdown cell', async function () {
const app = this.app as Application;
await app.workbench.notebook.openNotebook();
await app.workbench.notebook.focusNextCell();
await app.workbench.notebook.insertNotebookCell('markdown');
await app.workbench.notebook.waitForTypeInEditor('## hello2! ');
await app.workbench.notebook.stopEditingCell();
await app.workbench.notebook.waitForMarkdownContents('h2', 'hello2!');
});
it.skip('moves focus as it inserts/deletes a cell', async function () {
const app = this.app as Application;
await app.workbench.notebook.openNotebook();
await app.workbench.notebook.insertNotebookCell('code');
await app.workbench.notebook.waitForActiveCellEditorContents('');
await app.workbench.notebook.stopEditingCell();
await app.workbench.notebook.deleteActiveCell();
await app.workbench.notebook.waitForMarkdownContents('p', 'Markdown Cell');
});
it.skip('moves focus in and out of output', async function () { // TODO@rebornix https://github.com/microsoft/vscode/issues/113882
const app = this.app as Application;

View File

@@ -3,10 +3,15 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import minimist = require('minimist');
import { Application, ActivityBarPosition } from '../../../../automation';
import { afterSuite, beforeSuite } from '../../utils';
export function setup() {
export function setup(opts: minimist.ParsedArgs) {
describe('Preferences', () => {
beforeSuite(opts);
afterSuite(opts);
it('turns off editor line numbers and verifies the live change', async function () {
const app = this.app as Application;
@@ -27,13 +32,5 @@ export function setup() {
await app.code.dispatchKeybinding('ctrl+u');
await app.workbench.activitybar.waitForActivityBar(ActivityBarPosition.RIGHT);
});
after(async function () {
const app = this.app as Application;
await app.workbench.settingsEditor.clearUserSettings();
// Wait for settings to be applied, which will happen after the settings file is empty
await app.workbench.activitybar.waitForActivityBar(ActivityBarPosition.LEFT);
});
});
}

View File

@@ -4,17 +4,23 @@
*--------------------------------------------------------------------------------------------*/
import * as cp from 'child_process';
import minimist = require('minimist');
import { Application } from '../../../../automation';
import { afterSuite, beforeSuite } from '../../utils';
export function setup() {
export function setup(opts: minimist.ParsedArgs) {
// https://github.com/microsoft/vscode/issues/115244
describe('Search', () => {
beforeSuite(opts);
after(function () {
const app = this.app as Application;
cp.execSync('git checkout . --quiet', { cwd: app.workspacePathOrFolder });
cp.execSync('git reset --hard HEAD --quiet', { cwd: app.workspacePathOrFolder });
});
afterSuite(opts);
// https://github.com/microsoft/vscode/issues/124146
it.skip /* https://github.com/microsoft/vscode/issues/124335 */('has a tooltp with a keybinding', async function () {
const app = this.app as Application;
@@ -68,6 +74,9 @@ export function setup() {
});
describe('Quick Access', () => {
beforeSuite(opts);
afterSuite(opts);
it('quick access search produces correct result', async function () {
const app = this.app as Application;
const expectedNames = [

View File

@@ -3,10 +3,15 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import minimist = require('minimist');
import { Application, Quality, StatusBarElement } from '../../../../automation';
import { afterSuite, beforeSuite } from '../../utils';
export function setup(isWeb) {
export function setup(opts: minimist.ParsedArgs) {
describe('Statusbar', () => {
beforeSuite(opts);
afterSuite(opts);
it('verifies presence of all default status bar elements', async function () {
const app = this.app as Application;
@@ -18,7 +23,7 @@ export function setup(isWeb) {
await app.workbench.statusbar.waitForStatusbarElement(StatusBarElement.PROBLEMS_STATUS);
await app.workbench.quickaccess.openFile('app.js');
if (!isWeb) {
if (!opts.web) {
// Encoding picker currently hidden in web (only UTF-8 supported)
await app.workbench.statusbar.waitForStatusbarElement(StatusBarElement.ENCODING_STATUS);
}
@@ -39,7 +44,7 @@ export function setup(isWeb) {
await app.workbench.statusbar.clickOn(StatusBarElement.INDENTATION_STATUS);
await app.workbench.quickinput.waitForQuickInputOpened();
await app.workbench.quickinput.closeQuickInput();
if (!isWeb) {
if (!opts.web) {
// Encoding picker currently hidden in web (only UTF-8 supported)
await app.workbench.statusbar.clickOn(StatusBarElement.ENCODING_STATUS);
await app.workbench.quickinput.waitForQuickInputOpened();
@@ -60,17 +65,6 @@ export function setup(isWeb) {
await app.workbench.problems.waitForProblemsView();
});
it(`verifies that 'Tweet us feedback' pop-up appears when clicking on 'Feedback' icon`, async function () {
const app = this.app as Application;
if (app.quality === Quality.Dev) {
return this.skip();
}
await app.workbench.statusbar.clickOn(StatusBarElement.FEEDBACK_ICON);
await app.code.waitForElement('.feedback-form');
});
it(`checks if 'Go to Line' works if called from the status bar`, async function () {
const app = this.app as Application;
@@ -94,5 +88,16 @@ export function setup(isWeb) {
await app.workbench.statusbar.waitForEOL('CRLF');
});
it(`verifies that 'Tweet us feedback' pop-up appears when clicking on 'Feedback' icon`, async function () {
const app = this.app as Application;
if (app.quality === Quality.Dev) {
return this.skip();
}
await app.workbench.statusbar.clickOn(StatusBarElement.FEEDBACK_ICON);
await app.code.waitForElement('.feedback-form');
});
});
}

View File

@@ -3,10 +3,16 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import minimist = require('minimist');
import { Application } from '../../../../automation';
import { afterSuite, beforeSuite } from '../../utils';
export function setup(opts: minimist.ParsedArgs) {
export function setup() {
describe('Dataloss', () => {
beforeSuite(opts);
afterSuite(opts);
it(`verifies that 'hot exit' works for dirty files`, async function () {
const app = this.app as Application;
await app.workbench.editors.newUntitledFile();

View File

@@ -5,15 +5,25 @@
import { Application, ApplicationOptions, Quality } from '../../../../automation';
import { join } from 'path';
import { ParsedArgs } from 'minimist';
import { timeout } from '../../utils';
export function setup(stableCodePath: string, testDataPath: string) {
export function setup(opts: ParsedArgs, testDataPath: string) {
describe('Datamigration', () => {
it(`verifies opened editors are restored`, async function () {
const stableCodePath = opts['stable-build'];
if (!stableCodePath) {
this.skip();
}
// On macOS, the stable app fails to launch on first try,
// so let's retry this once
// https://github.com/microsoft/vscode/pull/127799
if (process.platform === 'darwin') {
this.retries(2);
}
const userDataDir = join(testDataPath, 'd2'); // different data dir from the other tests
const stableOptions: ApplicationOptions = Object.assign({}, this.defaultOptions);
@@ -22,7 +32,7 @@ export function setup(stableCodePath: string, testDataPath: string) {
stableOptions.quality = Quality.Stable;
const stableApp = new Application(stableOptions);
await stableApp!.start();
await stableApp.start();
// Open 3 editors and pin 2 of them
await stableApp.workbench.quickaccess.openFile('www');
@@ -39,10 +49,10 @@ export function setup(stableCodePath: string, testDataPath: string) {
insiderOptions.userDataDir = userDataDir;
const insidersApp = new Application(insiderOptions);
await insidersApp!.start(false /* not expecting walkthrough path */);
await insidersApp.start();
// Verify 3 editors are open
await insidersApp.workbench.editors.waitForEditorFocus('Untitled-1');
await insidersApp.workbench.editors.selectTab('Untitled-1');
await insidersApp.workbench.editors.selectTab('app.js');
await insidersApp.workbench.editors.selectTab('www');
@@ -50,6 +60,7 @@ export function setup(stableCodePath: string, testDataPath: string) {
});
it(`verifies that 'hot exit' works for dirty files`, async function () {
const stableCodePath = opts['stable-build'];
if (!stableCodePath) {
this.skip();
}
@@ -62,7 +73,7 @@ export function setup(stableCodePath: string, testDataPath: string) {
stableOptions.quality = Quality.Stable;
const stableApp = new Application(stableOptions);
await stableApp!.start();
await stableApp.start();
await stableApp.workbench.editors.newUntitledFile();
@@ -75,15 +86,18 @@ export function setup(stableCodePath: string, testDataPath: string) {
await stableApp.workbench.quickaccess.openFile(readmeMd);
await stableApp.workbench.editor.waitForTypeInEditor(readmeMd, textToType);
await timeout(2000); // give time to store the backup before stopping the app
await stableApp.stop();
const insiderOptions: ApplicationOptions = Object.assign({}, this.defaultOptions);
insiderOptions.userDataDir = userDataDir;
const insidersApp = new Application(insiderOptions);
await insidersApp!.start(false /* not expecting walkthrough path */);
await insidersApp.start();
await insidersApp.workbench.editors.waitForActiveTab(readmeMd, true);
await insidersApp.workbench.editors.waitForTab(readmeMd, true);
await insidersApp.workbench.editors.selectTab(readmeMd);
await insidersApp.workbench.editor.waitForEditorContents(readmeMd, c => c.indexOf(textToType) > -1);
await insidersApp.workbench.editors.waitForTab(untitled, true);

View File

@@ -3,46 +3,40 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import minimist = require('minimist');
import { Application, Quality } from '../../../../automation';
import { afterSuite, beforeSuite } from '../../utils';
export function setup() {
export function setup(opts: minimist.ParsedArgs) {
describe('Localization', () => {
before(async function () {
const app = this.app as Application;
// Don't run the localization tests in dev or remote.
if (app.quality === Quality.Dev || app.remote) {
return;
}
await app.workbench.extensions.openExtensionsViewlet();
await app.workbench.extensions.installExtension('ms-ceintl.vscode-language-pack-de', false);
await app.restart({ extraArgs: ['--locale=DE'] });
});
beforeSuite(opts);
afterSuite(opts);
it(`starts with 'DE' locale and verifies title and viewlets text is in German`, async function () {
const app = this.app as Application;
if (app.quality === Quality.Dev || app.remote) {
this.skip();
return;
return this.skip();
}
// await app.workbench.explorer.waitForOpenEditorsViewTitle(title => /geöffnete editoren/i.test(title));
await app.workbench.extensions.openExtensionsViewlet();
await app.workbench.extensions.installExtension('ms-ceintl.vscode-language-pack-de', false);
await app.restart({ extraArgs: ['--locale=DE'] });
await app.workbench.search.openSearchViewlet();
await app.workbench.search.waitForTitle(title => /suchen/i.test(title));
const result = await app.workbench.localization.getLocalizedStrings();
const localeInfo = await app.workbench.localization.getLocaleInfo();
// await app.workbench.scm.openSCMViewlet();
// await app.workbench.scm.waitForTitle(title => /quellcodeverwaltung/i.test(title));
if (localeInfo.locale === undefined || localeInfo.locale.toLowerCase() !== 'de') {
throw new Error(`The requested locale for VS Code was not German. The received value is: ${localeInfo.locale === undefined ? 'not set' : localeInfo.locale}`);
}
// See https://github.com/microsoft/vscode/issues/93462
// await app.workbench.debug.openDebugViewlet();
// await app.workbench.debug.waitForTitle(title => /starten/i.test(title));
if (localeInfo.language.toLowerCase() !== 'de') {
throw new Error(`The UI language is not German. It is ${localeInfo.language}`);
}
// await app.workbench.extensions.openExtensionsViewlet();
// await app.workbench.extensions.waitForTitle(title => /extensions/i.test(title));
if (result.open.toLowerCase() !== 'öffnen' || result.close.toLowerCase() !== 'schließen' || result.find.toLowerCase() !== 'finden') {
throw new Error(`Received wrong German localized strings: ${JSON.stringify(result, undefined, 0)}`);
}
});
});
}

View File

@@ -6,20 +6,14 @@
import * as fs from 'fs';
import * as cp from 'child_process';
import * as path from 'path';
import * as os from 'os';
import * as minimist from 'minimist';
import * as tmp from 'tmp';
import * as rimraf from 'rimraf';
import * as mkdirp from 'mkdirp';
import { ncp } from 'ncp';
import {
Application,
Quality,
ApplicationOptions,
MultiLogger,
Logger,
ConsoleLogger,
FileLogger,
} from '../../automation';
import * as vscodetest from 'vscode-test';
import fetch from 'node-fetch';
import { Quality, ApplicationOptions, MultiLogger, Logger, ConsoleLogger, FileLogger, Application } from '../../automation';
import { main as sqlMain, setup as sqlSetup } from './sql/main'; // {{SQL CARBON EDIT}}
/*import { setup as setupDataMigrationTests } from './areas/workbench/data-migration.test';
@@ -35,9 +29,18 @@ import { setup as setupDataMultirootTests } from './areas/multiroot/multiroot.te
import { setup as setupDataLocalizationTests } from './areas/workbench/localization.test';
import { setup as setupLaunchTests } from './areas/workbench/launch.test';*/
const tmpDir = tmp.dirSync({ prefix: 't' }) as { name: string; removeCallback: Function; };
const testDataPath = tmpDir.name;
process.once('exit', () => rimraf.sync(testDataPath));
const testDataPath = path.join(os.tmpdir(), 'vscsmoke');
if (fs.existsSync(testDataPath)) {
rimraf.sync(testDataPath);
}
fs.mkdirSync(testDataPath);
process.once('exit', () => {
try {
rimraf.sync(testDataPath);
} catch {
// noop
}
});
const [, , ...args] = process.argv;
const opts = minimist(args, {
@@ -49,12 +52,14 @@ const opts = minimist(args, {
'test-repo',
'screenshots',
'log',
'extensionsDir' // {{SQL CARBON EDIT}} Let callers control extensions dir for non-packaged extensions
'extensionsDir', // {{SQL CARBON EDIT}} Let callers control extensions dir for non-packaged extensions
'electronArgs'
],
boolean: [
'verbose',
'remote',
'web'
'web',
'headless'
],
default: {
verbose: false
@@ -77,7 +82,6 @@ if (screenshotsPath) {
mkdirp.sync(screenshotsPath);
}
// {{SQL CARBON EDIT}} Add logs to smoke tests
const logPath = opts.log ? path.resolve(opts.log) : null;
if (logPath) {
mkdirp.sync(path.dirname(logPath));
@@ -91,6 +95,12 @@ function fail(errorMessage): void {
const repoPath = path.join(__dirname, '..', '..', '..');
let quality: Quality;
let version: string | undefined;
function parseVersion(version: string): { major: number, minor: number, patch: number } {
const [, major, minor, patch] = /^(\d+)\.(\d+)\.(\d+)/.exec(version)!;
return { major: parseInt(major), minor: parseInt(minor), patch: parseInt(patch) };
}
//
// #### Electron Smoke Tests ####
@@ -130,17 +140,21 @@ if (!opts.web) {
}
}
function getBuildVersion(root: string): string {
switch (process.platform) {
case 'darwin':
return require(path.join(root, 'Contents', 'Resources', 'app', 'package.json')).version;
default:
return require(path.join(root, 'resources', 'app', 'package.json')).version;
}
}
let testCodePath = opts.build;
let stableCodePath = opts['stable-build'];
let electronPath: string;
let stablePath: string | undefined = undefined;
if (testCodePath) {
electronPath = getBuildElectronPath(testCodePath);
if (stableCodePath) {
stablePath = getBuildElectronPath(stableCodePath);
}
version = getBuildVersion(testCodePath);
} else {
testCodePath = getDevElectronPath();
electronPath = testCodePath;
@@ -153,10 +167,6 @@ if (!opts.web) {
fail(`Can't find VSCode at ${electronPath}.`);
}
if (typeof stablePath === 'string' && !fs.existsSync(stablePath)) {
fail(`Can't find Stable VSCode at ${stablePath}.`);
}
if (process.env.VSCODE_DEV === '1') {
quality = Quality.Dev;
} else if (electronPath.indexOf('Code - Insiders') >= 0 /* macOS/Windows */ || electronPath.indexOf('code-insiders') /* Linux */ >= 0) {
@@ -221,16 +231,66 @@ async function setupRepository(): Promise<void> {
cp.spawnSync('git', ['clean', '-xdf'], { cwd: workspacePath });
}
// None of the test run the project
// None of the current smoke tests have a dependency on the packages.
// If new smoke tests are added that need the packages, uncomment this.
// console.log('*** Running yarn...');
// cp.execSync('yarn', { cwd: workspacePath, stdio: 'inherit' });
}
}
async function ensureStableCode(): Promise<void> {
if (opts.web || !opts['build']) {
return;
}
let stableCodePath = opts['stable-build'];
if (!stableCodePath) {
const { major, minor } = parseVersion(version!);
const majorMinorVersion = `${major}.${minor - 1}`;
const versionsReq = await fetch('https://update.code.visualstudio.com/api/releases/stable', { headers: { 'x-api-version': '2' } });
if (!versionsReq.ok) {
throw new Error('Could not fetch releases from update server');
}
const versions: { version: string }[] = await versionsReq.json();
const prefix = `${majorMinorVersion}.`;
const previousVersion = versions.find(v => v.version.startsWith(prefix));
if (!previousVersion) {
throw new Error(`Could not find suitable stable version ${majorMinorVersion}`);
}
console.log(`*** Found VS Code v${version}, downloading previous VS Code version ${previousVersion.version}...`);
const stableCodeExecutable = await vscodetest.download({
cachePath: path.join(os.tmpdir(), 'vscode-test'),
version: previousVersion.version
});
if (process.platform === 'darwin') {
// Visual Studio Code.app/Contents/MacOS/Electron
stableCodePath = path.dirname(path.dirname(path.dirname(stableCodeExecutable)));
} else {
// VSCode/Code.exe (Windows) | VSCode/code (Linux)
stableCodePath = path.dirname(stableCodeExecutable);
}
}
if (!fs.existsSync(stableCodePath)) {
throw new Error(`Can't find Stable VSCode at ${stableCodePath}.`);
}
console.log(`*** Using stable build ${stableCodePath} for migration tests`);
opts['stable-build'] = stableCodePath;
}
async function setup(): Promise<void> {
console.log('*** Test data:', testDataPath);
console.log('*** Preparing smoketest setup...');
await ensureStableCode();
await setupRepository();
console.log('*** Smoketest setup done!\n');
@@ -249,6 +309,7 @@ function createOptions(): ApplicationOptions {
loggers.push(new FileLogger(opts.log));
log = 'trace';
}
return {
quality,
codePath: opts.build,
@@ -262,7 +323,9 @@ function createOptions(): ApplicationOptions {
screenshotsPath,
remote: opts.remote,
web: opts.web,
browser: opts.browser
headless: opts.headless,
browser: opts.browser,
extraArgs: (opts.electronArgs || '').split(' ').map(a => a.trim()).filter(a => !!a)
};
}
@@ -270,7 +333,7 @@ before(async function () {
this.timeout(2 * 60 * 1000); // allow two minutes for setup
await setup();
this.defaultOptions = createOptions();
await sqlSetup(this.defaultOptions); // {{SQL CARBON EDIT}}
await sqlSetup(this.defaultOptions);
});
after(async function () {
@@ -297,59 +360,38 @@ after(async function () {
await new Promise((c, e) => rimraf(testDataPath, { maxBusyTries: 10 }, err => err ? e(err) : c(undefined)));
});
sqlMain(opts.web);
if (screenshotsPath) {
afterEach(async function () {
if (this.currentTest!.state !== 'failed') {
return;
}
const app = this.app as Application;
const name = this.currentTest!.fullTitle().replace(/[^a-z0-9\-]/ig, '_');
await app.captureScreenshot(name);
});
}
if (!opts.web && opts['build'] && !opts['remote']) {
describe(`Stable vs Insiders Smoke Tests: This test MUST run before releasing`, () => {
// setupDataMigrationTests(opts, testDataPath); {{SQL CARBON EDIT}} Remove unused tests
});
}
describe(`VSCode Smoke Tests (${opts.web ? 'Web' : 'Electron'})`, () => {
if (screenshotsPath) {
afterEach(async function () {
if (this.currentTest!.state !== 'failed') {
return;
}
const app = this.app as Application;
const name = this.currentTest!.fullTitle().replace(/[^a-z0-9\-]/ig, '_');
await app.captureScreenshot(name);
});
}
if (opts.log) {
beforeEach(async function () {
const app = this.app as Application;
const title = this.currentTest!.fullTitle();
app.logger.log('*** Test start:', title);
});
}
// if (!opts.web && opts['stable-build']) {
// describe(`Stable vs Insiders Smoke Tests: This test MUST run before releasing by providing the --stable-build command line argument`, () => {
// setupDataMigrationTests(opts['stable-build'], testDataPath);
// });
// }
// {{SQL CARBON EDIT}} - Remove the nested test suite to make sure the suite setup is also applied to beforeEach and afterEach
// describe(`VSCode Smoke Tests (${opts.web ? 'Web' : 'Electron'})`, () => {
before(async function () {
const app = new Application(this.defaultOptions);
await app!.start(opts.web ? false : undefined);
this.app = app;
});
after(async function () {
await this.app.stop();
});
sqlMain(opts.web);
/* if (!opts.web) { setupDataLossTests(); }
if (!opts.web) { setupDataPreferencesTests(); }
setupDataSearchTests();
setupDataNotebookTests();
setupDataLanguagesTests();
setupDataEditorTests();
setupDataStatusbarTests(!!opts.web);
setupDataExtensionTests();
if (!opts.web) { setupDataMultirootTests(); }
if (!opts.web) { setupDataLocalizationTests(); }
if (!opts.web) { setupLaunchTests(); }*/
// });
/* {{SQL CARBON EDIT}} Disable unused tests
if (!opts.web) { setupDataLossTests(opts); }
if (!opts.web) { setupDataPreferencesTests(opts); }
setupDataSearchTests(opts);
setupDataNotebookTests(opts);
setupDataLanguagesTests(opts);
setupDataEditorTests(opts);
setupDataStatusbarTests(opts);
setupDataExtensionTests(opts);
if (!opts.web) { setupDataMultirootTests(opts); }
if (!opts.web) { setupDataLocalizationTests(opts); }
if (!opts.web) { setupLaunchTests(); }
*/
});

View File

@@ -3,7 +3,9 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import minimist = require('minimist');
import { Suite, Context } from 'mocha';
import { Application, ApplicationOptions } from '../../automation';
export function describeRepeat(n: number, description: string, callback: (this: Suite) => void): void {
for (let i = 0; i < n; i++) {
@@ -16,3 +18,49 @@ export function itRepeat(n: number, description: string, callback: (this: Contex
it(`${description} (iteration ${i})`, callback);
}
}
export function beforeSuite(opts: minimist.ParsedArgs, optionsTransform?: (opts: ApplicationOptions) => Promise<ApplicationOptions>) {
before(async function () {
let options: ApplicationOptions = { ...this.defaultOptions };
if (optionsTransform) {
options = await optionsTransform(options);
}
// https://github.com/microsoft/vscode/issues/34988
const userDataPathSuffix = [...Array(8)].map(() => Math.random().toString(36)[3]).join('');
const userDataDir = options.userDataDir.concat(`-${userDataPathSuffix}`);
const app = new Application({ ...options, userDataDir });
await app.start();
this.app = app;
if (opts.log) {
const title = this.currentTest!.fullTitle();
app.logger.log('*** Test start:', title);
}
});
}
export function afterSuite(opts: minimist.ParsedArgs) {
after(async function () {
const app = this.app as Application;
if (this.currentTest?.state === 'failed' && opts.screenshots) {
const name = this.currentTest!.fullTitle().replace(/[^a-z0-9\-]/ig, '_');
await app.captureScreenshot(name);
}
if (app) {
await app.stop();
}
});
}
export function timeout(i: number) {
return new Promise<void>(resolve => {
setTimeout(() => {
resolve();
}, i);
});
}