Merge VS Code 1.23.1 (#1520)

This commit is contained in:
Matt Irvine
2018-06-05 11:24:51 -07:00
committed by GitHub
parent e3baf5c443
commit 0c58f09e59
3651 changed files with 74249 additions and 48599 deletions

View File

@@ -11,9 +11,9 @@ import * as minimist from 'minimist';
import * as tmp from 'tmp';
import * as rimraf from 'rimraf';
import * as mkdirp from 'mkdirp';
import { SpectronApplication, Quality } from './spectron/application';
import { setup as setupDataMigrationTests } from './areas/workbench/data-migration.test';
import { Application, Quality } from './application';
import { setup as setupDataMigrationTests } from './areas/workbench/data-migration.test';
import { setup as setupDataLossTests } from './areas/workbench/data-loss.test';
import { setup as setupDataExplorerTests } from './areas/explorer/explorer.test';
import { setup as setupDataPreferencesTests } from './areas/preferences/preferences.test';
@@ -24,9 +24,10 @@ import { setup as setupDataDebugTests } from './areas/debug/debug.test';
import { setup as setupDataGitTests } from './areas/git/git.test';
import { setup as setupDataStatusbarTests } from './areas/statusbar/statusbar.test';
import { setup as setupDataExtensionTests } from './areas/extensions/extensions.test';
import { setup as setupTerminalTests } from './areas/terminal/terminal.test';
import { setup as setupDataMultirootTests } from './areas/multiroot/multiroot.test';
import { setup as setupDataLocalizationTests } from './areas/workbench/localization.test';
// import './areas/terminal/terminal.test';
import { MultiLogger, Logger, ConsoleLogger, FileLogger } from './logger';
const tmpDir = tmp.dirSync({ prefix: 't' }) as { name: string; removeCallback: Function; };
const testDataPath = tmpDir.name;
@@ -37,13 +38,20 @@ const opts = minimist(args, {
string: [
'build',
'stable-build',
'log',
'wait-time'
]
'wait-time',
'test-repo',
'keybindings',
'screenshots',
'log'
],
boolean: [
'verbose'
],
default: {
verbose: false
}
});
const artifactsPath = opts.log || '';
const workspaceFilePath = path.join(testDataPath, 'smoketest.code-workspace');
const testRepoUrl = 'https://github.com/Microsoft/vscode-smoketest-express';
const workspacePath = path.join(testDataPath, 'vscode-smoketest-express');
@@ -51,6 +59,12 @@ const keybindingsPath = path.join(testDataPath, 'keybindings.json');
const extensionsPath = path.join(testDataPath, 'extensions-dir');
mkdirp.sync(extensionsPath);
const screenshotsPath = opts.screenshots ? path.resolve(opts.screenshots) : null;
if (screenshotsPath) {
mkdirp.sync(screenshotsPath);
}
function fail(errorMessage): void {
console.error(errorMessage);
process.exit(1);
@@ -96,16 +110,16 @@ function getBuildElectronPath(root: string): string {
}
let testCodePath = opts.build;
let stableCodePath = opts['stable-build'];
// let stableCodePath = opts['stable-build'];
let electronPath: string;
let stablePath: string;
// let stablePath: string;
if (testCodePath) {
electronPath = getBuildElectronPath(testCodePath);
if (stableCodePath) {
stablePath = getBuildElectronPath(stableCodePath);
}
// if (stableCodePath) {
// stablePath = getBuildElectronPath(stableCodePath);
// }
} else {
testCodePath = getDevElectronPath();
electronPath = testCodePath;
@@ -147,96 +161,106 @@ function toUri(path: string): string {
return `${path}`;
}
async function getKeybindings(): Promise<void> {
if (opts.keybindings) {
console.log('*** Using keybindings: ', opts.keybindings);
const rawKeybindings = fs.readFileSync(opts.keybindings);
fs.writeFileSync(keybindingsPath, rawKeybindings);
} else {
const keybindingsUrl = `https://raw.githubusercontent.com/Microsoft/vscode-docs/master/build/keybindings/doc.keybindings.${getKeybindingPlatform()}.json`;
console.log('*** Fetching keybindings...');
await new Promise((c, e) => {
https.get(keybindingsUrl, res => {
const output = fs.createWriteStream(keybindingsPath);
res.on('error', e);
output.on('error', e);
output.on('close', c);
res.pipe(output);
}).on('error', e);
});
}
}
async function createWorkspaceFile(): Promise<void> {
if (fs.existsSync(workspaceFilePath)) {
return;
}
console.log('*** Creating workspace file...');
const workspace = {
folders: [
{
path: toUri(path.join(workspacePath, 'public'))
},
{
path: toUri(path.join(workspacePath, 'routes'))
},
{
path: toUri(path.join(workspacePath, 'views'))
}
]
};
fs.writeFileSync(workspaceFilePath, JSON.stringify(workspace, null, '\t'));
}
async function setupRepository(): Promise<void> {
if (opts['test-repo']) {
console.log('*** Copying test project repository:', opts['test-repo']);
rimraf.sync(workspacePath);
// not platform friendly
cp.execSync(`cp -R "${opts['test-repo']}" "${workspacePath}"`);
} else {
if (!fs.existsSync(workspacePath)) {
console.log('*** Cloning test project repository...');
cp.spawnSync('git', ['clone', testRepoUrl, workspacePath]);
} else {
console.log('*** Cleaning test project repository...');
cp.spawnSync('git', ['fetch'], { cwd: workspacePath });
cp.spawnSync('git', ['reset', '--hard', 'FETCH_HEAD'], { cwd: workspacePath });
cp.spawnSync('git', ['clean', '-xdf'], { cwd: workspacePath });
}
console.log('*** Running npm install...');
cp.execSync('npm install', { cwd: workspacePath, stdio: 'inherit' });
}
}
async function setup(): Promise<void> {
console.log('*** Test data:', testDataPath);
console.log('*** Preparing smoketest setup...');
const keybindingsUrl = `https://raw.githubusercontent.com/Microsoft/vscode-docs/master/build/keybindings/doc.keybindings.${getKeybindingPlatform()}.json`;
console.log('*** Fetching keybindings...');
await new Promise((c, e) => {
https.get(keybindingsUrl, res => {
const output = fs.createWriteStream(keybindingsPath);
res.on('error', e);
output.on('error', e);
output.on('close', c);
res.pipe(output);
}).on('error', e);
});
if (!fs.existsSync(workspaceFilePath)) {
console.log('*** Creating workspace file...');
const workspace = {
folders: [
{
path: toUri(path.join(workspacePath, 'public'))
},
{
path: toUri(path.join(workspacePath, 'routes'))
},
{
path: toUri(path.join(workspacePath, 'views'))
}
]
};
fs.writeFileSync(workspaceFilePath, JSON.stringify(workspace, null, '\t'));
}
if (!fs.existsSync(workspacePath)) {
console.log('*** Cloning test project repository...');
cp.spawnSync('git', ['clone', testRepoUrl, workspacePath]);
} else {
console.log('*** Cleaning test project repository...');
cp.spawnSync('git', ['fetch'], { cwd: workspacePath });
cp.spawnSync('git', ['reset', '--hard', 'FETCH_HEAD'], { cwd: workspacePath });
cp.spawnSync('git', ['clean', '-xdf'], { cwd: workspacePath });
}
console.log('*** Running npm install...');
cp.execSync('npm install', { cwd: workspacePath, stdio: 'inherit' });
await getKeybindings();
await createWorkspaceFile();
await setupRepository();
console.log('*** Smoketest setup done!\n');
}
/**
* WebDriverIO 4.8.0 outputs all kinds of "deprecation" warnings
* for common commands like `keys` and `moveToObject`.
* According to https://github.com/Codeception/CodeceptJS/issues/531,
* these deprecation warnings are for Firefox, and have no alternative replacements.
* Since we can't downgrade WDIO as suggested (it's Spectron's dep, not ours),
* we must suppress the warning with a classic monkey-patch.
*
* @see webdriverio/lib/helpers/depcrecationWarning.js
* @see https://github.com/webdriverio/webdriverio/issues/2076
*/
// Filter out the following messages:
const wdioDeprecationWarning = /^WARNING: the "\w+" command will be deprecated soon../; // [sic]
// Monkey patch:
const warn = console.warn;
console.warn = function suppressWebdriverWarnings(message) {
if (wdioDeprecationWarning.test(message)) { return; }
warn.apply(console, arguments);
};
function createApp(quality: Quality): Application {
const loggers: Logger[] = [];
function createApp(quality: Quality): SpectronApplication | null {
const path = quality === Quality.Stable ? stablePath : electronPath;
if (!path) {
return null;
if (opts.verbose) {
loggers.push(new ConsoleLogger());
}
return new SpectronApplication({
if (opts.log) {
loggers.push(new FileLogger(opts.log));
}
return new Application({
quality,
electronPath: path,
codePath: opts.build,
workspacePath,
userDataDir,
extensionsPath,
artifactsPath,
workspaceFilePath,
waitTime: parseInt(opts['wait-time'] || '0') || 20
waitTime: parseInt(opts['wait-time'] || '0') || 20,
logger: new MultiLogger(loggers)
});
}
before(async function () {
// allow two minutes for setup
this.timeout(2 * 60 * 1000);
@@ -244,6 +268,7 @@ before(async function () {
});
after(async function () {
await new Promise(c => setTimeout(c, 500)); // wait for shutdown
await new Promise((c, e) => rimraf(testDataPath, { maxBusyTries: 10 }, err => err ? e(err) : c()));
});
@@ -251,7 +276,7 @@ describe('Data Migration', () => {
setupDataMigrationTests(userDataDir, createApp);
});
describe('Everything Else', () => {
describe('Test', () => {
before(async function () {
const app = createApp(quality);
await app!.start();
@@ -262,6 +287,36 @@ describe('Everything Else', () => {
await this.app.stop();
});
if (screenshotsPath) {
afterEach(async function () {
if (this.currentTest.state !== 'failed') {
return;
}
const app = this.app as Application;
const raw = await app.capturePage();
const buffer = new Buffer(raw, 'base64');
const name = this.currentTest.fullTitle().replace(/[^a-z0-9\-]/ig, '_');
const screenshotPath = path.join(screenshotsPath, `${name}.png`);
if (opts.log) {
app.logger.log('*** Screenshot recorded:', screenshotPath);
}
fs.writeFileSync(screenshotPath, buffer);
});
}
if (opts.log) {
beforeEach(async function () {
const app = this.app as Application;
const title = this.currentTest.fullTitle();
app.logger.log('*** Test start:', title);
});
}
setupDataLossTests();
setupDataExplorerTests();
setupDataPreferencesTests();
@@ -272,6 +327,7 @@ describe('Everything Else', () => {
setupDataGitTests();
setupDataStatusbarTests();
setupDataExtensionTests();
setupTerminalTests();
setupDataMultirootTests();
setupDataLocalizationTests();
});