ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Rees <d.ree...@usa.net>
Subject [PATCH] Bug 564
Date Tue, 20 Feb 2001 07:21:41 GMT
Patches to fix Bug 564 (as per updated Bugzilla comments):

Correct typo in new Zip test case (tar -> zip)
Add Zip test case for zipping target when target file doesn't already
exist
Zip task patched to properly catch additional test case


Index: jakarta-ant/src/etc/testcases/taskdefs/zip.xml
===================================================================
RCS file:
/home/cvspublic/jakarta-ant/src/etc/testcases/taskdefs/zip.xml,v
retrieving revision 1.2.2.1
diff -u -r1.2.2.1 zip.xml
--- jakarta-ant/src/etc/testcases/taskdefs/zip.xml	2001/02/19
13:30:06	1.2.2.1
+++ jakarta-ant/src/etc/testcases/taskdefs/zip.xml	2001/02/20
07:20:36
@@ -10,13 +10,24 @@
     <zip zipfile="zip.tmp"/>
   </target>
 
+  <!-- Test when the zip file includes itself
+  when target file exists before the zip task is run -->
   <target name="test3">
     <touch file="test3.zip"/>
-    <tar zipfile="test3.zip"
+    <zip zipfile="test3.zip"
          basedir="."/>
   </target>
-  
-  <target name="cleanup"> 
+
+  <!-- Test when the zip file includes itself
+  when target file does not exist before the zip task is run -->
+  <target name="test4">
+     <zip zipfile="test4.zip"
+         basedir="."/>
+  </target>
+
+
+  <target name="cleanup">
     <delete file="test3.zip"/>
+    <delete file="test4.zip"/>
   </target>
 </project>
Index: jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Zip.java
===================================================================
RCS file:
/home/cvspublic/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Zip.java,v
retrieving revision 1.30.2.1
diff -u -r1.30.2.1 Zip.java
--- jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Zip.java
2001/02/19 13:30:07	1.30.2.1
+++ jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Zip.java
2001/02/20 07:20:37
@@ -334,12 +334,6 @@
                 return true;
             }
         } else {
-            for (int i = 0; i < files.length; ++i) {
-                if (files[i].equals(zipFile)) {
-                    throw new BuildException("A zip file cannot
include itself", location);
-                }
-            }
-
             if (!zipFile.exists()) return false;
 
             SourceFileScanner sfs = new SourceFileScanner(this);
@@ -465,6 +459,10 @@
     protected void zipFile(File file, ZipOutputStream zOut, String
vPath)
         throws IOException
     {
+        if (file.equals(zipFile)) {
+            throw new BuildException("A zip file cannot include
itself", location);
+        }
+
         FileInputStream fIn = new FileInputStream(file);
         try {
             zipFile(fIn, zOut, vPath, file.lastModified());
Index:
jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/ZipTest.java
===================================================================
RCS file:
/home/cvspublic/jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/ZipTest.java,v
retrieving revision 1.2.2.1
diff -u -r1.2.2.1 ZipTest.java
---
jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/ZipTest.java
2001/02/19 13:30:07	1.2.2.1
+++
jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/ZipTest.java
2001/02/20 07:20:39
@@ -78,6 +78,10 @@
     public void test3() { 
         expectBuildException("test3", "zip cannot include itself");
     }
+
+    public void test4() { 
+        expectBuildException("test4", "zip cannot include itself");
+    }
     
     public void tearDown() {
         executeTarget("cleanup");


Mime
View raw message