ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r479017 - in /ant/core/trunk: WHATSNEW src/main/org/apache/tools/ant/taskdefs/Delete.java src/tests/antunit/taskdefs/delete-test.xml
Date Fri, 24 Nov 2006 22:02:29 GMT
Author: jkf
Date: Fri Nov 24 14:02:28 2006
New Revision: 479017

URL: http://svn.apache.org/viewvc?view=rev&rev=479017
Log:
Pr 40972 Directory Deletion Dont Work Properly

Added:
    ant/core/trunk/src/tests/antunit/taskdefs/delete-test.xml
Modified:
    ant/core/trunk/WHATSNEW
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Delete.java

Modified: ant/core/trunk/WHATSNEW
URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?view=diff&rev=479017&r1=479016&r2=479017
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Fri Nov 24 14:02:28 2006
@@ -6,6 +6,8 @@
 
 Fixed bugs:
 -----------
+* Directory Deletion Dont Work Properly
+  Bugzilla 40972
 
 * docletpath attribute of javadoc ignored.
   Bugzilla 40900.

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Delete.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Delete.java?view=diff&rev=479017&r1=479016&r2=479017
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Delete.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Delete.java Fri Nov 24 14:02:28
2006
@@ -562,10 +562,14 @@
                 fs = (FileSet) fs.clone();
                 fs.setProject(getProject());
             }
-            resourcesToDelete.add(fs);
-            if (includeEmpty && fs.getDir().isDirectory()) {
-              filesetDirs.add(new ReverseDirs(fs.getDir(),
-                  fs.getDirectoryScanner().getIncludedDirectories()));
+            if (!fs.getDir().isDirectory()) {
+                handle("Directory does not exist:" + fs.getDir());
+            } else {
+                resourcesToDelete.add(fs);
+                if (includeEmpty) {
+                    filesetDirs.add(new ReverseDirs(fs.getDir(), fs
+                            .getDirectoryScanner().getIncludedDirectories()));
+                }
             }
         }
         resourcesToDelete.add(filesetDirs);

Added: ant/core/trunk/src/tests/antunit/taskdefs/delete-test.xml
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/taskdefs/delete-test.xml?view=auto&rev=479017
==============================================================================
--- ant/core/trunk/src/tests/antunit/taskdefs/delete-test.xml (added)
+++ ant/core/trunk/src/tests/antunit/taskdefs/delete-test.xml Fri Nov 24 14:02:28 2006
@@ -0,0 +1,69 @@
+<?xml version="1.0"?>
+
+<project name="delete-test" basedir="." default="all"
+       xmlns:au="antlib:org.apache.ant.antunit">
+  <property name="working.dir" value="working"/>
+  <property name="existing.dir" value="working/exists"/>
+  <property name="nonexistent.dir" value="working/nonexists"/>
+	
+  <target name="all">
+    <au:antunit>
+      <fileset file="${ant.file}"/>
+      <au:plainlistener/>
+    </au:antunit>
+  </target>
+
+
+  <target name="init">
+    <delete dir="${working.dir}"/>
+    <mkdir dir="${working.dir}"/>
+    <mkdir dir="${existing.dir}"/>
+  </target>
+
+  <target name="tearDown">
+    <delete dir="${working.dir}"/>
+  </target>
+
+  <!--test that you can delete a fileset with a nonexistent dir without failure-->
+  <target name="testdelfileset" depends="init">
+    <delete quiet="true" includeEmptyDirs="true">
+       <fileset dir="${nonexistent.dir}"/>
+    </delete>
+
+  	<au:assertFileExists file="${existing.dir}" />
+  		
+    <delete quiet="true" includeEmptyDirs="true">
+       <fileset dir="${existing.dir}"/>
+    </delete>
+
+  	<au:assertFileDoesntExist file="${existing.dir}" />
+
+  	
+    <mkdir dir="${existing.dir}"/>
+
+    <delete quiet="true" includeEmptyDirs="true">
+       <fileset dir="${nonexistent.dir}"/>
+       <fileset dir="${existing.dir}"/>
+    </delete>
+
+
+  	<au:assertFileDoesntExist file="${existing.dir}" />
+  	<!--
+    <available file="dir_exists" type="dir" property="delete.dir.failed"/>
+    <fail message="Failed to delete directory (2)" if="delete.dir.failed"/>
+-->
+  	
+  	
+    <mkdir dir="${existing.dir}"/>
+
+    <delete quiet="true" includeEmptyDirs="true">
+       <fileset dir="${existing.dir}"/>
+       <fileset dir="${nonexistent.dir}"/>
+    </delete>
+
+
+  	<au:assertFileDoesntExist file="${existing.dir}" />
+
+  </target>
+
+</project>



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message