Skip to content

Explicitly add inaccessible files into 'blackListedFiles'  #225

@weynhamz

Description

@weynhamz

I use vfsstram to set up a virtual file system stucture to run tests, when apply code coverage on these tests, the virtal path 'vfs://..' can not be handled by php-code-coverage. it causes PHP_CodeCoverage_Report_Factory::reducepaths behave strangely, you can test it by feeding array('vfs:://somepath' => 'content', '/tmp/' => 'content') to it, leading to the top directory become ''.

But when I ran the tests with 'phpunit.phar' instead of 'verdor/bin/phpunit' which is installed by composer, it is very interesting that all these 'vfs://...' paths were successfully filtered, so I digged into the code, and it turns out that when run with 'phpunit.phar', code $this->whitelistedFiles[realpath($filename)] = true; from PHP_CodeCoverage_Filter::addFileToBlacklist will add 0 => TRUE for file inside 'phpunit.phar' into the 'blackListedFiles', then in the PHP_CodeCoverage_Filter::isFiltered method will return TURE for all inaccessible files, including the 'vfs://..' files.

So, I suggested It would be better to explicitly add a 0 => TRUE into 'blackListedFiles' with a proper comment, so that no implicit behavior here.

Or, please provide a way to exclude 'vfs://...' type of files.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions