Author: jglick
Date: Wed Jul 26 15:15:12 2006
New Revision: 425875

URL: http://svn.apache.org/viewvc?rev=425875&view=rev
Log:
Expressing a <dirset> as a string should show matching dirs, not files!

Modified:
    ant/core/trunk/src/main/org/apache/tools/ant/types/DirSet.java
    ant/core/trunk/src/testcases/org/apache/tools/ant/types/DirSetTest.java

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/DirSet.java
URL: 
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/DirSet.java?rev=425875&r1=425874&r2=425875&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/DirSet.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/DirSet.java Wed Jul 26 
15:15:12 2006
@@ -18,7 +18,7 @@
 package org.apache.tools.ant.types;
 
 import java.util.Iterator;
-
+import org.apache.tools.ant.DirectoryScanner;
 import org.apache.tools.ant.types.resources.FileResourceIterator;
 
 /**
@@ -89,6 +89,25 @@
      */
     public boolean isFilesystemOnly() {
         return true;
+    }
+
+    /**
+     * Returns included directories as a list of semicolon-separated paths.
+     *
+     * @return a <code>String</code> of included directories.
+     */
+    public String toString() {
+        DirectoryScanner ds = getDirectoryScanner(getProject());
+        String[] dirs = ds.getIncludedDirectories();
+        StringBuffer sb = new StringBuffer();
+
+        for (int i = 0; i < dirs.length; i++) {
+            if (i > 0) {
+                sb.append(';');
+            }
+            sb.append(dirs[i]);
+        }
+        return sb.toString();
     }
 
 }

Modified: 
ant/core/trunk/src/testcases/org/apache/tools/ant/types/DirSetTest.java
URL: 
http://svn.apache.org/viewvc/ant/core/trunk/src/testcases/org/apache/tools/ant/types/DirSetTest.java?rev=425875&r1=425874&r2=425875&view=diff
==============================================================================
--- ant/core/trunk/src/testcases/org/apache/tools/ant/types/DirSetTest.java 
(original)
+++ ant/core/trunk/src/testcases/org/apache/tools/ant/types/DirSetTest.java Wed 
Jul 26 15:15:12 2006
@@ -17,6 +17,8 @@
 
 package org.apache.tools.ant.types;
 
+import java.io.File;
+import java.io.FileOutputStream;
 import org.apache.tools.ant.BuildException;
 
 /**
@@ -39,7 +41,7 @@
         FileSet fs = new FileSet();
         fs.setProject(getProject());
         getProject().addReference("dummy", fs);
-        ds.setRefid(new Reference("dummy"));
+        ds.setRefid(new Reference(getProject(), "dummy"));
         try {
             ds.getDir(getProject());
             fail("DirSet created from FileSet reference");
@@ -50,13 +52,31 @@
         ds = (DirSet) getInstance();
         ds.setProject(getProject());
         getProject().addReference("dummy2", ds);
-        fs.setRefid(new Reference("dummy2"));
+        fs.setRefid(new Reference(getProject(), "dummy2"));
         try {
             fs.getDir(getProject());
             fail("FileSet created from DirSet reference");
         } catch (BuildException e) {
             assertEquals("dummy2 doesn\'t denote a FileSet", e.getMessage());
         }
+    }
+
+    public void testToString() throws Exception {
+        File tmp = File.createTempFile("DirSetTest", "");
+        tmp.delete();
+        File a = new File(tmp, "a");
+        a.mkdirs();
+        File b = new File(tmp, "b");
+        File bc = new File(b, "c");
+        bc.mkdirs();
+        new FileOutputStream(new File(a, "x")).close();
+        new FileOutputStream(new File(b, "x")).close();
+        new FileOutputStream(new File(bc, "x")).close();
+        DirSet ds = new DirSet();
+        ds.setProject(getProject());
+        ds.setDir(tmp);
+        ds.setIncludes("b/");
+        assertEquals("b;b" + File.separator + "c", ds.toString());
     }
 
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to