Ticket #544 (closed defect: fixed)
Wrong file set when exclude test/**/** is used
| Reported by: | aigors@… | Owned by: | mrook |
|---|---|---|---|
| Priority: | major | Milestone: | 2.4.5 |
| Component: | phing-core | Version: | 2.4.2 |
| Keywords: | Cc: |
Description
If I have such copy task
<copy todir="c:/tmp/target" includeemptydirs="true" overwrite="true">
<fileset dir="c:/tmp/source" defaultexcludes="true">
<include name="**/**" />
<exclude name=".*" />
<exclude name="test/**/**" />
</fileset>
</copy>
Still it doesn't exclude the "test" folder only, it excludes all folders starting with "test" as well (e.g. "tests"). Is there any workaround for this?
Attachments
Change History
comment:4 Changed 14 months ago by Tim Gerundt
- Status changed from closed to reopened
- Resolution fixed deleted
Mhhh, this fix make problems on Windows''' I have a <fileset> who should exclude the "fckeditor" directory:
<fileset dir="${project.source.dir}">
<include name="**/*.php" />
<exclude name="fckeditor/**" />
</fileset>
DirectoryScanner::matchPath(...) calls now SelectorUtils::matchPath(...) with for example the following parameters:
$pattern = string(12) "fckeditor\**" $str = string(36) "fckeditor\editor\dialog\fck_div.html"
$rePattern looks good at the beginning:
$rePattern = string(15) "fckeditor\\\*\*"
But after str_replace(...) it looks like:
$rePattern = string(17) "/^fckeditor\/.*$/"
And this don't match on a Windows path! :(
Correct would be:
$rePattern = string(17) "/^fckeditor\\.*$/"
Greetings, Tim Gerundt
comment:5 Changed 14 months ago by alexey.borzov@…
Can confirm about problems on Windows, including inability to exclude directories.
The change from
return (bool) preg_match($rePattern, $str);
to
return (bool) preg_match($rePattern, str_replace(DIRECTORY_SEPARATOR, '/', $str));
in SelectorUtils::matchPath() seems to fix the problem. Cannot really check whether it breaks anything else, since unit tests of stock 2.4.4 fail on Windows:
[phpunit] Tests run: 124, Failures: 16, Errors: 43, Incomplete: 0, Skipped: 0, Time elapsed: 16.40935 s
Execution of target "reports" failed for the following reason: E:\work\phing\phing-2.4.4\test\build.xml:56:50: Test FAIL
URE (testFlipFlopTarget in class ImportTaskTest): Expected to find 'This is E:\work\phing\phing-2.4.4\test/etc/tasks/imp
orting.xml flop target.' in logs: array (
0 => 'Build sequence for target \'flipflop\' is: flop flip flipflop ',
1 => 'Complete build sequence is: flop flip flipflop main imported.main cascade imported imported.imported imported.fl
ip imported.flop imported2 imported2.imported2 imported2.main ',
2 => 'Property ${phing.file} => E:\\work\\phing\\phing-2.4.4\\test\\etc\\tasks\\importing.xml',
3 => 'This is E:\\work\\phing\\phing-2.4.4\\test\\etc\\tasks\\importing.xml flop target.',
4 => 'Property ${phing.file.imported} => E:\\work\\phing\\phing-2.4.4\\test\\etc\\tasks\\imports\\imported.xml',
5 => 'This is E:\\work\\phing\\phing-2.4.4\\test\\etc\\tasks\\imports\\imported.xml flip target.',
6 => 'Property ${phing.file} => E:\\work\\phing\\phing-2.4.4\\test\\etc\\tasks\\importing.xml',
7 => 'This is E:\\work\\phing\\phing-2.4.4\\test\\etc\\tasks\\importing.xml flipflop target.',
)
BUILD FAILED
E:\work\phing\phing-2.4.4\test\build.xml:56:50: Test FAILURE (testFlipFlopTarget in class ImportTaskTest): Expected to f
ind 'This is E:\work\phing\phing-2.4.4\test/etc/tasks/importing.xml flop target.' in logs: array (
0 => 'Build sequence for target \'flipflop\' is: flop flip flipflop ',
1 => 'Complete build sequence is: flop flip flipflop main imported.main cascade imported imported.imported imported.fl
ip imported.flop imported2 imported2.imported2 imported2.main ',
2 => 'Property ${phing.file} => E:\\work\\phing\\phing-2.4.4\\test\\etc\\tasks\\importing.xml',
3 => 'This is E:\\work\\phing\\phing-2.4.4\\test\\etc\\tasks\\importing.xml flop target.',
4 => 'Property ${phing.file.imported} => E:\\work\\phing\\phing-2.4.4\\test\\etc\\tasks\\imports\\imported.xml',
5 => 'This is E:\\work\\phing\\phing-2.4.4\\test\\etc\\tasks\\imports\\imported.xml flip target.',
6 => 'Property ${phing.file} => E:\\work\\phing\\phing-2.4.4\\test\\etc\\tasks\\importing.xml',
7 => 'This is E:\\work\\phing\\phing-2.4.4\\test\\etc\\tasks\\importing.xml flipflop target.',
)
comment:6 Changed 14 months ago by pierre.frouge@…
I can confirm the bug : any included or excluded path containing 'myDir\**' no longer works under windows.
Commit 995 changed selectorUtils' line 134 from :
$dirSep.'\*\*' => '\/?.*',
to
$dirSep.'\*\*'.$dirSep => '\/.*\/?', $dirSep.'\*\*' => '\/.*',
Before, thanks to the '?' the trailing '/' was optionnal, now it is mandatory and thus 'myDir\**' patterns no longer match paths like 'myDir\'.
comment:7 Changed 13 months ago by kamazee@…
Confirm the issue in 2.4.4 under Windows (PHP 5.3.4 but that's not really relevant)
As a workaround, I guess, the following could solve the problem. Change lines 134 and 135 of types/selectors/SelectorUtils.php in order to use not just / but escsaped DIRECTORY_SEPARATOR in the regular expression to match a path against.
@@ -131,8 +131,8 @@
$rePattern = preg_quote($pattern, '/');
$dirSep = preg_quote(DIRECTORY_SEPARATOR, '/');
$patternReplacements = array(
- $dirSep.'\*\*'.$dirSep => '\/.*\/?',
- $dirSep.'\*\*' => '\/.*',
+ $dirSep.'\*\*'.$dirSep => $dirSep.'.*'.$dirSep.'?',
+ $dirSep.'\*\*' => $dirSep.'.*',
'\*\*'.$dirSep => '.*',
'\*\*' => '.*',
'\*' => '[^'.$dirSep.']*',
Worked for me as expected, but need to be tested.
comment:10 Changed 13 months ago by mrook
- Status changed from reopened to closed
- Resolution set to fixed
comment:11 Changed 13 months ago by anonymous
- Status changed from closed to reopened
- Resolution fixed deleted
The replacement in line 134 produce a wrong output string under Windows Vista Version 6.0 (Build 6002: Service Pack 2).
For example:
images/**/24*.png => images\\.*\[^\\]24[^\\]*\.png
Possible solution:
134: $dirSep.'\*\*'.$dirSep => $dirSep.'.*('.$dirSep.')?'
comment:12 Changed 11 months ago by Daniel Dimitrov <services@…>
I tested both: http://phing.info/trac/ticket/544#comment:7 http://phing.info/trac/ticket/544#comment:11
They both produced the desired effect - the .svn folders on windows 7 were excluded.
comment:13 Changed 11 months ago by mrook
comment:14 Changed 11 months ago by mrook
- Status changed from reopened to closed
- Resolution set to fixed
