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

Process isolation doesn't work starting from 10.2.0 #5595

Closed
l-alexandrov opened this issue Dec 1, 2023 · 6 comments
Closed

Process isolation doesn't work starting from 10.2.0 #5595

l-alexandrov opened this issue Dec 1, 2023 · 6 comments
Labels
feature/process-isolation Issues related to running tests in separate PHP processes status/waiting-for-feedback Waiting for feedback from original reporter type/bug Something is broken version/10 Something affects PHPUnit 10

Comments

@l-alexandrov
Copy link

Q A
PHPUnit version 10.2.0
PHP version 8.3.0
Installation Method Composer

Summary

When enable processs isolation in any form (CLI argument, PHP doc annotation or attribute in phpunit.xml) the tests are failing with an error.
I'm using PHPUnit in combination with Laravel 10.34.2. Prior to PHPUnit 10.2.0 I had no issues with proccess isolation.

Current behavior

When run a test in a process isolation I get Test was run in child process and ended unexpectedly error.

How to reproduce

vendor/bin/phpunit --process-isolation and see the error.

Expected behavior

Getting no errors.

Configuration

<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.4/phpunit.xsd"
         bootstrap="vendor/autoload.php"
         executionOrder="depends,defects"
         beStrictAboutOutputDuringTests="true"
         failOnRisky="true"
         failOnWarning="true"
         colors="true"
         enforceTimeLimit="true"
         defaultTimeLimit="3"
>
    <testsuites>
        <testsuite name="Unit">
            <directory>./tests/Unit</directory>
        </testsuite>
        <testsuite name="Feature">
            <directory>./tests/Feature</directory>
        </testsuite>
        <testsuite name="Integration">
            <directory>./tests/Integration</directory>
        </testsuite>
    </testsuites>
  <coverage/>
    <php>
        <server name="APP_ENV" value="testing"/>
        <server name="BCRYPT_ROUNDS" value="4"/>
    </php>
  <source>
    <include>
      <directory suffix=".php">./app</directory>
    </include>
  </source>
</phpunit>
@l-alexandrov l-alexandrov added type/bug Something is broken version/10 Something affects PHPUnit 10 labels Dec 1, 2023
@sebastianbergmann sebastianbergmann added status/waiting-for-feedback Waiting for feedback from original reporter feature/process-isolation Issues related to running tests in separate PHP processes labels Dec 1, 2023
@sebastianbergmann
Copy link
Owner

Thank you for your report.

Please provide a minimal, self-contained, reproducing test case that shows the problem you are reporting.

Without such a minimal, self-contained, reproducing test case I will not be able to investigate this issue.

@l-alexandrov
Copy link
Author

It looks it's a Laravel issue, since I have no problems when extending PHPUnit's TestCase class.

@arclw
Copy link

arclw commented Jan 6, 2024

@l-alexandrov Were you able to solve it? Please share it how ?

@l-alexandrov
Copy link
Author

l-alexandrov commented Jan 8, 2024

@arclw In my case I'm using Laravel and it seems this is a feature that Laravel doesn't support.
They suggest using php artisan test --parallel instead, but it broke my tests.

Reference: laravel/framework#49237 (comment)

@SimplyCorey
Copy link

Does anyone know how to begin to debug this? I've tried adding the --debug flag to phpunit and it is not producing anything useful.

This is definitely related to Laravel, but they do not have any desire to resolve the issue on PHP 8.3.

The stdout is returning an empty string within processChildResult. I've looked into the pipes within DefaultPhpProcess and they are all empty as well.

@arclw
Copy link

arclw commented Jan 19, 2024

The problem is not with PHPUnit itself. I have tried the annotation @runInSeparateProcess with PHP Unit's framework class i.e: \PHPUnit\Framework\TestCase everything is working in PHP 8.2 and 8.3, while when used Laravel's base test class i.e: Tests\TestCase; it works in PHP 8.2 but NOT in 8.3. So yes it is definitely Laravel.

siketyan added a commit to siketyan/phpunit that referenced this issue Jan 23, 2024
siketyan added a commit to siketyan/phpunit that referenced this issue Jan 23, 2024
siketyan added a commit to siketyan/phpunit that referenced this issue Jan 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature/process-isolation Issues related to running tests in separate PHP processes status/waiting-for-feedback Waiting for feedback from original reporter type/bug Something is broken version/10 Something affects PHPUnit 10
Projects
None yet
Development

No branches or pull requests

4 participants