Problem/Motivation

Seeing some random test failures, where PHPUnit is scanning files while another parallel test is deleting them:

    PHPUnit 12.5.14 by Sebastian Bergmann and contributors.
    
    Runtime:       PHP 8.5.4
    Configuration: /builds/core/phpunit.xml.dist
    
    
    
    An error occurred inside PHPUnit.
    
    Message:  RecursiveDirectoryIterator::__construct(/builds/sites/simpletest/13584946/files/php/twig/69ca72874479d_user.html.twig_nHF3iSucuBhDPmnpoGBzlxXuk): Failed to open directory: No such file or directory
    Location: /builds/vendor/phpunit/php-file-iterator/src/ExcludeIterator.php:67
    
    #0 [internal function]: RecursiveDirectoryIterator->__construct('/builds/sites/s...', 20480)
    #1 /builds/vendor/phpunit/php-file-iterator/src/ExcludeIterator.php(67): RecursiveDirectoryIterator->getChildren()
    #2 [internal function]: SebastianBergmann\FileIterator\ExcludeIterator->getChildren()
    #3 [internal function]: FilterIterator->next()
    #4 /builds/vendor/phpunit/php-file-iterator/src/Facade.php(36): AppendIterator->next()
    #5 /builds/vendor/phpunit/phpunit/src/TextUI/Configuration/SourceMapper.php(83): SebastianBergmann\FileIterator\Facade->getFilesAsArray('/builds/core/.....', Array, Array)
    #6 /builds/vendor/phpunit/phpunit/src/TextUI/Configuration/SourceMapper.php(35): PHPUnit\TextUI\Configuration\SourceMapper->map(Object(PHPUnit\TextUI\Configuration\Source))
    #7 /builds/vendor/phpunit/phpunit/src/Framework/TestRunner/SeparateProcessTestRunner.php(173): PHPUnit\TextUI\Configuration\SourceMapper::saveTo('/tmp/phpunit_uk...', Object(PHPUnit\TextUI\Configuration\Source))
    #8 /builds/vendor/phpunit/phpunit/src/Framework/TestRunner/SeparateProcessTestRunner.php(107): PHPUnit\Framework\SeparateProcessTestRunner->sourceMapFileForChildProcess()
    #9 /builds/vendor/phpunit/phpunit/src/Framework/TestRunner/IsolatedTestRunnerRegistry.php(27): PHPUnit\Framework\SeparateProcessTestRunner->run(Object(Drupal\Tests\help\Functional\NoHelpTest), false, false, false)
    #10 /builds/vendor/phpunit/phpunit/src/Framework/TestCase.php(367): PHPUnit\Framework\IsolatedTestRunnerRegistry::run(Object(Drupal\Tests\help\Functional\NoHelpTest), false, false, false)
    #11 /builds/vendor/phpunit/phpunit/src/Framework/TestSuite.php(374): PHPUnit\Framework\TestCase->run()
    #12 /builds/vendor/phpunit/phpunit/src/TextUI/TestRunner.php(64): PHPUnit\Framework\TestSuite->run()
    #13 /builds/vendor/phpunit/phpunit/src/TextUI/Application.php(229): PHPUnit\TextUI\TestRunner->run(Object(PHPUnit\TextUI\Configuration\Configuration), Object(PHPUnit\Runner\ResultCache\NullResultCache), Object(PHPUnit\Framework\TestSuite))
    #14 /builds/vendor/phpunit/phpunit/phpunit(104): PHPUnit\TextUI\Application->run(Array)

Steps to reproduce

Proposed resolution

PHPUnit should not need to scan sites/simpletest. Figure out how to prevent this.

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-3582249

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

longwave created an issue. See original summary.

longwave’s picture

I think the problem here is:

  <source ignoreSuppressionOfDeprecations="true">
    <include>
      <directory>../sites</directory>
    </include>

Do we need to scan ../sites at all for code coverage? Or should we just exclude ../sites/simpletest?

longwave’s picture

Status: Active » Needs review

I don't think there is any reason to scan ../sites so let's not include it in the first place.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Please! This one pops up so much.

  • catch committed 3753f904 on 11.x
    fix: #3582249 [random test failure] PHPUnit scans sites/simpletest while...

  • catch committed 49aa96c0 on main
    fix: #3582249 [random test failure] PHPUnit scans sites/simpletest while...
catch’s picture

Version: main » 11.x-dev
Status: Reviewed & tested by the community » Fixed

I wonder if this was originally put in there to find coverage for modules in sites/default, sites/SITENAME etc but we don't have that in core and those are also no longer recommended locations for modules apart from multisite situations anyway, definitely doesn't need to be in core phpunit.xml

Committed/pushed to main and 11.x, thanks!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

mondrake’s picture

Strange… why would these directories be parsed in test runs that do not calculate code coverage?

longwave’s picture

The source map is parsed before the test itself is run in SeparateProcessTestRunner::run() - as to why that's needed, probably a question for upstream.

smustgrave’s picture

I only started seeing this random failure after the gitlab update where the permissions got all screwed up

mondrake’s picture

Actually I think since PHPUnit 12 bump there have been more of these. Let's see if this impacts.

Thanks @longwave for #12, yes it seems an upstream thing.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.