ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r566707 - in /ant/core/trunk/src: main/org/apache/tools/ant/taskdefs/Pack.java tests/antunit/taskdefs/gzip-test.xml
Date Thu, 16 Aug 2007 13:33:01 GMT
Author: jkf
Date: Thu Aug 16 06:33:00 2007
New Revision: 566707

URL: http://svn.apache.org/viewvc?view=rev&rev=566707
Log:
Pr 43016 improved error reporting on nothing to compress.

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

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Pack.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Pack.java?view=diff&rev=566707&r1=566706&r2=566707
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Pack.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Pack.java Thu Aug 16 06:33:00 2007
@@ -88,9 +88,14 @@
      * @param a the resource to pack as a single element Resource collection.
      */
     public void addConfigured(ResourceCollection a) {
+        if (a.size() == 0) {
+            throw new BuildException("No resource selected, " + getTaskName()
+                    + " needs exactly one resource.");
+        }
         if (a.size() != 1) {
-            throw new BuildException("only single argument resource collections"
-                                     + " are supported as archives");
+            throw new BuildException(getTaskName()
+                    + " cannot handle multiple resources at once. (" + a.size()
+                    + " resources were selected.)");
         }
         setSrcResource((Resource) a.iterator().next());
     }

Added: ant/core/trunk/src/tests/antunit/taskdefs/gzip-test.xml
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/taskdefs/gzip-test.xml?view=auto&rev=566707
==============================================================================
--- ant/core/trunk/src/tests/antunit/taskdefs/gzip-test.xml (added)
+++ ant/core/trunk/src/tests/antunit/taskdefs/gzip-test.xml Thu Aug 16 06:33:00 2007
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="utf-8"?>
+<project default="antunit" xmlns:au="antlib:org.apache.ant.antunit">
+
+    <!-- note relies on antunit built from svn trunk (1.1-alpha) -->
+    <import file="../antunit-base.xml" />
+
+    <target name="setUp">
+        <mkdir dir="${java.io.tmpdir}/gzip-test" />
+        <mkdir dir="${java.io.tmpdir}/gzip-test/empty" />
+        <touch file="${java.io.tmpdir}/gzip-test/fileone" />
+        <touch file="${java.io.tmpdir}/gzip-test/filetwo" />
+    </target>
+
+    <target name="tearDown">
+        <delete includeemptydirs="true">
+            <fileset dir="${java.io.tmpdir}/gzip-test" />
+        </delete>
+    </target>
+
+    <target name="testFailNone">
+        <au:expectfailure expectedmessage="No resource selected, gzip needs exactly one
resource." message="Should have thrown an exception">
+            <gzip destfile="${java.io.tmpdir}/gzip-test/file.gz">
+                <fileset dir="${java.io.tmpdir}/gzip-test/empty" />
+            </gzip>
+        </au:expectfailure>
+    </target>
+
+    <target name="testFailTwo">
+        <au:expectfailure expectedmessage="gzip cannot handle multiple resources at once.
(2 resources were selected.)" message="Should have thrown an exception">
+            <gzip destfile="${java.io.tmpdir}/gzip-test/file.gz">
+                <fileset dir="${java.io.tmpdir}/gzip-test" />
+            </gzip>
+        </au:expectfailure>
+    </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