Bring back non-web smoke tests

This commit is contained in:
Daniel Imms 2019-07-19 17:12:11 -07:00
parent 488fa6d4cf
commit 8d20c171fc
5 changed files with 105 additions and 79 deletions

View file

@ -6,8 +6,8 @@
"postinstall": "npm run compile",
"compile": "npm run copy-driver && npm run copy-driver-definition && tsc",
"watch": "concurrently \"npm run watch-driver\" \"npm run watch-driver-definition\" \"tsc --watch\"",
"copy-driver": "cpx src/vscode/puppeteer-driver.js out/vscode",
"watch-driver": "cpx src/vscode/puppeteer-driver.js out/vscode -w",
"copy-driver": "cpx src/vscode/driver.js out/vscode",
"watch-driver": "cpx src/vscode/driver.js out/vscode -w",
"copy-driver-definition": "node tools/copy-driver-definition.js",
"watch-driver-definition": "watch \"node tools/copy-driver-definition.js\" ../../src/vs/platform/driver/node",
"mocha": "mocha"

View file

@ -6,7 +6,7 @@
import { Application } from '../../application';
export function setup() {
describe.only('Terminal', () => {
describe('Terminal', () => {
it(`opens terminal, runs 'echo' and verifies the output`, async function () {
this.timeout(60 * 5000);
const app = this.app as Application;

View file

@ -14,19 +14,19 @@ import { ncp } from 'ncp';
import { Application, Quality, ApplicationOptions } 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';
// import { setup as setupDataSearchTests } from './areas/search/search.test';
// import { setup as setupDataCSSTests } from './areas/css/css.test';
// import { setup as setupDataEditorTests } from './areas/editor/editor.test';
// 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 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';
import { setup as setupDataSearchTests } from './areas/search/search.test';
import { setup as setupDataCSSTests } from './areas/css/css.test';
import { setup as setupDataEditorTests } from './areas/editor/editor.test';
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 { setup as setupDataMultirootTests } from './areas/multiroot/multiroot.test';
import { setup as setupDataLocalizationTests } from './areas/workbench/localization.test';
import { setup as setupLaunchTests } from './areas/workbench/launch.test';
import { MultiLogger, Logger, ConsoleLogger, FileLogger } from './logger';
@ -51,7 +51,8 @@ const opts = minimist(args, {
],
boolean: [
'verbose',
'remote'
'remote',
'web'
],
default: {
verbose: false
@ -132,13 +133,13 @@ if (testCodePath) {
process.env.VSCODE_CLI = '1';
}
// if (!fs.existsSync(electronPath || '')) {
// fail(`Can't find Code at ${electronPath}.`);
// }
console.log(stablePath);
// if (typeof stablePath === 'string' && !fs.existsSync(stablePath)) {
// fail(`Can't find Stable Code at ${stablePath}.`);
// }
if (!fs.existsSync(electronPath || '')) {
fail(`Can't find Code at ${electronPath}.`);
}
if (typeof stablePath === 'string' && !fs.existsSync(stablePath)) {
fail(`Can't find Stable Code at ${stablePath}.`);
}
const userDataDir = path.join(testDataPath, 'd');
@ -239,7 +240,7 @@ setupDataMigrationTests(stableCodePath, testDataPath);
describe('Running Code', () => {
before(async function () {
const app = new Application(this.defaultOptions);
await app!.start(false);
await app!.start(opts.web ? false : undefined);
this.app = app;
});
@ -268,19 +269,24 @@ describe('Running Code', () => {
});
}
// setupDataLossTests();
// setupDataExplorerTests();
// setupDataPreferencesTests();
// setupDataSearchTests();
// setupDataCSSTests();
// setupDataEditorTests();
// setupDataDebugTests();
// setupDataGitTests();
// setupDataStatusbarTests();
// setupDataExtensionTests();
if (opts.web) {
setupTerminalTests();
return;
}
setupDataLossTests();
setupDataExplorerTests();
setupDataPreferencesTests();
setupDataSearchTests();
setupDataCSSTests();
setupDataEditorTests();
setupDataDebugTests();
setupDataGitTests();
setupDataStatusbarTests();
setupDataExtensionTests();
setupTerminalTests();
// setupDataMultirootTests();
// setupDataLocalizationTests();
setupDataMultirootTests();
setupDataLocalizationTests();
});
setupLaunchTests();

View file

@ -9,45 +9,46 @@ import * as os from 'os';
import * as fs from 'fs';
import * as mkdirp from 'mkdirp';
import { tmpName } from 'tmp';
import { IDriver, connect as connectDriver, IDisposable, IElement, Thenable } from './puppeteer-driver';
import { IDriver, connect as connectElectronDriver, IDisposable, IElement, Thenable } from './driver';
import { connect as connectPuppeteerDriver, launch } from './puppeteer-driver';
import { Logger } from '../logger';
import { ncp } from 'ncp';
import { URI } from 'vscode-uri';
const repoPath = path.join(__dirname, '../../../..');
// function getDevElectronPath(): string {
// const buildPath = path.join(repoPath, '.build');
// const product = require(path.join(repoPath, 'product.json'));
function getDevElectronPath(): string {
const buildPath = path.join(repoPath, '.build');
const product = require(path.join(repoPath, 'product.json'));
// switch (process.platform) {
// case 'darwin':
// return path.join(buildPath, 'electron', `${product.nameLong}.app`, 'Contents', 'MacOS', 'Electron');
// case 'linux':
// return path.join(buildPath, 'electron', `${product.applicationName}`);
// case 'win32':
// return path.join(buildPath, 'electron', `${product.nameShort}.exe`);
// default:
// throw new Error('Unsupported platform.');
// }
// }
switch (process.platform) {
case 'darwin':
return path.join(buildPath, 'electron', `${product.nameLong}.app`, 'Contents', 'MacOS', 'Electron');
case 'linux':
return path.join(buildPath, 'electron', `${product.applicationName}`);
case 'win32':
return path.join(buildPath, 'electron', `${product.nameShort}.exe`);
default:
throw new Error('Unsupported platform.');
}
}
// function getBuildElectronPath(root: string): string {
// switch (process.platform) {
// case 'darwin':
// return path.join(root, 'Contents', 'MacOS', 'Electron');
// case 'linux': {
// const product = require(path.join(root, 'resources', 'app', 'product.json'));
// return path.join(root, product.applicationName);
// }
// case 'win32': {
// const product = require(path.join(root, 'resources', 'app', 'product.json'));
// return path.join(root, `${product.nameShort}.exe`);
// }
// default:
// throw new Error('Unsupported platform.');
// }
// }
function getBuildElectronPath(root: string): string {
switch (process.platform) {
case 'darwin':
return path.join(root, 'Contents', 'MacOS', 'Electron');
case 'linux': {
const product = require(path.join(root, 'resources', 'app', 'product.json'));
return path.join(root, product.applicationName);
}
case 'win32': {
const product = require(path.join(root, 'resources', 'app', 'product.json'));
return path.join(root, `${product.nameShort}.exe`);
}
default:
throw new Error('Unsupported platform.');
}
}
function getDevOutPath(): string {
return path.join(repoPath, 'out');
@ -62,7 +63,7 @@ function getBuildOutPath(root: string): string {
}
}
async function connect(child: cp.ChildProcess | undefined, outPath: string, handlePath: string, logger: Logger): Promise<Code> {
async function connect(connectDriver: typeof connectElectronDriver, child: cp.ChildProcess | undefined, outPath: string, handlePath: string, logger: Logger): Promise<Code> {
let errCount = 0;
while (true) {
@ -95,7 +96,10 @@ export interface SpawnOptions {
verbose?: boolean;
extraArgs?: string[];
log?: string;
/** Run in the test resolver */
remote?: boolean;
/** Run in the web */
web?: boolean;
}
async function createDriverHandle(): Promise<string> {
@ -109,7 +113,7 @@ async function createDriverHandle(): Promise<string> {
export async function spawn(options: SpawnOptions): Promise<Code> {
const codePath = options.codePath;
// const electronPath = codePath ? getBuildElectronPath(codePath) : getDevElectronPath();
const electronPath = codePath ? getBuildElectronPath(codePath) : getDevElectronPath();
const outPath = codePath ? getBuildOutPath(codePath) : getDevOutPath();
const handle = await createDriverHandle();
@ -162,15 +166,21 @@ export async function spawn(options: SpawnOptions): Promise<Code> {
args.push(...options.extraArgs);
}
// const spawnOptions: cp.SpawnOptions = { env };
let child: cp.ChildProcess | undefined;
let connectDriver: typeof connectElectronDriver;
// const child = cp.spawn(electronPath, args, spawnOptions);
if (options.web) {
launch(args);
connectDriver = connectPuppeteerDriver;
} else {
const spawnOptions: cp.SpawnOptions = { env };
child = cp.spawn(electronPath, args, spawnOptions);
instances.add(child);
child.once('exit', () => instances.delete(child!));
connectDriver = connectElectronDriver;
}
// instances.add(child);
// child.once('exit', () => instances.delete(child));
const child = undefined;
return connect(child, outPath, handle, options.logger);
return connect(connectDriver, child, outPath, handle, options.logger);
}
async function poll<T>(
@ -215,7 +225,7 @@ export class Code {
private driver: IDriver;
constructor(
private client: IDisposable,
private client: IDisposable | undefined,
driver: IDriver,
readonly logger: Logger
) {
@ -331,7 +341,9 @@ export class Code {
}
dispose(): void {
this.client.dispose();
if (this.client) {
this.client.dispose();
}
}
}

View file

@ -314,6 +314,14 @@ function buildDriver(browser: puppeteer.Browser, page: puppeteer.Page): IDriver
};
}
let args;
export function launch(_args): void {
args = _args;
// TODO: Move puppeteer launch here
console.log(args);
}
export function connect(outPath: string, handle: string): Promise<{ client: IDisposable, driver: IDriver }> {
return new Promise(async (c) => {
const browser = await puppeteer.launch({
@ -325,7 +333,7 @@ export function connect(outPath: string, handle: string): Promise<{ client: IDis
});
const page = (await browser.pages())[0];
await page.setViewport({ width, height });
await page.goto('http://127.0.0.1:9888');
await page.goto(`http://127.0.0.1:9888?folder=${args[1]}`);
const result = {
client: { dispose: () => { } },
driver: buildDriver(browser, page)