mirror of
https://github.com/Microsoft/vscode
synced 2024-10-12 06:17:18 +00:00
tests: make sure to set proper exit codes
This commit is contained in:
parent
31f876f6c4
commit
6505ab448b
|
@ -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();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -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 } });
|
||||
|
||||
|
|
|
@ -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<void>((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<void>(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);
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
16
test/run.sh
16
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
|
||||
# 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
|
Loading…
Reference in a new issue