Skip to content

Commit 8d20c17

Browse files
committed
Bring back non-web smoke tests
1 parent 488fa6d commit 8d20c17

5 files changed

Lines changed: 107 additions & 81 deletions

File tree

test/smoke/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
"postinstall": "npm run compile",
77
"compile": "npm run copy-driver && npm run copy-driver-definition && tsc",
88
"watch": "concurrently \"npm run watch-driver\" \"npm run watch-driver-definition\" \"tsc --watch\"",
9-
"copy-driver": "cpx src/vscode/puppeteer-driver.js out/vscode",
10-
"watch-driver": "cpx src/vscode/puppeteer-driver.js out/vscode -w",
9+
"copy-driver": "cpx src/vscode/driver.js out/vscode",
10+
"watch-driver": "cpx src/vscode/driver.js out/vscode -w",
1111
"copy-driver-definition": "node tools/copy-driver-definition.js",
1212
"watch-driver-definition": "watch \"node tools/copy-driver-definition.js\" ../../src/vs/platform/driver/node",
1313
"mocha": "mocha"

test/smoke/src/areas/terminal/terminal.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import { Application } from '../../application';
77

88
export function setup() {
9-
describe.only('Terminal', () => {
9+
describe('Terminal', () => {
1010
it(`opens terminal, runs 'echo' and verifies the output`, async function () {
1111
this.timeout(60 * 5000);
1212
const app = this.app as Application;

test/smoke/src/main.ts

Lines changed: 39 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@ import { ncp } from 'ncp';
1414
import { Application, Quality, ApplicationOptions } from './application';
1515

1616
import { setup as setupDataMigrationTests } from './areas/workbench/data-migration.test';
17-
// import { setup as setupDataLossTests } from './areas/workbench/data-loss.test';
18-
// import { setup as setupDataExplorerTests } from './areas/explorer/explorer.test';
19-
// import { setup as setupDataPreferencesTests } from './areas/preferences/preferences.test';
20-
// import { setup as setupDataSearchTests } from './areas/search/search.test';
21-
// import { setup as setupDataCSSTests } from './areas/css/css.test';
22-
// import { setup as setupDataEditorTests } from './areas/editor/editor.test';
23-
// import { setup as setupDataDebugTests } from './areas/debug/debug.test';
24-
// import { setup as setupDataGitTests } from './areas/git/git.test';
25-
// import { setup as setupDataStatusbarTests } from './areas/statusbar/statusbar.test';
26-
// import { setup as setupDataExtensionTests } from './areas/extensions/extensions.test';
17+
import { setup as setupDataLossTests } from './areas/workbench/data-loss.test';
18+
import { setup as setupDataExplorerTests } from './areas/explorer/explorer.test';
19+
import { setup as setupDataPreferencesTests } from './areas/preferences/preferences.test';
20+
import { setup as setupDataSearchTests } from './areas/search/search.test';
21+
import { setup as setupDataCSSTests } from './areas/css/css.test';
22+
import { setup as setupDataEditorTests } from './areas/editor/editor.test';
23+
import { setup as setupDataDebugTests } from './areas/debug/debug.test';
24+
import { setup as setupDataGitTests } from './areas/git/git.test';
25+
import { setup as setupDataStatusbarTests } from './areas/statusbar/statusbar.test';
26+
import { setup as setupDataExtensionTests } from './areas/extensions/extensions.test';
2727
import { setup as setupTerminalTests } from './areas/terminal/terminal.test';
28-
// import { setup as setupDataMultirootTests } from './areas/multiroot/multiroot.test';
29-
// import { setup as setupDataLocalizationTests } from './areas/workbench/localization.test';
28+
import { setup as setupDataMultirootTests } from './areas/multiroot/multiroot.test';
29+
import { setup as setupDataLocalizationTests } from './areas/workbench/localization.test';
3030
import { setup as setupLaunchTests } from './areas/workbench/launch.test';
3131
import { MultiLogger, Logger, ConsoleLogger, FileLogger } from './logger';
3232

@@ -51,7 +51,8 @@ const opts = minimist(args, {
5151
],
5252
boolean: [
5353
'verbose',
54-
'remote'
54+
'remote',
55+
'web'
5556
],
5657
default: {
5758
verbose: false
@@ -132,13 +133,13 @@ if (testCodePath) {
132133
process.env.VSCODE_CLI = '1';
133134
}
134135

135-
// if (!fs.existsSync(electronPath || '')) {
136-
// fail(`Can't find Code at ${electronPath}.`);
137-
// }
138-
console.log(stablePath);
139-
// if (typeof stablePath === 'string' && !fs.existsSync(stablePath)) {
140-
// fail(`Can't find Stable Code at ${stablePath}.`);
141-
// }
136+
if (!fs.existsSync(electronPath || '')) {
137+
fail(`Can't find Code at ${electronPath}.`);
138+
}
139+
140+
if (typeof stablePath === 'string' && !fs.existsSync(stablePath)) {
141+
fail(`Can't find Stable Code at ${stablePath}.`);
142+
}
142143

143144
const userDataDir = path.join(testDataPath, 'd');
144145

@@ -239,7 +240,7 @@ setupDataMigrationTests(stableCodePath, testDataPath);
239240
describe('Running Code', () => {
240241
before(async function () {
241242
const app = new Application(this.defaultOptions);
242-
await app!.start(false);
243+
await app!.start(opts.web ? false : undefined);
243244
this.app = app;
244245
});
245246

@@ -268,19 +269,24 @@ describe('Running Code', () => {
268269
});
269270
}
270271

271-
// setupDataLossTests();
272-
// setupDataExplorerTests();
273-
// setupDataPreferencesTests();
274-
// setupDataSearchTests();
275-
// setupDataCSSTests();
276-
// setupDataEditorTests();
277-
// setupDataDebugTests();
278-
// setupDataGitTests();
279-
// setupDataStatusbarTests();
280-
// setupDataExtensionTests();
272+
if (opts.web) {
273+
setupTerminalTests();
274+
return;
275+
}
276+
277+
setupDataLossTests();
278+
setupDataExplorerTests();
279+
setupDataPreferencesTests();
280+
setupDataSearchTests();
281+
setupDataCSSTests();
282+
setupDataEditorTests();
283+
setupDataDebugTests();
284+
setupDataGitTests();
285+
setupDataStatusbarTests();
286+
setupDataExtensionTests();
281287
setupTerminalTests();
282-
// setupDataMultirootTests();
283-
// setupDataLocalizationTests();
288+
setupDataMultirootTests();
289+
setupDataLocalizationTests();
284290
});
285291

286292
setupLaunchTests();

test/smoke/src/vscode/code.ts

Lines changed: 56 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -9,45 +9,46 @@ import * as os from 'os';
99
import * as fs from 'fs';
1010
import * as mkdirp from 'mkdirp';
1111
import { tmpName } from 'tmp';
12-
import { IDriver, connect as connectDriver, IDisposable, IElement, Thenable } from './puppeteer-driver';
12+
import { IDriver, connect as connectElectronDriver, IDisposable, IElement, Thenable } from './driver';
13+
import { connect as connectPuppeteerDriver, launch } from './puppeteer-driver';
1314
import { Logger } from '../logger';
1415
import { ncp } from 'ncp';
1516
import { URI } from 'vscode-uri';
1617

1718
const repoPath = path.join(__dirname, '../../../..');
1819

19-
// function getDevElectronPath(): string {
20-
// const buildPath = path.join(repoPath, '.build');
21-
// const product = require(path.join(repoPath, 'product.json'));
22-
23-
// switch (process.platform) {
24-
// case 'darwin':
25-
// return path.join(buildPath, 'electron', `${product.nameLong}.app`, 'Contents', 'MacOS', 'Electron');
26-
// case 'linux':
27-
// return path.join(buildPath, 'electron', `${product.applicationName}`);
28-
// case 'win32':
29-
// return path.join(buildPath, 'electron', `${product.nameShort}.exe`);
30-
// default:
31-
// throw new Error('Unsupported platform.');
32-
// }
33-
// }
34-
35-
// function getBuildElectronPath(root: string): string {
36-
// switch (process.platform) {
37-
// case 'darwin':
38-
// return path.join(root, 'Contents', 'MacOS', 'Electron');
39-
// case 'linux': {
40-
// const product = require(path.join(root, 'resources', 'app', 'product.json'));
41-
// return path.join(root, product.applicationName);
42-
// }
43-
// case 'win32': {
44-
// const product = require(path.join(root, 'resources', 'app', 'product.json'));
45-
// return path.join(root, `${product.nameShort}.exe`);
46-
// }
47-
// default:
48-
// throw new Error('Unsupported platform.');
49-
// }
50-
// }
20+
function getDevElectronPath(): string {
21+
const buildPath = path.join(repoPath, '.build');
22+
const product = require(path.join(repoPath, 'product.json'));
23+
24+
switch (process.platform) {
25+
case 'darwin':
26+
return path.join(buildPath, 'electron', `${product.nameLong}.app`, 'Contents', 'MacOS', 'Electron');
27+
case 'linux':
28+
return path.join(buildPath, 'electron', `${product.applicationName}`);
29+
case 'win32':
30+
return path.join(buildPath, 'electron', `${product.nameShort}.exe`);
31+
default:
32+
throw new Error('Unsupported platform.');
33+
}
34+
}
35+
36+
function getBuildElectronPath(root: string): string {
37+
switch (process.platform) {
38+
case 'darwin':
39+
return path.join(root, 'Contents', 'MacOS', 'Electron');
40+
case 'linux': {
41+
const product = require(path.join(root, 'resources', 'app', 'product.json'));
42+
return path.join(root, product.applicationName);
43+
}
44+
case 'win32': {
45+
const product = require(path.join(root, 'resources', 'app', 'product.json'));
46+
return path.join(root, `${product.nameShort}.exe`);
47+
}
48+
default:
49+
throw new Error('Unsupported platform.');
50+
}
51+
}
5152

5253
function getDevOutPath(): string {
5354
return path.join(repoPath, 'out');
@@ -62,7 +63,7 @@ function getBuildOutPath(root: string): string {
6263
}
6364
}
6465

65-
async function connect(child: cp.ChildProcess | undefined, outPath: string, handlePath: string, logger: Logger): Promise<Code> {
66+
async function connect(connectDriver: typeof connectElectronDriver, child: cp.ChildProcess | undefined, outPath: string, handlePath: string, logger: Logger): Promise<Code> {
6667
let errCount = 0;
6768

6869
while (true) {
@@ -95,7 +96,10 @@ export interface SpawnOptions {
9596
verbose?: boolean;
9697
extraArgs?: string[];
9798
log?: string;
99+
/** Run in the test resolver */
98100
remote?: boolean;
101+
/** Run in the web */
102+
web?: boolean;
99103
}
100104

101105
async function createDriverHandle(): Promise<string> {
@@ -109,7 +113,7 @@ async function createDriverHandle(): Promise<string> {
109113

110114
export async function spawn(options: SpawnOptions): Promise<Code> {
111115
const codePath = options.codePath;
112-
// const electronPath = codePath ? getBuildElectronPath(codePath) : getDevElectronPath();
116+
const electronPath = codePath ? getBuildElectronPath(codePath) : getDevElectronPath();
113117
const outPath = codePath ? getBuildOutPath(codePath) : getDevOutPath();
114118
const handle = await createDriverHandle();
115119

@@ -162,15 +166,21 @@ export async function spawn(options: SpawnOptions): Promise<Code> {
162166
args.push(...options.extraArgs);
163167
}
164168

165-
// const spawnOptions: cp.SpawnOptions = { env };
169+
let child: cp.ChildProcess | undefined;
170+
let connectDriver: typeof connectElectronDriver;
166171

167-
// const child = cp.spawn(electronPath, args, spawnOptions);
168-
169-
// instances.add(child);
170-
// child.once('exit', () => instances.delete(child));
172+
if (options.web) {
173+
launch(args);
174+
connectDriver = connectPuppeteerDriver;
175+
} else {
176+
const spawnOptions: cp.SpawnOptions = { env };
177+
child = cp.spawn(electronPath, args, spawnOptions);
178+
instances.add(child);
179+
child.once('exit', () => instances.delete(child!));
180+
connectDriver = connectElectronDriver;
181+
}
171182

172-
const child = undefined;
173-
return connect(child, outPath, handle, options.logger);
183+
return connect(connectDriver, child, outPath, handle, options.logger);
174184
}
175185

176186
async function poll<T>(
@@ -215,7 +225,7 @@ export class Code {
215225
private driver: IDriver;
216226

217227
constructor(
218-
private client: IDisposable,
228+
private client: IDisposable | undefined,
219229
driver: IDriver,
220230
readonly logger: Logger
221231
) {
@@ -331,7 +341,9 @@ export class Code {
331341
}
332342

333343
dispose(): void {
334-
this.client.dispose();
344+
if (this.client) {
345+
this.client.dispose();
346+
}
335347
}
336348
}
337349

test/smoke/src/vscode/puppeteer-driver.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,14 @@ function buildDriver(browser: puppeteer.Browser, page: puppeteer.Page): IDriver
314314
};
315315
}
316316

317+
let args;
318+
319+
export function launch(_args): void {
320+
args = _args;
321+
// TODO: Move puppeteer launch here
322+
console.log(args);
323+
}
324+
317325
export function connect(outPath: string, handle: string): Promise<{ client: IDisposable, driver: IDriver }> {
318326
return new Promise(async (c) => {
319327
const browser = await puppeteer.launch({
@@ -325,7 +333,7 @@ export function connect(outPath: string, handle: string): Promise<{ client: IDis
325333
});
326334
const page = (await browser.pages())[0];
327335
await page.setViewport({ width, height });
328-
await page.goto('http://127.0.0.1:9888');
336+
await page.goto(`http://127.0.0.1:9888?folder=${args[1]}`);
329337
const result = {
330338
client: { dispose: () => { } },
331339
driver: buildDriver(browser, page)

0 commit comments

Comments
 (0)