ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r727993 - in /ant/core/trunk: WHATSNEW src/main/org/apache/tools/ant/DirectoryScanner.java src/tests/antunit/taskdefs/sync-test.xml src/tests/junit/org/apache/tools/ant/DirectoryScannerTest.java
Date Fri, 19 Dec 2008 10:18:17 GMT
Author: bodewig
Date: Fri Dec 19 02:18:16 2008
New Revision: 727993

URL: http://svn.apache.org/viewvc?rev=727993&view=rev
Log:
slow-scan was broken for recursive exclude patterns since contentsExcluded was added about
four years ago

Modified:
    ant/core/trunk/WHATSNEW
    ant/core/trunk/src/main/org/apache/tools/ant/DirectoryScanner.java
    ant/core/trunk/src/tests/antunit/taskdefs/sync-test.xml
    ant/core/trunk/src/tests/junit/org/apache/tools/ant/DirectoryScannerTest.java

Modified: ant/core/trunk/WHATSNEW
URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=727993&r1=727992&r2=727993&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Fri Dec 19 02:18:16 2008
@@ -309,6 +309,11 @@
    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:
 --------------
 

Modified: ant/core/trunk/src/main/org/apache/tools/ant/DirectoryScanner.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/DirectoryScanner.java?rev=727993&r1=727992&r2=727993&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/DirectoryScanner.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/DirectoryScanner.java Fri Dec 19 02:18:16
2008
@@ -1116,7 +1116,7 @@
     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);
             }
         }

Modified: ant/core/trunk/src/tests/antunit/taskdefs/sync-test.xml
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/taskdefs/sync-test.xml?rev=727993&r1=727992&r2=727993&view=diff
==============================================================================
--- ant/core/trunk/src/tests/antunit/taskdefs/sync-test.xml (original)
+++ ant/core/trunk/src/tests/antunit/taskdefs/sync-test.xml Fri Dec 19 02:18:16 2008
@@ -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}"/>

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/DirectoryScannerTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/DirectoryScannerTest.java?rev=727993&r1=727992&r2=727993&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/DirectoryScannerTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/DirectoryScannerTest.java Fri Dec
19 02:18:16 2008
@@ -25,9 +25,11 @@
 
 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 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)));
+    }
 }



Mime
View raw message