33 * Licensed under the MIT License. See License.txt in the project root for license information.
44 *--------------------------------------------------------------------------------------------*/
55
6- import { test as testPort } from 'portastic' ;
76import { API } from './api' ;
87import { ScreenCapturer } from './helpers/screenshot' ;
98import { Workbench } from './areas/workbench/workbench' ;
@@ -12,19 +11,6 @@ import * as cp from 'child_process';
1211import { CodeDriver } from './driver' ;
1312import { Code , spawn , SpawnOptions } from './vscode/code' ;
1413
15- // Just hope random helps us here, cross your fingers!
16- export async function findFreePort ( ) : Promise < number > {
17- for ( let i = 0 ; i < 10 ; i ++ ) {
18- const port = 10000 + Math . round ( Math . random ( ) * 10000 ) ;
19-
20- if ( await testPort ( port ) ) {
21- return port ;
22- }
23- }
24-
25- throw new Error ( 'Could not find free port!' ) ;
26- }
27-
2814export enum Quality {
2915 Dev ,
3016 Insiders ,
@@ -141,85 +127,6 @@ export class SpectronApplication {
141127 }
142128
143129 private async startApplication ( workspaceOrFolder : string , extraArgs : string [ ] = [ ] ) : Promise < any > {
144-
145- // let args: string[] = [];
146- // let chromeDriverArgs: string[] = [];
147-
148- // if (process.env.VSCODE_REPOSITORY) {
149- // args.push(process.env.VSCODE_REPOSITORY as string);
150- // }
151-
152- // args.push(workspaceOrFolder);
153-
154- // // Prevent 'Getting Started' web page from opening on clean user-data-dir
155- // args.push('--skip-getting-started');
156-
157- // // Prevent 'Getting Started' web page from opening on clean user-data-dir
158- // args.push('--skip-release-notes');
159-
160- // // Prevent Quick Open from closing when focus is stolen, this allows concurrent smoketest suite running
161- // args.push('--sticky-quickopen');
162-
163- // // Disable telemetry
164- // args.push('--disable-telemetry');
165-
166- // // Disable updates
167- // args.push('--disable-updates');
168-
169- // // Disable crash reporter
170- // // This seems to be the fix for the strange hangups in which Code stays unresponsive
171- // // and tests finish badly with timeouts, leaving Code running in the background forever
172- // args.push('--disable-crash-reporter');
173-
174- // // Ensure that running over custom extensions directory, rather than picking up the one that was used by a tester previously
175- // args.push(`--extensions-dir=${this.options.extensionsPath}`);
176-
177- // args.push(...extraArgs);
178-
179- // chromeDriverArgs.push(`--user-data-dir=${this.options.userDataDir}`);
180-
181- // Spectron always uses the same port number for the chrome driver
182- // and it handles gracefully when two instances use the same port number
183- // This works, but when one of the instances quits, it takes down
184- // chrome driver with it, leaving the other instance in DISPAIR!!! :(
185- // const port = await findFreePort();
186-
187- // We must get a different port for debugging the smoketest express app
188- // otherwise concurrent test runs will clash on those ports
189- // const env = { PORT: String(await findFreePort()), ...process.env };
190-
191- // const opts = {
192- // path: this.options.electronPath,
193- // port,
194- // args,
195- // env,
196- // chromeDriverArgs,
197- // startTimeout: 10000,
198- // requireName: 'nodeRequire'
199- // };
200-
201- // const runName = String(SpectronApplication.count++);
202- // let testsuiteRootPath: string | undefined = undefined;
203- // let screenshotsDirPath: string | undefined = undefined;
204-
205- // if (this.options.artifactsPath) {
206- // testsuiteRootPath = path.join(this.options.artifactsPath, sanitize(runName));
207- // mkdirp.sync(testsuiteRootPath);
208-
209- // // Collect screenshots
210- // screenshotsDirPath = path.join(testsuiteRootPath, 'screenshots');
211- // mkdirp.sync(screenshotsDirPath);
212-
213- // // Collect chromedriver logs
214- // const chromedriverLogPath = path.join(testsuiteRootPath, 'chromedriver.log');
215- // opts.chromeDriverLogPath = chromedriverLogPath;
216-
217- // // Collect webdriver logs
218- // const webdriverLogsPath = path.join(testsuiteRootPath, 'webdriver');
219- // mkdirp.sync(webdriverLogsPath);
220- // opts.webdriverLogPath = webdriverLogsPath;
221- // }
222-
223130 this . codeInstance = await spawn ( {
224131 codePath : this . options . codePath ,
225132 workspacePath : workspaceOrFolder ,
@@ -228,43 +135,6 @@ export class SpectronApplication {
228135 verbose : this . options . verbose
229136 } ) ;
230137
231- // if (testsuiteRootPath) {
232- // // Collect logs
233- // const mainProcessLogPath = path.join(testsuiteRootPath, 'main.log');
234- // const rendererProcessLogPath = path.join(testsuiteRootPath, 'renderer.log');
235-
236- // const flush = async () => {
237- // if (!this.spectron) {
238- // return;
239- // }
240-
241- // const mainLogs = await this.spectron.client.getMainProcessLogs();
242- // await new Promise((c, e) => fs.appendFile(mainProcessLogPath, mainLogs.join('\n'), { encoding: 'utf8' }, err => err ? e(err) : c()));
243-
244- // const rendererLogs = (await this.spectron.client.getRenderProcessLogs()).map(m => `${m.timestamp} - ${m.level} - ${m.message}`);
245- // await new Promise((c, e) => fs.appendFile(rendererProcessLogPath, rendererLogs.join('\n'), { encoding: 'utf8' }, err => err ? e(err) : c()));
246- // };
247-
248- // let running = true;
249- // const loopFlush = async () => {
250- // while (true) {
251- // await flush();
252-
253- // if (!running) {
254- // return;
255- // }
256-
257- // await new Promise(c => setTimeout(c, 1000));
258- // }
259- // };
260-
261- // const loopPromise = loopFlush();
262- // this.stopLogCollection = () => {
263- // running = false;
264- // return loopPromise;
265- // };
266- // }
267-
268138 this . _screenCapturer = new ScreenCapturer ( null as any , this . _suiteName , '' ) ;
269139
270140 const driver = new CodeDriver ( this . codeInstance . driver , this . options . verbose ) ;
0 commit comments