Skip to content

[Process] Make tests more deterministic #17070

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

Merged
merged 1 commit into from
Dec 23, 2015

Conversation

nicolas-grekas
Copy link
Member

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #16988
License MIT
Doc PR -

This makes running the Process tests faster and more deterministic.

@nicolas-grekas nicolas-grekas force-pushed the fix-process-test branch 3 times, most recently from 4bac9b9 to 0f982e6 Compare December 21, 2015 12:02
@@ -422,6 +429,8 @@ public function signal($signal)
public function disableOutput()
{
if ($this->isRunning()) {
$this->stop(0);
Copy link
Contributor

Choose a reason for hiding this comment

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

this drastically changes the bahavior of Symfony Process. I consider this as a BC break

Copy link
Member Author

Choose a reason for hiding this comment

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

reverted, even if I think that stopping the process when an exception is triggered would make things more robust (less process left behind)

if (!is_resource($this->process)) {
throw new RuntimeException('Unable to launch a new process.');
}
$this->status = self::STATUS_STARTED;

if (isset($descriptors[3])) {
fclose($ptsWorkaround);
Copy link
Member

Choose a reason for hiding this comment

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

moving this line looks wrong to me: you are not closing it anymore in case launching the process fails.

Copy link
Member Author

Choose a reason for hiding this comment

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

resources are automatically closed when they are not used anymore, isn't it?

Copy link
Member

Choose a reason for hiding this comment

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

I don't think so. they are closed at the end of the process but maybe not on GC

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think so. they are closed at the end of the process

I tried with this script:

for ($i = 100000; $i; --$i) {
    $h[] = fopen(__FILE__, 'r');
}

if fails as expected with failed to open stream: Too many open files

but if I replace $h[] by $h it doesn't fail, which for me means the
files are closed once resources are freed. Isn't it?

@nicolas-grekas nicolas-grekas force-pushed the fix-process-test branch 2 times, most recently from 0f56981 to 86de2ed Compare December 21, 2015 14:16
@nicolas-grekas
Copy link
Member Author

Status: needs work
To be rebased on top of #17094

@nicolas-grekas nicolas-grekas merged commit 0dc9389 into symfony:2.7 Dec 23, 2015
nicolas-grekas added a commit that referenced this pull request Dec 23, 2015
This PR was merged into the 2.7 branch.

Discussion
----------

[Process] Make tests more deterministic

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #16988
| License       | MIT
| Doc PR        | -

This makes running the Process tests faster and more deterministic.

Commits
-------

0dc9389 [Process] Make tests more deterministic
@nicolas-grekas nicolas-grekas deleted the fix-process-test branch December 23, 2015 08:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants