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

@runTestsInSeparateProcesses results in infinite loop when installed with Composer ^2.2 #4847

Closed
rdarcy1 opened this issue Dec 23, 2021 · 3 comments
Labels
feature/process-isolation Issues related to running tests in separate PHP processes installation/composer type/bug Something is broken

Comments

@rdarcy1
Copy link
Sponsor

rdarcy1 commented Dec 23, 2021

Q A
PHPUnit version 9.5.10
PHP version 8.0.13
Installation Method Composer 2.2.0, 2.21

Summary

After composer install with composer 2.2.0 or 2.2.1, running a PHPUnit test with separate process flag results in an infinite loop. Possibly related to #4835?

Apologies if this is an issue with Composer rather than PHPUnit. I know there were a few reported issues with the Composer 2.2.0 release, but I think they've been marked resolved with the 2.2.1 patch? E.g. composer/composer#10387

Current behavior

PHPUnit appears to keep spawning new child processes. Keeps looping and consuming memory until terminated.

How to reproduce

Ensure no vendor directory exists.
Install composer 2.2.0 or 2.2.1 and composer install:

curl -sS https://getcomposer.org/installer | php -- --filename=composer --version=2.2.1
./composer install

composer.json:

{
    "name": "robin/phpunit_separate_process_test",
    "require-dev": {
        "phpunit/phpunit": "^9.0"
    }
}

MyTest.php

<?php

use PHPUnit\Framework\TestCase;

/** @runTestsInSeparateProcesses */
class MyTest extends TestCase
{
    /** @test */
    public function aTest()
    {
        $this->assertTrue(true);
    }
}

phpunit.xml (created using --generate-configuration)

<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
         bootstrap="vendor/autoload.php"
         cacheResultFile=".phpunit.cache/test-results"
         executionOrder="depends,defects"
         forceCoversAnnotation="true"
         beStrictAboutCoversAnnotation="true"
         beStrictAboutOutputDuringTests="true"
         beStrictAboutTodoAnnotatedTests="true"
         convertDeprecationsToExceptions="true"
         failOnRisky="true"
         failOnWarning="true"
         verbose="true">
    <testsuites>
        <testsuite name="default">
            <directory>tests</directory>
        </testsuite>
    </testsuites>
</phpunit>

Run tests:

vendor/bin/phpunit --debug

Expected behavior

Tests should run to completion (as is the case with composer 2.1.14).

@rdarcy1 rdarcy1 added the type/bug Something is broken label Dec 23, 2021
@sebastianbergmann
Copy link
Owner

@Seldaek Is this fixed by #4846?

@sebastianbergmann sebastianbergmann added feature/process-isolation Issues related to running tests in separate PHP processes installation/composer labels Dec 23, 2021
@Seldaek
Copy link
Contributor

Seldaek commented Dec 23, 2021

If using the latest composer snapshot (composer selfupdate --snapshot) then removing vendor/bin/phpunit and running composer install fixes it then yes most likely it's fixed by #4846

@rdarcy1
Copy link
Sponsor Author

rdarcy1 commented Dec 23, 2021

Can confirm it's fixed for me with composer selfupdate --snapshot. Sorry didn't see your PR, thanks for the speedy fix.

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 installation/composer type/bug Something is broken
Projects
None yet
Development

No branches or pull requests

3 participants