Static Source Path Matching
This PR is a proof-of-concept for statically matching paths without traversing the filesystem during the test run. It replaces #6146 and uses the webmozarts/glob package.
Would fix #6114
The primary goal is to ensure that the source mapper needn't iterate over all included directories recursively whenever the source map is required to validate if a file belongs to the mapped files or not - for example when a deprecation is encountered PHPUnit needs to know if the deprecation was issued from source code within the project's responsiblity - i.e. source that is mapped.
We can determine if a file is within the included source by converting the glob-patterns in the <directory> element to regexes. Currently the <directory> element in <include> and <exclude> has the attributes prefix and suffix and we also have <file> which specifies a single file.
This is more complicated than it could be:
- Current matching/traversal logic depends on PHP's
globfunction - the implementation of which is not consistent across platforms and which has a number of rarely-used operators which while not common, would present a B/C break if they were removed.
We can expect the following breaks in behavior:
- Differences in the more esoteric syntax between the internal
globfunction and thewebmozartslibrary. Note that the behavior ofglobis also dependent on the platform making it hard-to-impossible to lock down the behavior completely (for reference linux man page for glob). - Consequently the behavior of
phpunit/php-file-iteratorwill not exactly match the results of the static matching logic.
Things to consider:
- Making this an experiemental "feature flag"
- Updating the
phpunit/php-file-iteratorto use the same package so as to be consistent. - Implementing the logic within PHPUnit rather than using an external package.
- Documenting the glob syntax.
What is the status of this? Thanks.
Hey, basically this is a proposal - and it should work but would need more time invested in testing, exploring the behavior and perhaps adding more test cases and as above, to consider:
- Should this be a"feature flag"?
- Do we want/need to update the phpunit/php-file-iterator to use the same package so as to be consistent.
- Do we want to use the external package or "vendor" the code within PHPUnit.
- Do we want to document the (new) glob syntax, and I guess, the difference between the old and new.