ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r722967 - in /ant/core/trunk: WHATSNEW docs/manual/CoreTasks/dependset.html src/main/org/apache/tools/ant/taskdefs/DependSet.java src/tests/antunit/taskdefs/dependset-test.xml
Date Wed, 03 Dec 2008 16:53:34 GMT
Author: bodewig
Date: Wed Dec  3 08:53:33 2008
New Revision: 722967

URL: http://svn.apache.org/viewvc?rev=722967&view=rev
Log:
some assertions on dependset's logging

Modified:
    ant/core/trunk/WHATSNEW
    ant/core/trunk/docs/manual/CoreTasks/dependset.html
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/DependSet.java
    ant/core/trunk/src/tests/antunit/taskdefs/dependset-test.xml

Modified: ant/core/trunk/WHATSNEW
URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=722967&r1=722966&r2=722967&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Wed Dec  3 08:53:33 2008
@@ -586,6 +586,10 @@
    as nested element of <zip> and friends.
    Bugzilla Report 46257.
 
+ * <dependset> has a new verbose attribute that makes the task list
+   all deleted targets and give a hint as to why it deleted them.
+   Bugzilla Report 13681.
+
 Changes from Ant 1.7.0 TO Ant 1.7.1
 =============================================
 

Modified: ant/core/trunk/docs/manual/CoreTasks/dependset.html
URL: http://svn.apache.org/viewvc/ant/core/trunk/docs/manual/CoreTasks/dependset.html?rev=722967&r1=722966&r2=722967&view=diff
==============================================================================
--- ant/core/trunk/docs/manual/CoreTasks/dependset.html (original)
+++ ant/core/trunk/docs/manual/CoreTasks/dependset.html Wed Dec  3 08:53:33 2008
@@ -59,9 +59,19 @@
 
 <h3>Parameters</h3>
 
-<p>
-(none)
-</p>
+<table border="1" cellpadding="2" cellspacing="0">
+  <tr>
+    <td valign="top"><b>Attribute</b></td>
+    <td valign="top"><b>Description</b></td>
+    <td valign="top" align="center"><b>Required</b></td>
+  </tr>
+  <tr>
+    <td valign="top">verbose</td>
+    <td valign="top">Makes the task list all deleted targets files
+      and the reason why they get deleted.</td>
+    <td align="center" valign="top" rowspan="2">No</td>
+  </tr>
+</table>
 
 <h3>Parameters Specified as Nested Elements</h3>
 

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/DependSet.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/DependSet.java?rev=722967&r1=722966&r2=722967&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/DependSet.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/DependSet.java Wed Dec  3 08:53:33
2008
@@ -19,6 +19,7 @@
 package org.apache.tools.ant.taskdefs;
 
 import java.io.File;
+import java.util.Date;
 import java.util.Iterator;
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Project;
@@ -119,6 +120,8 @@
     private Union sources = null;
     private Path targets = null;
 
+    private boolean verbose;
+
     /**
      * Create a nested sources element.
      * @return a Union instance.
@@ -170,6 +173,19 @@
     }
 
     /**
+     * In verbose mode missing targets and sources as well as the
+     * modification times of the newest source and latest target will
+     * be logged as info.
+     *
+     * <p>All deleted files will be logged as well.</p>
+     *
+     * @since Ant 1.8.0
+     */
+    public void setVerbose(boolean b) {
+        verbose = b;
+    }
+
+    /**
      * Execute the task.
      * @throws BuildException if errors occur.
      */
@@ -185,6 +201,12 @@
         //no sources = nothing to compare; no targets = nothing to delete:
         if (sources.size() > 0 && targets.size() > 0 && !uptodate(sources,
targets)) {
            log("Deleting all target files.", Project.MSG_VERBOSE);
+           if (verbose) {
+               String[] t = targets.list();
+               for (int i = 0; i < t.length; i++) {
+                   log("Deleting " + t[i]);
+               }
+           }
            Delete delete = new Delete();
            delete.bindToOwner(this);
            delete.add(targets);
@@ -202,23 +224,27 @@
         datesel.setGranularity(0);
         logFuture(targets, datesel);
 
-        int neTargets = new NonExistent(targets).size();
+        NonExistent missingTargets = new NonExistent(targets);
+        int neTargets = missingTargets.size();
         if (neTargets > 0) {
             log(neTargets + " nonexistent targets", Project.MSG_VERBOSE);
+            logMissing(missingTargets, "target");
             return false;
         }
         Resource oldestTarget = getOldest(targets);
-        log(oldestTarget + " is oldest target file", Project.MSG_VERBOSE);
+        logWithModificationTime(oldestTarget, "oldest target file");
 
         logFuture(sources, datesel);
 
-        int neSources = new NonExistent(sources).size();
+        NonExistent missingSources = new NonExistent(sources);
+        int neSources = missingSources.size();
         if (neSources > 0) {
             log(neSources + " nonexistent sources", Project.MSG_VERBOSE);
+            logMissing(missingSources, "source");
             return false;
         }
         Resource newestSource = (Resource) getNewest(sources);
-        log(newestSource.toLongString() + " is newest source", Project.MSG_VERBOSE);
+        logWithModificationTime(newestSource, "newest source");
         return oldestTarget.getLastModified() >= newestSource.getLastModified();
     }
 
