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

--functional: wait for wrapper to end its operations before destroing the child process #787

Merged
merged 2 commits into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,19 @@
"phpunit/php-code-coverage": "^10.1.3",
"phpunit/php-file-iterator": "^4.0.2",
"phpunit/php-timer": "^6.0",
"phpunit/phpunit": "^10.3.1",
"phpunit/phpunit": "^10.3.2",
"sebastian/environment": "^6.0.1",
"symfony/console": "^6.3.2",
"symfony/process": "^6.3.2"
"symfony/console": "^6.3.4",
"symfony/process": "^6.3.4"
},
"require-dev": {
"ext-pcov": "*",
"ext-posix": "*",
"doctrine/coding-standard": "^12.0.0",
"infection/infection": "^0.27.0",
"phpstan/phpstan": "^1.10.26",
"phpstan/phpstan-deprecation-rules": "^1.1.3",
"phpstan/phpstan-phpunit": "^1.3.13",
"phpstan/phpstan": "^1.10.32",
"phpstan/phpstan-deprecation-rules": "^1.1.4",
"phpstan/phpstan-phpunit": "^1.3.14",
"phpstan/phpstan-strict-rules": "^1.5.1",
"squizlabs/php_codesniffer": "^3.7.2",
"symfony/filesystem": "^6.3.1"
Expand Down
8 changes: 4 additions & 4 deletions src/WrapperRunner/WrapperRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,11 @@ private function startWorker(int $token): WrapperWorker

private function destroyWorker(int $token): void
{
// Mutation Testing tells us that the following `unset()` already destroys
// the `WrapperWorker`, which destroys the Symfony's `Process`, which
// automatically calls `Process::stop` within `Process::__destruct()`.
// But we prefer to have an explicit stops.
$this->workers[$token]->stop();
// We need to wait for ApplicationForWrapperWorker::end to end
while ($this->workers[$token]->isRunning()) {
usleep(self::CYCLE_SLEEP);
}
Copy link
Member Author

Choose a reason for hiding this comment

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

@nunomaduro can you apply this fix to Pest too please?


unset($this->workers[$token]);
}
Expand Down
16 changes: 16 additions & 0 deletions test/Unit/WrapperRunner/WrapperRunnerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,22 @@ public function testFunctionalParallelization(): void
self::assertSame(RunnerInterface::SUCCESS_EXIT, $runnerResult->exitCode);
}

#[RequiresPhp('8.2')]
public function testFunctionalParallelizationWithJunitLogging(): void
{
$outputFile = $this->tmpDir . DIRECTORY_SEPARATOR . 'test-output.xml';

$this->bareOptions['path'] = $this->fixture('function_parallelization_tests');
$this->bareOptions['--processes'] = '1';
$this->bareOptions['--functional'] = true;
$this->bareOptions['--max-batch-size'] = 1;
$this->bareOptions['--log-junit'] = $outputFile;

$runnerResult = $this->runRunner();
self::assertStringContainsString('.......', $runnerResult->output);
self::assertSame(RunnerInterface::SUCCESS_EXIT, $runnerResult->exitCode);
}

public function testProcessIsolation(): void
{
$this->bareOptions['path'] = $this->fixture('process_isolation' . DIRECTORY_SEPARATOR . 'FooTest.php');
Expand Down