Skip to content

Reading from non-existent file test-results in cache folder #5764

@cracksalad

Description

@cracksalad
Q A
PHPUnit version 10.5.13 and 10.5.14
PHP version 8.1.26, 8.2.13, 8.3.0
Installation Method PHAR (phive)

Summary

Best description is probably the exception itself:

PHPUnit 10.5.13 by Sebastian Bergmann and contributors.
Runtime:       PHP 8.3.0 with Xdebug 3.3.0
Configuration: /builds/x/y/phpunit.xml
An error occurred inside PHPUnit.
Message:  file_get_contents(/builds/x/y/.phpunit.cache/test-results): Failed to open stream: No such file or directory
Location: phar:///builds/x/y/tools/phpunit/phpunit/Runner/ResultCache/DefaultResultCache.php:78
#0 phar:///builds/x/y/tools/phpunit/phpunit/Runner/ResultCache/DefaultResultCache.php(78): file_get_contents('/builds/x/y...')
#1 phar:///builds/x/y/tools/phpunit/phpunit/TextUI/TestRunner.php(37): PHPUnit\Runner\ResultCache\DefaultResultCache->load()
#2 phar:///builds/x/y/tools/phpunit/phpunit/TextUI/Application.php(146): PHPUnit\TextUI\TestRunner->run(Object(PHPUnit\TextUI\Configuration\Configuration), Object(PHPUnit\Runner\ResultCache\DefaultResultCache), Object(PHPUnit\Framework\TestSuite))
#3 /builds/x/y/tools/phpunit(3002): PHPUnit\TextUI\Application->run(Array)
#4 {main}

Although this snippet shows the result with PHP 8.3.0 and PHPUnit 10.5.13, the same problem is observed using the version combinations stated above.

Current behavior

See Summary

How to reproduce

  1. Delete your .phpunit.cache folder
  2. Run PHPUnit

The cache folder does not exist in CI pipelines e.g. in GitLab (at least if you do not push it to your repo).

Expected behavior

I guess there should be a check, if the file exists before reading it. The problem could also be, that the file should have been created before it is read.

Additional Information

PHPUnit 10.5.10 and 10.5.12 work fine. I did not test other versions yet.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/bugSomething is broken

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions