Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ExcludeList::addDirectory() does not work correctly #5022

Closed
eis-os opened this issue Jul 22, 2022 · 0 comments
Closed

ExcludeList::addDirectory() does not work correctly #5022

eis-os opened this issue Jul 22, 2022 · 0 comments
Assignees
Labels
type/bug Something is broken

Comments

@eis-os
Copy link

eis-os commented Jul 22, 2022

Q A
PHPUnit version 9.5.10
PHP version 8.1.2
Installation Method Composer

Summary

PHPUnit\Util\ExcludeList won’t initialize correctly when static addDirectory is called before a class instance was created.

This interface is required to create new custom asserts without showing internals in the stacktrace.
As introduced and described in #4186

Current behavior

PHPUnit\Util\ExcludeList::addDirectory won’t initialize ExcludeList ::$directories correctly.

All Tracebacks show PHPUnit classes after using this interface

How to reproduce

PHPUnit\Util\ExcludeList::addDirectory(__DIR__);

Failing assert shows a long stacktrace with files in
/vendor/phpunit/phpunit/src/

Workaround:

$excludeList = new \PHPUnit\Util\ExcludeList();
if (!$excludeList->isExcluded(__FILE__)) {
// Add directory after initialize ExcludeList::$directories via isExcluded
\PHPUnit\Util\ExcludeList::addDirectory(__DIR__);
}

Expected behavior

PHPUnit\Util\ExcludeList::addDirectory($directory);

should be in the compatibility promise and ExcludeList will initialize itself properly,
Later tracebacks won’t show PHPUnit internal files and user added directories.

As the backward compatibility promise isn’t clear, please provide a stable interface.

(As there isn't a static function to check the directories, it would be nice if a directory won't be added as duplicate to the internal list)

@eis-os eis-os added the type/bug Something is broken label Jul 22, 2022
@sebastianbergmann sebastianbergmann changed the title ExcludeList::addDirectory won’t initialize correctly, assert tracebacks will show PHPUnit classes ExcludeList::addDirectory() does not work correctly Aug 13, 2022
@sebastianbergmann sebastianbergmann self-assigned this Aug 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Something is broken
Projects
None yet
Development

No branches or pull requests

2 participants