From phpunit.xml how can I get PHPUnit to not search in .svn directories? On large projects this becomes more of an issue as the number of .svn directories increases.
My current config:
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="phpunit_bootstrap.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
syntaxCheck="true"
verbose="true"
strict="true">
<filter>
<whitelist addUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./phpunit/</directory>
<exclude>
<directory>./phpunit/.svn</directory>
</exclude>
</whitelist>
</filter>
</phpunit>
This seems to be ignored as when I run strace -e open phpunit phpunit/
I see:
open("phpunit/", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY) = 3
open("phpunit/.svn", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY) = 4
open("phpunit/.svn/tmp", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY) = 5
open("phpunit/.svn/tmp/prop-base", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY) = 6
open("phpunit/.svn/tmp/text-base", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY) = 6
open("phpunit/.svn/tmp/props", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY) = 6
open("phpunit/.svn/prop-base", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY) = 5
open("phpunit/.svn/text-base", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY) = 5
open("phpunit/.svn/props", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY) = 5
Is it possible to blacklist .svn directories? Preferably with a wildcard directive so I don't have to specify the absolute path of each .svn dir (eg <directory>.svn</directory>
)
There is currently no way to tell PHPUnit
to not scan directories matching a certain expression or to ignore hidden dirs.
So currently you would have to <exclude>
every single svn dir.
Just to reiterate what is stated in the comments: This is only an issue when working with very slow file systems that take a lot of time for stat and read calls.
This is why I'd assume the use cases are so limited that building a .svn ignore into phpunit is not worthwhile, especially because newer svn versions don't put the dirs everywhere anymore. (See possible solution 2)
Maybe writing a small script that generate the exclude tags from the files isn't to much of an issue
find . | grep -e ".svn$" | sed 's/^/<directory>/' | sed 's/$/<\/directory>/'
will give you a list of all include tags to paste in for example. Or using a small domDocument based script to update the file in place :)
This will store all the meta data in one directory in the project root so there will be no files in your project/tests
folder for phpunit to scan and get rid of the issue.
This may be overkill, but I really wanted a better solution.
Here is a patch for your php\\PEAR\\File\\Iterator\\Factory.php file that is the cause of all this slowness. It skips directories that don't start with a letter or number. Adoped from here .
108,110c108
< new RecursiveIteratorIterator(
< new RecursiveDirectoryIterator($path)
< ),
---
> new RecursiveIteratorIterator(new RecursiveRegexIterator(new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::FOLLOW_SYMLINKS), '=\\\\[a-zA-Z0-9]='), true),
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.