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
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:
- 3582249-random-test-failure-phpunit
changes, plain diff MR !15284
Comments
Comment #2
longwaveI think the problem here is:
Do we need to scan
../sitesat all for code coverage? Or should we just exclude../sites/simpletest?Comment #4
longwaveI don't think there is any reason to scan
../sitesso let's not include it in the first place.Comment #5
smustgrave commentedPlease! This one pops up so much.
Comment #8
catchI 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!
Comment #11
mondrakeStrange… why would these directories be parsed in test runs that do not calculate code coverage?
Comment #12
longwaveThe source map is parsed before the test itself is run in
SeparateProcessTestRunner::run()- as to why that's needed, probably a question for upstream.Comment #13
smustgrave commentedI only started seeing this random failure after the gitlab update where the permissions got all screwed up
Comment #14
mondrakeActually 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.