Skip to content

Commit 9d427e4

Browse files
committed
smoke test tweaks
- remove timeout on shutdown - log exactly where time is spend on shutdown (web) - stop spawning code when terminated
1 parent 68a1e2f commit 9d427e4

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

test/automation/src/code.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,15 @@ export interface SpawnOptions {
2929
browser?: 'chromium' | 'webkit' | 'firefox';
3030
}
3131

32+
let stopped = false;
33+
process.on('exit', () => stopped = true);
34+
process.on('SIGINT', () => stopped = true);
35+
process.on('SIGTERM', () => stopped = true);
36+
3237
export async function spawn(options: SpawnOptions): Promise<Code> {
38+
if (stopped) {
39+
throw new Error('Smoke test process has terminated, refusing to spawn Code');
40+
}
3341

3442
await copyExtension(repoPath, options.extensionsPath, 'vscode-notebook-tests');
3543

test/automation/src/playwrightDriver.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,22 +61,32 @@ class PlaywrightDriver implements IDriver {
6161

6262
async exitApplication() {
6363
try {
64-
await this.context.tracing.stop({ path: join(logsPath, `playwright-trace-${traceCounter++}.zip`) });
64+
await this.warnAfter(this.context.tracing.stop({ path: join(logsPath, `playwright-trace-${traceCounter++}.zip`) }), 5000, 'Stopping playwright trace took >5seconds');
6565
} catch (error) {
6666
console.warn(`Failed to stop playwright tracing: ${error}`);
6767
}
6868

6969
try {
70-
await this.browser.close();
70+
await this.warnAfter(this.browser.close(), 5000, 'Closing playwright browser took >5seconds');
7171
} catch (error) {
7272
console.warn(`Failed to close browser: ${error}`);
7373
}
7474

75-
await teardown(this.server);
75+
await this.warnAfter(teardown(this.server), 5000, 'Tearing down server took >5seconds');
7676

7777
return false;
7878
}
7979

80+
private async warnAfter(promise: Promise<void>, delay: number, msg: string): Promise<void> {
81+
const timeout = setTimeout(() => console.warn(msg), delay);
82+
83+
try {
84+
await promise;
85+
} finally {
86+
clearTimeout(timeout);
87+
}
88+
}
89+
8090
async dispatchKeybinding(windowId: number, keybinding: string) {
8191
const chords = keybinding.split(' ');
8292
for (let i = 0; i < chords.length; i++) {

test/smoke/src/main.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import * as fs from 'fs';
7-
import { timeout } from './utils';
87
import { promisify } from 'util';
98
import { gracefulify } from 'graceful-fs';
109
import * as cp from 'child_process';
@@ -336,8 +335,6 @@ before(async function () {
336335
});
337336

338337
after(async function () {
339-
await timeout(500); // wait for shutdown
340-
341338
if (opts.log) {
342339
const logsDir = path.join(userDataDir, 'logs');
343340
const destLogsDir = path.join(path.dirname(opts.log), 'logs');

0 commit comments

Comments
 (0)