Skip to content

Deprecations cause SourceMapper to scan all <source/> files #6111

@dantleech

Description

@dantleech
Q A
PHPUnit version 11.5.3
PHP version 8.3
Installation Method PHAR + Composer

Summary

Hi 👋

When deprecations are encountered the SouceMapper recursively scans all files for each <source> include and exclude paths.

This causes a siginficant pause in PHPUnit as it scans all these files, initially for 16 seconds until we isolated the issue and refined the <source> list - now it's "only" 3 seconds.

Current behavior

Scans all files when a deprecation is encountered.

How to reproduce

Add a <source> configuration:

    <source>
        <include>
            <directory suffix=".php">src/</directory>
            <directory suffix=".php">perhaps-another-directory-here/</directory>
        </include>
        <exclude>
            <directory suffix=".php">src/SubFolder</directory>
            <!-- maybe serveral more here -->
        </exclude>
    </source>
  • Run a test that would trigger a deprecation
  • Observe that source mapper will recursively iterate over all the files in the above paths.

https://github.com/sebastianbergmann/phpunit/blob/main/src/Runner/ErrorHandler.php#L178

Expected behavior

That a triggered deprecation would not scan all the files and block the test run for N seconds.

Metadata

Metadata

Labels

feature/test-runnerCLI test runnertype/performanceIssues related to resource consumption (time and memory)version/11Something affects PHPUnit 11version/12Something affects PHPUnit 12

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions