Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: `fork()`: Automatically exit child process after closure returns #139

Merged
merged 1 commit into from Feb 8, 2017

Conversation

@antrik
Copy link
Contributor

antrik commented Feb 8, 2017

Rather than panicking, just exit the process cleanly.

The idea with this was that the closure is never supposed to return,
since chaos would ensue otherwise, as the child process and the parent
process would continue running the rest of the test suite.

However, the existing unreachable!() panic that was supposed to
enforce this, effectively just terminated the process anyway. The panic
message wouldn't even show up unless using --nocapture. So we can just
as well make this official, so callers are no longer required to exit
the process explicitly. This actually makes use of fork() more
ergonomic.

Rather than panicking, just exit the process cleanly.

The idea with this was that the closure is never supposed to return,
since chaos would ensue otherwise, as the child process and the parent
process would continue running the rest of the test suite.

However, the existing `unreachable!()` panic that was supposed to
enforce this, effectively just terminated the process anyway. The panic
message wouldn't even show up unless using `--nocapture`. So we can just
as well make this official, so callers are no longer required to exit
the process explicitly. This actually makes use of `fork()` more
ergonomic.
@metajack
Copy link

metajack commented Feb 8, 2017

The only case where this might be different is that panics may be trapped in the application and thus not cause an exit. Is that not a likely scenario?

@antrik
Copy link
Contributor Author

antrik commented Feb 8, 2017

@metajack that's an interesting point, since the test runner does trap panics AIUI? I haven't seen this cause any trouble though when there is a panic in a sub-process... (Aside from the parent sometimes hanging waiting for an answer until the test timeout kicks in -- but that's OK I guess...) Maybe that's because a forked process only clones the thread that called fork(), so the thread panic causes the process to terminate anyway? Not sure.

At any rate, more explicitly terminating the process is actually more correct in this regard.

@metajack
Copy link

metajack commented Feb 8, 2017

@bors-servo
Copy link
Contributor

bors-servo commented Feb 8, 2017

📌 Commit 38eba4b has been approved by metajack

@bors-servo
Copy link
Contributor

bors-servo commented Feb 8, 2017

Testing commit 38eba4b with merge abc74c9...

bors-servo added a commit that referenced this pull request Feb 8, 2017
tests: `fork()`: Automatically exit child process after closure returns

Rather than panicking, just exit the process cleanly.

The idea with this was that the closure is never supposed to return,
since chaos would ensue otherwise, as the child process and the parent
process would continue running the rest of the test suite.

However, the existing `unreachable!()` panic that was supposed to
enforce this, effectively just terminated the process anyway. The panic
message wouldn't even show up unless using `--nocapture`. So we can just
as well make this official, so callers are no longer required to exit
the process explicitly. This actually makes use of `fork()` more
ergonomic.
@bors-servo
Copy link
Contributor

bors-servo commented Feb 8, 2017

☀️ Test successful - status-appveyor, status-travis
Approved by: metajack
Pushing abc74c9 to master...

@bors-servo bors-servo merged commit 38eba4b into servo:master Feb 8, 2017
3 checks passed
3 checks passed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants
You can’t perform that action at this time.