Exit gracefully on linux by ckerr · Pull Request #12139 · electron/electron · GitHub
Skip to content

Exit gracefully on linux#12139

Merged
codebytere merged 6 commits into
masterfrom
exit-gracefully-on-linux
Mar 7, 2018
Merged

Exit gracefully on linux#12139
codebytere merged 6 commits into
masterfrom
exit-gracefully-on-linux

Conversation

@ckerr

@ckerr ckerr commented Mar 6, 2018

Copy link
Copy Markdown
Member
  1. Fixes not ok 11 app module app.exit(exitCode) exits gracefully on macos #12050 which was caused by a timing issue. The singleton fixture was reporting its readiness before app had emitted a 'ready' signal. At times, this could cause the parent test harness to run its tests before the child Electron process had finished starting its event loop.

  2. Rewrites the exit_gracefully_on_macos() test to run on other platforms too.

This code is ready for review but is a WIP in the sense that I need confirmation from CI about the portability of the rewritten test.

ckerr added 3 commits March 6, 2018 15:45
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.
Rewrite the "exits gracefully on macos" spec to run on Linux too.
@ckerr ckerr requested a review from a team March 6, 2018 07:02
ckerr added 2 commits March 6, 2018 16:14
In the 'exits gracefully' test for app.exit(exitCode),
print the relevant error information if the test fails.

@codebytere codebytere left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀 ty for this, solves such a key flake

@codebytere

codebytere commented Mar 6, 2018

Copy link
Copy Markdown
Member

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.
@ckerr

ckerr commented Mar 6, 2018

Copy link
Copy Markdown
Member Author

@codebytere, thank you for doing the win32 research on this!

I agree we'll need a different approach for win32. Simulating SIGTERM is a good Node feature, but forcing an unconditional exit doesn't give us a meaningful test when we're looking for a graceful shutdown. So let's limit this implementation of the test to macOS and Linux.

@codebytere

Copy link
Copy Markdown
Member

in that case, i'll merge when CI goes ✅✨

@codebytere codebytere merged commit 65ee977 into master Mar 7, 2018
@codebytere codebytere deleted the exit-gracefully-on-linux branch March 7, 2018 03:01
@alexeykuzmin

Copy link
Copy Markdown
Contributor

I would vote for backporting the change to 2-0-x. Flaky tests is pain.

@ckerr, @codebytere

codebytere pushed a commit that referenced this pull request Mar 7, 2018
* 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.
@codebytere

Copy link
Copy Markdown
Member

sethlu pushed a commit to sethlu/electron that referenced this pull request May 3, 2018
* 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. (electron#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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

not ok 11 app module app.exit(exitCode) exits gracefully on macos

3 participants