Exit gracefully on linux (#12139)

* Fix timing issue in singleton fixture.

Singleton now sends the "we've started" message out only after it's
received a `'ready'` event from `app`. Previously it sent the message
out immediately, resulting in the parent test trying to manipulate it
before Singleton's event loop was fully bootstrapped.

* Check for graceful exits on Linux, too.

Rewrite the "exits gracefully on macos" spec to run on Linux too.

* Check for graceful exits everywhere.

* Tweak comment

* Better error logging in api-app-spec.js. (#12122)

In the 'exits gracefully' test for app.exit(exitCode),
print the relevant error information if the test fails.

* Run the exit-gracefully test on macOS and Linux.

Windows does not support sending signals, but Node.js offers some
emulation with process.kill(), and subprocess.kill(). Sending signal 0
can be used to test for the existence of a process. Sending SIGINT,
SIGTERM, and SIGKILL cause the unconditional termination of the target
process.

So, we'll need a different approach if we want to test this in win32.
This commit is contained in:
Charles Kerr 2018-03-07 12:01:17 +09:00 committed by Shelley Vohr
parent f170914def
commit 65ee977a86
2 changed files with 16 additions and 12 deletions

View file

@ -1,6 +1,8 @@
const {app} = require('electron')
console.log('started') // ping parent
app.once('ready', () => {
console.log('started') // ping parent
})
const shouldExit = app.makeSingleInstance(() => {
process.nextTick(() => app.exit(0))