Skip to content

Commit 9bdcd61

Browse files
authored
Merge pull request microsoft#65941 from Microsoft/kieferrm/smoke-test-shutdown
Gentle shutdown of application in smoke test
2 parents c4a1b80 + 26ed89d commit 9bdcd61

4 files changed

Lines changed: 16 additions & 3 deletions

File tree

src/vs/platform/driver/electron-main/driver.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ export class Driver implements IDriver, IWindowDriverRegistry {
7171
this.windowsService.reload(window);
7272
}
7373

74+
async exitApplication(): Promise<void> {
75+
return this.windowsService.quit();
76+
}
77+
7478
async dispatchKeybinding(windowId: number, keybinding: string): Promise<void> {
7579
await this.whenUnfrozen(windowId);
7680

src/vs/platform/driver/node/driver.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export interface IDriver {
3030
getWindowIds(): Promise<number[]>;
3131
capturePage(windowId: number): Promise<string>;
3232
reloadWindow(windowId: number): Promise<void>;
33+
exitApplication(): Promise<void>;
3334
dispatchKeybinding(windowId: number, keybinding: string): Promise<void>;
3435
click(windowId: number, selector: string, xoffset?: number | undefined, yoffset?: number | undefined): Promise<void>;
3536
doubleClick(windowId: number, selector: string): Promise<void>;
@@ -56,6 +57,7 @@ export class DriverChannel implements IServerChannel {
5657
case 'getWindowIds': return this.driver.getWindowIds();
5758
case 'capturePage': return this.driver.capturePage(arg);
5859
case 'reloadWindow': return this.driver.reloadWindow(arg);
60+
case 'exitApplication': return this.driver.exitApplication();
5961
case 'dispatchKeybinding': return this.driver.dispatchKeybinding(arg[0], arg[1]);
6062
case 'click': return this.driver.click(arg[0], arg[1], arg[2], arg[3]);
6163
case 'doubleClick': return this.driver.doubleClick(arg[0], arg[1]);
@@ -90,6 +92,10 @@ export class DriverChannelClient implements IDriver {
9092
return this.channel.call('reloadWindow', windowId);
9193
}
9294

95+
exitApplication(): Promise<void> {
96+
return this.channel.call('exitApplication');
97+
}
98+
9399
dispatchKeybinding(windowId: number, keybinding: string): Promise<void> {
94100
return this.channel.call('dispatchKeybinding', [windowId, keybinding]);
95101
}

test/smoke/src/application.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ export class Application {
8989

9090
async stop(): Promise<any> {
9191
if (this._code) {
92+
await this._code.exit();
9293
this._code.dispose();
9394
this._code = undefined;
9495
}

test/smoke/src/vscode/code.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ async function connect(child: cp.ChildProcess, outPath: string, handlePath: stri
6464
while (true) {
6565
try {
6666
const { client, driver } = await connectDriver(outPath, handlePath);
67-
return new Code(child, client, driver, logger);
67+
return new Code(client, driver, logger);
6868
} catch (err) {
6969
if (++errCount > 50) {
7070
child.kill();
@@ -188,7 +188,6 @@ export class Code {
188188
private driver: IDriver;
189189

190190
constructor(
191-
private process: cp.ChildProcess,
192191
private client: IDisposable,
193192
driver: IDriver,
194193
readonly logger: Logger
@@ -230,6 +229,10 @@ export class Code {
230229
await this.driver.reloadWindow(windowId);
231230
}
232231

232+
async exit(): Promise<void> {
233+
await this.driver.exitApplication();
234+
}
235+
233236
async waitForTextContent(selector: string, textContent?: string, accept?: (result: string) => boolean): Promise<string> {
234237
const windowId = await this.getActiveWindowId();
235238
accept = accept || (result => textContent !== undefined ? textContent === result : !!result);
@@ -302,7 +305,6 @@ export class Code {
302305

303306
dispose(): void {
304307
this.client.dispose();
305-
this.process.kill();
306308
}
307309
}
308310

0 commit comments

Comments
 (0)