@@ -255,4 +281,18 @@
         return getXest(rc, DATE);
     }
 
+    private void logWithModificationTime(Resource r, String what) {
+        log(r.toLongString() + " is " + what + ", modified at "
+            + new Date(r.getLastModified()),
+            verbose ? Project.MSG_INFO : Project.MSG_VERBOSE);
+    }
+
+    private void logMissing(ResourceCollection missing, String what) {
+        if (verbose) {
+            for (Iterator i = missing.iterator(); i.hasNext(); ) {
+                Resource r = (Resource) i.next();
+                log("Expected " + what + " " + r.toLongString() + " is missing.");
+            }
+        }
+    }
 }

Modified: ant/core/trunk/src/tests/antunit/taskdefs/dependset-test.xml
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/taskdefs/dependset-test.xml?rev=722967&r1=722966&r2=722967&view=diff
==============================================================================
--- ant/core/trunk/src/tests/antunit/taskdefs/dependset-test.xml (original)
+++ ant/core/trunk/src/tests/antunit/taskdefs/dependset-test.xml Wed Dec  3 08:53:33 2008
@@ -54,6 +54,8 @@
       <srcfilelist dir="${input}" files="test4.tmp" />
       <targetfileset id="targetfs" dir="${output}" includes="i-do-not-exist" />
     </dependset>
+    <au:assertLogDoesntContain text="Deleting all target files."
+                               level="verbose"/>
   </target>
 
   <target name="testMoreRecentSourceFile" depends="setUp">
@@ -64,6 +66,12 @@
       <srcfilelist dir="${input}" files="newer.tmp" />
       <targetfilelist dir="${output}" files="older.tmp" />
     </dependset>
+    <!--au:assertLogContains text="older.tmp&quot; is oldest target file"
+                          level="verbose"/-->
+    <au:assertLogContains text="newer.tmp&quot; is newest source"
+                          level="verbose"/>
+    <au:assertLogContains text="Deleting all target files."
+                          level="verbose"/>
     <au:assertFileDoesntExist file="${output}/older.tmp"/>
   </target>
 
@@ -82,6 +90,12 @@
         <filelist dir="${output}/" files="targetset_1.tmp,targetset_2.tmp" />
       </targets>
     </dependset>
+    <!--au:assertLogContains text="targetset_1&quot; is oldest target file"
+                          level="verbose"/-->
+    <au:assertLogContains text="sourceset_2.tmp&quot; is newest source"
+                          level="verbose"/>
+    <au:assertLogContains text="Deleting all target files."
+                          level="verbose"/>
     <au:assertFileDoesntExist file="${output}/targetset_1.tmp" />
     <au:assertFileDoesntExist file="${output}/targetset_2.tmp" />
   </target>
@@ -96,6 +110,10 @@
         <filelist dir="${output}" files="older.tmp" />
       </targets>
     </dependset>
+    <au:assertLogContains text="1 nonexistent sources"
+                          level="verbose"/>
+    <au:assertLogContains text="Deleting all target files."
+                          level="verbose"/>
     <au:assertFileDoesntExist file="${output}/older.tmp" />
   </target>
 
@@ -110,6 +128,8 @@
         <filelist dir="${output}" files="older.tmp" />
       </targets>
     </dependset>
+    <au:assertLogDoesntContain text="Deleting all target files."
+                               level="verbose"/>
     <au:assertFileExists file="${output}/older.tmp" />
   </target>
 
@@ -122,6 +142,8 @@
       <srcfileset dir="." includes="test9.tmp" />
       <targetfileset dir="${output}/test9dir" />
     </dependset>
+    <au:assertLogDoesntContain text="Deleting all target files."
+                               level="verbose"/>
   </target>
 
 </project>



Mime
View raw message