ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r433516 - in /ant/antlibs/antunit/trunk/src/main/org/apache/ant/antunit/listener: BaseAntUnitListener.java XMLAntUnitListener.java XMLConstants.java
Date Tue, 22 Aug 2006 04:55:07 GMT
Author: bodewig
Date: Mon Aug 21 21:55:07 2006
New Revision: 433516

URL: http://svn.apache.org/viewvc?rev=433516&view=rev
Log:
improve testsuite-name attribute in XML report

Modified:
    ant/antlibs/antunit/trunk/src/main/org/apache/ant/antunit/listener/BaseAntUnitListener.java
    ant/antlibs/antunit/trunk/src/main/org/apache/ant/antunit/listener/XMLAntUnitListener.java
    ant/antlibs/antunit/trunk/src/main/org/apache/ant/antunit/listener/XMLConstants.java

Modified: ant/antlibs/antunit/trunk/src/main/org/apache/ant/antunit/listener/BaseAntUnitListener.java
URL: http://svn.apache.org/viewvc/ant/antlibs/antunit/trunk/src/main/org/apache/ant/antunit/listener/BaseAntUnitListener.java?rev=433516&r1=433515&r2=433516&view=diff
==============================================================================
--- ant/antlibs/antunit/trunk/src/main/org/apache/ant/antunit/listener/BaseAntUnitListener.java
(original)
+++ ant/antlibs/antunit/trunk/src/main/org/apache/ant/antunit/listener/BaseAntUnitListener.java
Mon Aug 21 21:55:07 2006
@@ -137,17 +137,7 @@
         if (logTo.getValue().equals(SendLogTo.FILE)
             || logTo.getValue().equals(SendLogTo.BOTH)) {
 
-            buildFile = FileUtils.getFileUtils()
-                .removeLeadingPath(getProject().getBaseDir(),
-                                   new File(buildFile));
-            if (buildFile.length() > 0
-                && buildFile.charAt(0) == File.separatorChar) {
-                buildFile = buildFile.substring(1);
-            }
-            
-            String fileName = "TEST-" +
-                buildFile.replace(File.separatorChar, '.').replace(':', '.')
-                + "." + extension;
+            String fileName = "TEST-" + normalize(buildFile) + "." + extension;
             File file = toDir == null
                 ? getProject().resolveFile(fileName)
                 : new File(toDir, fileName);
@@ -161,6 +151,24 @@
             }
         }
         return new TeeOutputStream(l, f);
+    }
+
+    /**
+     * Turns the build file name into something that vaguely looks
+     * like a Java classname.  Close enough to be suitable for
+     * junitreport.
+     */
+    protected final String normalize(String buildFile) {
+        buildFile = FileUtils.getFileUtils()
+            .removeLeadingPath(getProject().getBaseDir(),
+                               new File(buildFile));
+        if (buildFile.length() > 0
+            && buildFile.charAt(0) == File.separatorChar) {
+            buildFile = buildFile.substring(1);
+        }
+
+        return buildFile.replace('.', '_').replace(':', '_')
+            .replace(File.separatorChar, '.');
     }
 
     public static class SendLogTo extends EnumeratedAttribute {

Modified: ant/antlibs/antunit/trunk/src/main/org/apache/ant/antunit/listener/XMLAntUnitListener.java
URL: http://svn.apache.org/viewvc/ant/antlibs/antunit/trunk/src/main/org/apache/ant/antunit/listener/XMLAntUnitListener.java?rev=433516&r1=433515&r2=433516&view=diff
==============================================================================
--- ant/antlibs/antunit/trunk/src/main/org/apache/ant/antunit/listener/XMLAntUnitListener.java
(original)
+++ ant/antlibs/antunit/trunk/src/main/org/apache/ant/antunit/listener/XMLAntUnitListener.java
Mon Aug 21 21:55:07 2006
@@ -63,10 +63,14 @@
             wri = new OutputStreamWriter(getOut(buildFile), "UTF8");
             doc = DOMUtils.newDocument();
             root = doc.createElement(XMLConstants.TESTSUITE);
-            String n = testProject.getName();
-            root.setAttribute(XMLConstants.ATTR_NAME,
-                              n == null ? "unknown" : n);
-            root.setAttribute("buildFile", buildFile);
+            // if we want to (ab)use <junitreport> name needs to
+            // follow the structure expected by that task:
+            // package.class.  package will be the directory holding
+            // the build file (file separators replaced by dots) and
+            // class the build file name with the last dot replaced
+            // by an underscore
+            root.setAttribute(XMLConstants.ATTR_NAME, normalize(buildFile));
+            root.setAttribute(XMLConstants.BUILD_FILE, buildFile);
 
             //add the timestamp
             String timestamp = DateUtils.format(new Date(),

Modified: ant/antlibs/antunit/trunk/src/main/org/apache/ant/antunit/listener/XMLConstants.java
URL: http://svn.apache.org/viewvc/ant/antlibs/antunit/trunk/src/main/org/apache/ant/antunit/listener/XMLConstants.java?rev=433516&r1=433515&r2=433516&view=diff
==============================================================================
--- ant/antlibs/antunit/trunk/src/main/org/apache/ant/antunit/listener/XMLConstants.java (original)
+++ ant/antlibs/antunit/trunk/src/main/org/apache/ant/antunit/listener/XMLConstants.java Mon
Aug 21 21:55:07 2006
@@ -101,4 +101,9 @@
      * name of host running the tests
      */
     String HOSTNAME = "hostname";
+
+    /**
+     * name of the build file.
+     */
+    String BUILD_FILE = "buildFile";
 }



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


Mime
View raw message