diff --git a/test/automation/src/code.ts b/test/automation/src/code.ts index 95471907abf..3d1743e0f28 100644 --- a/test/automation/src/code.ts +++ b/test/automation/src/code.ts @@ -29,7 +29,15 @@ export interface SpawnOptions { browser?: 'chromium' | 'webkit' | 'firefox'; } +let stopped = false; +process.on('exit', () => stopped = true); +process.on('SIGINT', () => stopped = true); +process.on('SIGTERM', () => stopped = true); + export async function spawn(options: SpawnOptions): Promise { + if (stopped) { + throw new Error('Smoke test process has terminated, refusing to spawn Code'); + } await copyExtension(repoPath, options.extensionsPath, 'vscode-notebook-tests'); diff --git a/test/automation/src/playwrightDriver.ts b/test/automation/src/playwrightDriver.ts index eb68ebea296..a7cc9ee74e3 100644 --- a/test/automation/src/playwrightDriver.ts +++ b/test/automation/src/playwrightDriver.ts @@ -61,22 +61,32 @@ class PlaywrightDriver implements IDriver { async exitApplication() { try { - await this.context.tracing.stop({ path: join(logsPath, `playwright-trace-${traceCounter++}.zip`) }); + await this.warnAfter(this.context.tracing.stop({ path: join(logsPath, `playwright-trace-${traceCounter++}.zip`) }), 5000, 'Stopping playwright trace took >5seconds'); } catch (error) { console.warn(`Failed to stop playwright tracing: ${error}`); } try { - await this.browser.close(); + await this.warnAfter(this.browser.close(), 5000, 'Closing playwright browser took >5seconds'); } catch (error) { console.warn(`Failed to close browser: ${error}`); } - await teardown(this.server); + await this.warnAfter(teardown(this.server), 5000, 'Tearing down server took >5seconds'); return false; } + private async warnAfter(promise: Promise, delay: number, msg: string): Promise { + const timeout = setTimeout(() => console.warn(msg), delay); + + try { + await promise; + } finally { + clearTimeout(timeout); + } + } + async dispatchKeybinding(windowId: number, keybinding: string) { const chords = keybinding.split(' '); for (let i = 0; i < chords.length; i++) { diff --git a/test/smoke/src/main.ts b/test/smoke/src/main.ts index f526eb19bf4..8f23a483e15 100644 --- a/test/smoke/src/main.ts +++ b/test/smoke/src/main.ts @@ -4,7 +4,6 @@ *--------------------------------------------------------------------------------------------*/ import * as fs from 'fs'; -import { timeout } from './utils'; import { promisify } from 'util'; import { gracefulify } from 'graceful-fs'; import * as cp from 'child_process'; @@ -336,8 +335,6 @@ before(async function () { }); after(async function () { - await timeout(500); // wait for shutdown - if (opts.log) { const logsDir = path.join(userDataDir, 'logs'); const destLogsDir = path.join(path.dirname(opts.log), 'logs');