You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@gump.apache.org by le...@apache.org on 2003/04/06 10:54:32 UTC
cvs commit: jakarta-gump/stylesheet pubreport.xsl xref.xsl
leosimons 2003/04/06 00:54:32
Modified: java Project.java Workspace.java
stylesheet xref.xsl
Added: stylesheet pubreport.xsl
Log:
Adding support for Junit reports. Basically cloned the existing javadoc functionality while giving things some different names.
Revision Changes Path
1.54 +80 -3 jakarta-gump/java/Project.java
Index: Project.java
===================================================================
RCS file: /home/cvs/jakarta-gump/java/Project.java,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -r1.53 -r1.54
--- Project.java 5 Apr 2003 17:41:49 -0000 1.53
+++ Project.java 6 Apr 2003 08:54:32 -0000 1.54
@@ -149,6 +149,7 @@
Element home = null;
Element javadoc = null;
+ Element junitreport = null;
Node child=element.getFirstChild();
for (; child != null; child=child.getNextSibling()) {
@@ -171,6 +172,8 @@
url = (Element)child;
} else if (child.getNodeName().equals("javadoc")) {
javadoc = (Element)child;
+ } else if (child.getNodeName().equals("junitreport")) {
+ junitreport = (Element)child;
} else if (child.getNodeName().equals("jar")) {
jars.put(((Element)child).getAttribute("id"), child);
} else if (child.getNodeName().equals("deliver")) {
@@ -193,6 +196,7 @@
}
resolveJavadoc(javadoc);
+ resolveJunitreport(junitreport);
handleDeliver();
// if only one jar is found, make sure that it can be accessed without
@@ -752,6 +756,79 @@
// copy the entire result to the desired module
module.appendChild(javadoc);
+ }
+
+ /**
+ * If a junitreport child was found, add any missing project, module,
+ * or description information; resolve path; and copy the resulting
+ * node to the specified module.
+ * @param junitreport child XML element
+ */
+ private void resolveJunitreport(Element junitreport) throws Exception {
+ if (junitreport == null) return;
+
+ // retrieve url and dir of javadoc from the workspace
+ Element config = Workspace.getJUnitReport();
+ if (config == null) return;
+ String url = config.getAttribute("url");
+ String junitreportDir = config.getAttribute("dir");
+
+ // default project attribute to the name of this project
+ if (junitreport.getAttributeNode("project") == null)
+ junitreport.setAttribute("project", name);
+
+ // default module attribute to the module which this project belongs
+ String moduleName = junitreport.getAttribute("module");
+ if (moduleName.equals("")) moduleName = this.get("module");
+ Module module = Module.find(moduleName);
+ require (module, "module", moduleName);
+
+ if (!moduleName.equals(this.get("module"))) {
+ junitreport.setAttribute("defined-in", this.get("module"));
+ }
+
+ // if there are no child nodes, add this project's description
+ if (!junitreport.hasChildNodes() && description!=null) {
+ Element desc = (Element) description.cloneNode(true);
+ junitreport.appendChild(desc);
+ }
+
+ // resolve relative and full path to this javadoc entry
+ String path = junitreport.getAttribute("nested");
+ String fullpath;
+ if (!path.equals("")) {
+ fullpath = get("srcdir") + "/" + path;
+ } else {
+ path = junitreport.getAttribute("parent");
+ fullpath = Workspace.getBaseDir() + "/" + path;
+ }
+ path = moduleName + "/" + path;
+
+ // for each description entry, resolve source, url, and dest attrs.
+ Node child=junitreport.getFirstChild();
+ for (; child != null; child=child.getNextSibling()) {
+ if (child.getNodeName().equals("description")) {
+ Element desc = (Element) child;
+ String dir = desc.getAttribute("dir");
+ String append = "";
+ if (!dir.equals("")) append = "/" + dir;
+
+ desc.setAttribute("source", fullpath + append);
+
+ if (url.equals("")) {
+ desc.setAttribute("url", "file:///" + fullpath + append);
+ } else {
+ desc.setAttribute("url", url + path + append);
+ }
+
+ if (!junitreportDir.equals("")) {
+ desc.setAttribute("dest", junitreportDir + "/" + path + append);
+ }
+ }
+ }
+
+ // copy the entire result to the desired module
+ module.appendChild(junitreport);
}
/**
1.7 +18 -7 jakarta-gump/java/Workspace.java
Index: Workspace.java
===================================================================
RCS file: /home/cvs/jakarta-gump/java/Workspace.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- Workspace.java 27 Aug 2002 14:54:09 -0000 1.6
+++ Workspace.java 6 Apr 2003 08:54:32 -0000 1.7
@@ -58,7 +58,7 @@
* <http://www.apache.org/>.
*
*/
-
+
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -71,6 +71,7 @@
private static Element element;
private static String basedir;
private static Element javadoc;
+ private static Element junitreport;
private static Element deliver;
private static Element nag;
private static HashMap servers = new HashMap();
@@ -109,6 +110,14 @@
}
/**
+ * Static property accessor for junitreport element.
+ * @return Junitreport element (if any) associated with this workspace
+ */
+ public static Element getJUnitReport() {
+ return junitreport;
+ }
+
+ /**
* Static property accessor for nag element.
* @return Javadoc element (if any) associated with this workspace
*/
@@ -188,13 +197,15 @@
for (; child != null; child=child.getNextSibling()) {
if (child.getNodeName().equals("javadoc")) {
javadoc = (Element) child;
+ } else if (child.getNodeName().equals("junitreport")) {
+ junitreport = (Element) child;
} else if (child.getNodeName().equals("nag")) {
nag = (Element) child;
} else if (child.getNodeName().equals("deliver")) {
handleDeliver((Element) child);
}
}
-
+
if (deliver != null) {
element.removeChild(deliver);
String scratchdir = deliver.getAttribute("scratchdir");
@@ -202,7 +213,7 @@
deliver.setAttribute("scratchdir", basedir+"/scratch");
}
}
-
+
}
/**
@@ -231,5 +242,5 @@
sites.put(site.getAttribute("name"), site);
}
}
- }
+ }
}
1.23 +84 -3 jakarta-gump/stylesheet/xref.xsl
Index: xref.xsl
===================================================================
RCS file: /home/cvs/jakarta-gump/stylesheet/xref.xsl,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- xref.xsl 3 Apr 2003 03:41:01 -0000 1.22
+++ xref.xsl 6 Apr 2003 08:54:32 -0000 1.23
@@ -95,7 +95,7 @@
<xsl:if test="not(depend[@project=$project])">
<xsl:text>]</xsl:text>
</xsl:if>
-
+
<xsl:if test="depend[@project=$project and @inherited] |
option[@project=$project and @inherited]">
<xsl:text>)</xsl:text>
@@ -179,7 +179,7 @@
<th class="content">Description</th>
</tr>
- <xsl:for-each
+ <xsl:for-each
select="/workspace/module[cvs/@repository=$r]">
<tr>
<td class="content">
@@ -527,7 +527,7 @@
<th class="content">Java Package Name</th>
<th class="content">Project</th>
</tr>
-
+
<xsl:for-each select="/workspace/project/package">
<xsl:sort select="."/>
<tr>
@@ -593,6 +593,87 @@
</content>
</html>
+
+ <!-- =============================================================== -->
+ <!-- Produce a listing of junit reports -->
+ <!-- =============================================================== -->
+
+ <html log="{@logdir}/junitreports.html"
+ banner-image="{@banner-image}" banner-link="{@banner-link}">
+
+ <title>List of junitreports</title>
+
+ <sidebar>
+ <strong><a href="index.html">Build logs</a></strong>
+ <ul>
+ <xsl:for-each select="project[ant|script]">
+ <xsl:sort select="@name"/>
+ <li>
+ <a href="{@name}.html"><xsl:value-of select="@name"/></a>
+ </li>
+ </xsl:for-each>
+ </ul>
+ </sidebar>
+
+ <content>
+
+ <blockquote>
+ <xsl:for-each select="/workspace/module[junitreport]">
+ <xsl:sort select="@name"/>
+ <xsl:variable name="name" select="@name"/>
+
+ <!-- Choose from three basic styles -->
+ <xsl:choose>
+ <xsl:when test="count(junitreport/description)>1">
+ <b>
+ <xsl:value-of select="@name"/>
+ </b>
+ <xsl:text> - </xsl:text>
+ <xsl:value-of select="normalize-space(description)"/>
+ <blockquote>
+
+ <!-- Multiple reports from different projects -->
+ <xsl:if test="junitreport[@project!=$name]">
+ <xsl:for-each select="junitreport/description">
+ <xsl:sort select="../@project"/>
+ <a href="{@url}/index.html">
+ <xsl:value-of select="../@project"/>
+ </a>
+ <xsl:text> - </xsl:text>
+ <xsl:value-of select="normalize-space(.)"/>
+ <br/>
+ </xsl:for-each>
+ </xsl:if>
+
+ <!-- Multiple javadocs all from the same project -->
+ <xsl:if test="not(junitreport[@project!=$name])">
+ <xsl:for-each select="junitreport/description">
+ <a href="{@url}/index.html">
+ <xsl:value-of select="normalize-space(.)"/>
+ </a>
+ <br/>
+ </xsl:for-each>
+ </xsl:if>
+ </blockquote>
+ </xsl:when>
+ <xsl:otherwise>
+
+ <!-- Single javadoc -->
+ <a href="{junitreport/description/@url}/index.html">
+ <xsl:value-of select="junitreport/@project"/>
+ </a>
+ <xsl:text> - </xsl:text>
+ <xsl:value-of select="normalize-space(description)"/>
+ <p/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:for-each>
+
+ </blockquote>
+
+ </content>
+
+ </html>
</xref>
1.1 jakarta-gump/stylesheet/pubreport.xsl
Index: pubreport.xsl
===================================================================
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="text" omit-xml-declaration="yes"/>
<xsl:template match="workspace">
<script>#!/usr/bin/perl
use File::Copy;
use File::Path;
my %map = (<xsl:apply-templates select="*"/>);
foreach $source (sort keys %map) {
if (-d $source) {
$dest = $map{$source};
rmtree $dest, 0, 0;
mkpath $dest, 0, 0775;
rmdir $dest;
system "cp -r $source $dest";
print "+ $source\n";
} else {
print "! $source\n";
}
}
</script>
</xsl:template>
<xsl:template match="junitreport/description[@dest]">
<data>
"<xsl:value-of select="@source"/>" =>
"<xsl:value-of select="@dest"/>",</data>
</xsl:template>
<xsl:template match="*">
<xsl:apply-templates select="*"/>
</xsl:template>
</xsl:stylesheet>
Re: JUnit reports (Re: cvs commit: jakarta-gump/stylesheet pubreport.xsl
xref.xsl)
Posted by Leo Simons <le...@apache.org>.
Christopher Lenz wrote:
> Any idea?
it's not working yet. I'm meaning to get back to this but find myself
distracted by real life. One thing I've found which is wrong is that on
my machine a slash is missing in the url --
http://lsd.student.utwente.nl/gump/junitreport/avalon/target/docs/test/index.html
works. But the script which copies this stuff is not running
automatically yet. Still testing.
cheers,
- LSD
JUnit reports (Re: cvs commit: jakarta-gump/stylesheet pubreport.xsl
xref.xsl)
Posted by Christopher Lenz <cm...@gmx.de>.
Leo,
what is the status of this feature? I've tried adding the junit-reports
to Cactus, but the listing here:
http://nagoya.apache.org/~rubys/gump/junitreports.html
is completely empty, while here:
http://lsd.student.utwente.nl/gump/junitreports.html
they appear in the listing but the links are broken.
Any idea?
leosimons@apache.org wrote:
> leosimons 2003/04/06 00:54:32
>
> Modified: java Project.java Workspace.java
> stylesheet xref.xsl
> Added: stylesheet pubreport.xsl
> Log:
> Adding support for Junit reports. Basically cloned the existing javadoc functionality while giving things some different names.
>
> Revision Changes Path
> 1.54 +80 -3 jakarta-gump/java/Project.java
[snip]
--
Christopher Lenz
/=/ cmlenz at gmx.de