From 6505ab448bde46d72f9b8565035e6f56cc0ae55d Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Tue, 24 Nov 2015 08:20:58 +0100 Subject: [PATCH] tests: make sure to set proper exit codes --- src/vs/workbench/electron-main/lifecycle.ts | 2 +- src/vs/workbench/electron-main/windows.ts | 4 ++++ src/vs/workbench/node/pluginHostMain.ts | 12 ++++++------ .../thread/electron-browser/threadService.ts | 7 ++++++- test/run.sh | 16 +++++++++------- 5 files changed, 26 insertions(+), 15 deletions(-) diff --git a/src/vs/workbench/electron-main/lifecycle.ts b/src/vs/workbench/electron-main/lifecycle.ts index 831415103a5..4d0cbc3f5f6 100644 --- a/src/vs/workbench/electron-main/lifecycle.ts +++ b/src/vs/workbench/electron-main/lifecycle.ts @@ -68,7 +68,7 @@ export class Lifecycle { // Windows/Linux: we quit when all windows have closed // Mac: we only quit when quit was requested // Tests: we always quit - if (this.quitRequested || process.platform !== 'darwin' || env.isTestingFromCli) { + if (this.quitRequested || process.platform !== 'darwin') { app.quit(); } }); diff --git a/src/vs/workbench/electron-main/windows.ts b/src/vs/workbench/electron-main/windows.ts index 81dd55b071c..0d1d2ab0f0f 100644 --- a/src/vs/workbench/electron-main/windows.ts +++ b/src/vs/workbench/electron-main/windows.ts @@ -266,6 +266,10 @@ export class WindowsManager { console[logEntry.severity].apply(console, args); }); + ipc.on('vscode:exit', (event: Event, code: number) => { + process.exit(code); + }); + UpdateManager.on('update-downloaded', (update: IUpdate) => { this.sendToFocused('vscode:telemetry', { eventName: 'update:downloaded', data: { version: update.version } }); diff --git a/src/vs/workbench/node/pluginHostMain.ts b/src/vs/workbench/node/pluginHostMain.ts index cdd8c531459..6364e96aa43 100644 --- a/src/vs/workbench/node/pluginHostMain.ts +++ b/src/vs/workbench/node/pluginHostMain.ts @@ -99,7 +99,7 @@ export function createServices(remoteCom: IPluginsIPC, initData: IInitData, shar } interface ITestRunner { - run(testsRoot:string, clb: (error:Error) => void): void; + run(testsRoot:string, clb: (error:Error, failures?: number) => void): void; } export class PluginHostMain { @@ -235,7 +235,7 @@ export class PluginHostMain { // Execute the runner if it follows our spec if (testRunner && typeof testRunner.run === 'function') { return new TPromise((c, e) => { - testRunner.run(env.pluginTestsPath, (error) => { + testRunner.run(env.pluginTestsPath, (error, failures) => { if (error) { e(error.toString()); } else { @@ -243,22 +243,22 @@ export class PluginHostMain { } // after tests have run, we shutdown the host - this.gracefulExit(); + this.gracefulExit(failures && failures > 0 ? 1 /* ERROR */ : 0 /* OK */); }); }); } // Otherwise make sure to shutdown anyway even in case of an error else { - this.gracefulExit(); + this.gracefulExit(1 /* ERROR */); } return TPromise.wrapError(requireError ? requireError.toString() : nls.localize('pluginTestError', "Path {0} does not point to a valid extension test runner.", env.pluginTestsPath)); } - private gracefulExit(): void { + private gracefulExit(code: number): void { // to give the PH process a chance to flush any outstanding console // messages to the main process, we delay the exit() by some time - setTimeout(() => exit(), 500); + setTimeout(() => exit(code), 500); } } \ No newline at end of file diff --git a/src/vs/workbench/services/thread/electron-browser/threadService.ts b/src/vs/workbench/services/thread/electron-browser/threadService.ts index fe946ab0837..6c365c26e68 100644 --- a/src/vs/workbench/services/thread/electron-browser/threadService.ts +++ b/src/vs/workbench/services/thread/electron-browser/threadService.ts @@ -237,9 +237,14 @@ class PluginHostProcessManager { } // Expected development plugin termination: When the plugin host goes down we also shutdown the window - else { + else if (!isTestingFromCli) { this.windowService.getWindow().close(); } + + // When CLI testing make sure to exit with proper exit code + else { + ipc.send('vscode:exit', code); + } } }); }); diff --git a/test/run.sh b/test/run.sh index c33c03ac96c..8a94edda3a1 100755 --- a/test/run.sh +++ b/test/run.sh @@ -18,10 +18,12 @@ else node_modules/mocha/bin/_mocha $* fi -# Integration Tests -if [[ "$OSTYPE" == "linux" ]]; then - export DISPLAY=:99.0 - sh -e /etc/init.d/xvfb start - sleep 3 -fi -./scripts/code.sh $ROOT/extensions/vscode-api-tests/testWorkspace --extensionDevelopmentPath=$ROOT/extensions/vscode-api-tests --extensionTestsPath=$ROOT/extensions/vscode-api-tests/out \ No newline at end of file +# Integration Tests (currently not enabled for linux because of missing display) +# if [[ "$OSTYPE" == "linux" ]]; then +# export DISPLAY=:99.0 +# sh -e /etc/init.d/xvfb start +# sleep 3 +# fi +if [[ "$OSTYPE" == "darwin"* ]]; then +./scripts/code.sh $ROOT/extensions/vscode-api-tests/testWorkspace --extensionDevelopmentPath=$ROOT/extensions/vscode-api-tests --extensionTestsPath=$ROOT/extensions/vscode-api-tests/out +fi \ No newline at end of file -- GitLab