Browse Source

slow-scan was broken for recursive exclude patterns since contentsExcluded was added about four years ago

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@727993 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 16 years ago
parent
commit
66b7fa5b87
4 changed files with 32 additions and 4 deletions
  1. +5
    -0
      WHATSNEW
  2. +1
    -1
      src/main/org/apache/tools/ant/DirectoryScanner.java
  3. +2
    -2
      src/tests/antunit/taskdefs/sync-test.xml
  4. +24
    -1
      src/tests/junit/org/apache/tools/ant/DirectoryScannerTest.java

+ 5
- 0
WHATSNEW View File

@@ -309,6 +309,11 @@ Fixed bugs:
command failed.
Bugzilla Report 46340.

* DirectoryScanner's slow-scanning algorithm that is used when you
ask for excluded or not-included files and/or directories could
miss some files and directories in the presence of recursive
exclude patterns.

Other changes:
--------------



+ 1
- 1
src/main/org/apache/tools/ant/DirectoryScanner.java View File

@@ -1116,7 +1116,7 @@ public class DirectoryScanner
private void processSlowScan(String[] arr) {
for (int i = 0; i < arr.length; i++) {
TokenizedPath path = new TokenizedPath(arr[i]);
if (!couldHoldIncluded(path)) {
if (!couldHoldIncluded(path) || contentsExcluded(path)) {
scandir(new File(basedir, arr[i]), path, false);
}
}


+ 2
- 2
src/tests/antunit/taskdefs/sync-test.xml View File

@@ -57,7 +57,7 @@
<au:assertFileDoesntExist file="${output}/b/c"/>
</target>

<target name="xtestPreserveEmptyOverridesDefault" depends="setUp">
<target name="testPreserveEmptyOverridesDefault" depends="setUp">

<sync todir="${output}">
<fileset dir="${input}"/>
@@ -72,7 +72,7 @@
<au:assertFileExists file="${output}/b/c"/>
</target>

<target name="xtestPreserveEmptyOverrulesIncludeEmpty" depends="setUp">
<target name="testPreserveEmptyOverrulesIncludeEmpty" depends="setUp">

<sync todir="${output}" includeEmptyDirs="true">
<fileset dir="${input}"/>


+ 24
- 1
src/tests/junit/org/apache/tools/ant/DirectoryScannerTest.java View File

@@ -25,9 +25,11 @@ import org.apache.tools.ant.util.SymbolicLinkUtils;

import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
import java.util.Iterator;

/**
* JUnit 3 testcases for org.apache.tools.ant.DirectoryScanner
@@ -532,4 +534,25 @@ public class DirectoryScannerTest extends BuildFileTest {
}
}

public void testRecursiveExcludes() throws Exception {
DirectoryScanner ds = new DirectoryScanner();
ds.setBasedir(new File(getProject().getBaseDir(), "tmp"));
ds.setExcludes(new String[] {"**/beta/**"});
ds.scan();
List dirs = Arrays.asList(ds.getExcludedDirectories());
assertEquals(2, dirs.size());
assertTrue("beta is excluded",
dirs.contains("alpha/beta".replace('/', File.separatorChar)));
assertTrue("gamma is excluded",
dirs.contains("alpha/beta/gamma".replace('/',
File.separatorChar)));
List files = Arrays.asList(ds.getExcludedFiles());
assertEquals(2, files.size());
assertTrue("beta.xml is excluded",
files.contains("alpha/beta/beta.xml"
.replace('/', File.separatorChar)));
assertTrue("gamma.xml is excluded",
files.contains("alpha/beta/gamma/gamma.xml"
.replace('/', File.separatorChar)));
}
}

Loading…
Cancel
Save