Author: jgbutler
Date: Tue Apr 29 15:11:09 2008
New Revision: 652166
URL: http://svn.apache.org/viewvc?rev=652166&view=rev
Log:
ibator: add emma coverage report to the build (not as easy as it sounds!)
Added:
ibatis/trunk/java/tools/ibator/core/build/ibatorBuild.vsd (with props)
ibatis/trunk/java/tools/ibator/core/devlib/emma.jar (with props)
ibatis/trunk/java/tools/ibator/core/devlib/emma_ant.jar (with props)
ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/ant/EmmaDumperTask.java
Modified:
ibatis/trunk/java/tools/ibator/core/build/ (props changed)
ibatis/trunk/java/tools/ibator/core/build/build.xml
ibatis/trunk/java/tools/ibator/core/build/version.properties
ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/api/dom/java/Method.java
ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/api/dom/xml/XmlElement.java
Propchange: ibatis/trunk/java/tools/ibator/core/build/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Tue Apr 29 15:11:09 2008
@@ -1,3 +1,4 @@
deploy
reports
work
+coverage.ec
Modified: ibatis/trunk/java/tools/ibator/core/build/build.xml
URL:
http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/build/build.xml?rev=652166&r1=652165&r2=652166&view=diff
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/build/build.xml (original)
+++ ibatis/trunk/java/tools/ibator/core/build/build.xml Tue Apr 29 15:11:09 2008
@@ -28,6 +28,7 @@
<property name="deploy.files" value="${deploy.dir}/files" />
<property name="work.dir" value="${basedir}/work" />
<property name="work.classes" value="${work.dir}/bin" />
+ <property name="work.instrumented" value="${work.dir}/instrumented" />
<property name="work.javadoc" value="${work.dir}/javadoc" />
<property name="generated.source.dir.java2"
value="${work.dir}/test/java2/src" />
<property name="generated.source.dir.java5"
value="${work.dir}/test/java5/src" />
@@ -36,12 +37,31 @@
<property name="ibator.test.bin.dir" value="${work.dir}/test/ibator/bin" />
<property name="reports.dir" value="${basedir}/reports" />
<property name="reports.junit" value="${reports.dir}/junit" />
-
+ <property name="reports.emma" value="${reports.dir}/emma" />
+
+ <path id="emma.lib" >
+ <pathelement location="../devlib/emma.jar" />
+ <pathelement location="../devlib/emma_ant.jar" />
+ </path>
+
+ <path id="emma.runtime.path">
+ <pathelement location="${work.instrumented}"/>
+ <pathelement location="${work.classes}"/>
+ <path refid="emma.lib"/>
+ </path>
+
+ <taskdef resource="emma_ant.properties" classpathref="emma.lib" />
+
<target name="clean" unless="${TSTAMP}">
<tstamp/>
<delete dir="${work.dir}" />
<delete dir="${deploy.dir}" />
<delete dir="${reports.dir}" />
+ <delete>
+ <fileset dir="${basedir}">
+ <include name="*.ec"/>
+ </fileset>
+ </delete>
</target>
<target name="build.prepare" depends="clean">
@@ -90,13 +110,17 @@
<property file="version.properties"/>
- <jar destfile="${deploy.files}/ibator.jar" basedir="${work.classes}" >
+ <jar destfile="${deploy.files}/ibator.jar" >
<manifest>
<attribute name="Main-Class"
value="org.apache.ibatis.ibator.api.IbatorRunner"/>
<attribute name="Specification-Title" value="Apache iBATIS ibator"/>
<attribute name="Specification-Version" value="${version}"/>
<attribute name="Specification-Vendor" value="The Apache Software
Foundation"/>
</manifest>
+ <fileset dir="${work.classes}">
+ <exclude name="org/apache/ibatis/ibator/ant/EmmaDumperTask.class"/>
+ <exclude name="org/apache/ibatis/ibator/ant/SqlScriptRunnerTask.class"/>
+ </fileset>
</jar>
</target>
@@ -120,14 +144,12 @@
<zip destfile="${deploy.dir}/ibator-${version}-${buildNum}.zip"
basedir="${deploy.files}" />
</target>
- <target name="buildIbator" depends="assemble.zipfile, test.report" >
+ <target name="buildIbator" depends="assemble.zipfile, emma.report" >
<fail if="testsFailed" message="The tests did not pass"/>
</target>
- <target name="build.test" depends="build.compile">
+ <target name="test.compile.ibator" depends="test.prepare">
<mkdir dir="${ibator.test.bin.dir}"/>
- <mkdir dir="${reports.dir}"/>
- <mkdir dir="${reports.junit}"/>
<javac destdir="${ibator.test.bin.dir}"
deprecation="true"
@@ -139,7 +161,9 @@
<pathelement location="${deploy.files}/ibator.jar"/>
</classpath>
</javac>
-
+ </target>
+
+ <target name="test.run.ibator" depends="test.compile.ibator">
<junit printsummary="true" showoutput="true">
<formatter type="xml"/>
<batchtest todir="${reports.junit}" fork="yes" haltonerror="no"
failureproperty="testsFailed">
@@ -149,26 +173,25 @@
</batchtest>
<classpath>
<pathelement location="${ibator.test.bin.dir}"/>
- <pathelement location="${deploy.files}/ibator.jar"/>
+ <path refid="emma.runtime.path"/>
</classpath>
</junit>
</target>
-
- <target name="test.prepare" depends="build.test">
+
+ <target name="test.prepare" depends="emma.instrument">
<mkdir dir="${generated.source.dir.java2}"/>
<mkdir dir="${generated.source.dir.java5}"/>
<mkdir dir="${generated.bin.dir.java2}"/>
<mkdir dir="${generated.bin.dir.java5}"/>
+ <mkdir dir="${reports.dir}"/>
+ <mkdir dir="${reports.junit}"/>
<!-- note that the class does not exist until the build runs.
Validating Ant editors will complain that the task cannot be
found, but it's not really an error. -->
<taskdef name="runscript"
- classname="org.apache.ibatis.ibator.ant.SqlScriptRunnerTask">
- <classpath>
- <pathelement location="${deploy.files}/ibator.jar"/>
- </classpath>
- </taskdef>
+ classname="org.apache.ibatis.ibator.ant.SqlScriptRunnerTask"
+ classpathref="emma.runtime.path"/>
<!-- create the test database -->
<runscript driver="org.hsqldb.jdbcDriver"
@@ -176,6 +199,12 @@
userid="sa"
password=""
src="${basedir}/../testJava5/ibatortest/CreateDB.sql"/>
+
+ <taskdef name="emmadumper"
+ classname="org.apache.ibatis.ibator.ant.EmmaDumperTask"
+ classpathref="emma.runtime.path"/>
+
+ <emmadumper fileName="${basedir}/coverage.ec" />
</target>
@@ -186,29 +215,25 @@
Validating Ant editors will complain that the task cannot be
found, but it's not really an error. -->
<taskdef name="ibator"
- classname="org.apache.ibatis.ibator.ant.IbatorAntTask">
- <classpath>
- <pathelement location="${deploy.files}/ibator.jar"/>
- </classpath>
- </taskdef>
+ classname="org.apache.ibatis.ibator.ant.IbatorAntTask"
+ classpathref="emma.runtime.path"/>
<ibator
configfile="${basedir}/../testJava2/ibatortest/java2/ibatorConfig.xml" >
<propertyset>
<propertyref name="generated.source.dir.java2"/>
</propertyset>
</ibator>
- </target>
+
+ <emmadumper fileName="${basedir}/coverage.ec" />
+</target>
<target name="test.generate.test.code.java5" depends="test.prepare">
<!-- note that the class does not exist until the build runs.
Validating Ant editors will complain that the task cannot be
found, but it's not really an error. -->
<taskdef name="ibator"
- classname="org.apache.ibatis.ibator.ant.IbatorAntTask">
- <classpath>
- <pathelement location="${deploy.files}/ibator.jar"/>
- </classpath>
- </taskdef>
+ classname="org.apache.ibatis.ibator.ant.IbatorAntTask"
+ classpathref="emma.runtime.path"/>
<!-- compile the base class so ibator can load it -->
<javac destdir="${generated.bin.dir.java5}"
@@ -228,6 +253,8 @@
<propertyref name="generated.bin.dir.java5"/>
</propertyset>
</ibator>
+
+ <emmadumper fileName="${basedir}/coverage.ec" />
</target>
<target name="test.compile.test.code.java2"
depends="test.generate.test.code.java2">
@@ -342,7 +369,7 @@
</junit>
</target>
- <target name="test.report" depends="test.run.java2, test.run.java5" >
+ <target name="test.report" depends="test.run.java2, test.run.java5,
test.run.ibator" >
<junitreport todir="${reports.junit}">
<fileset dir="${reports.junit}">
<include name="TEST-*.xml"/>
@@ -350,4 +377,31 @@
<report format="frames" todir="${reports.junit}"/>
</junitreport>
</target>
-</project>
\ No newline at end of file
+
+ <target name="emma.instrument" depends="build.ibator.jar" >
+ <mkdir dir="${work.instrumented}"/>
+
+ <path id="emma.classpath">
+ <pathelement location="${deploy.files}/ibator.jar" />
+ </path>
+
+ <emma verbosity="verbose" >
+ <instr instrpathref="emma.classpath"
+ destdir="${work.instrumented}"
+ metadatafile="${basedir}/coverage.ec"
+ merge="true"/>
+ </emma>
+ </target>
+
+ <target name="emma.report" depends="test.report" >
+ <mkdir dir="${reports.emma}" />
+ <emma >
+ <report sourcepath="${src.dir}" >
+ <fileset dir="${basedir}" >
+ <include name="*.ec" />
+ </fileset>
+ <html outfile="${reports.emma}/coverage.html" />
+ </report>
+ </emma>
+ </target>
+</project>
Added: ibatis/trunk/java/tools/ibator/core/build/ibatorBuild.vsd
URL:
http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/build/ibatorBuild.vsd?rev=652166&view=auto
==============================================================================
Binary file - no diff available.
Propchange: ibatis/trunk/java/tools/ibator/core/build/ibatorBuild.vsd
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Modified: ibatis/trunk/java/tools/ibator/core/build/version.properties
URL:
http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/build/version.properties?rev=652166&r1=652165&r2=652166&view=diff
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/build/version.properties (original)
+++ ibatis/trunk/java/tools/ibator/core/build/version.properties Tue Apr 29
15:11:09 2008
@@ -1,4 +1,4 @@
#ibator build version info
-#Sun Apr 27 22:28:35 CDT 2008
+#Tue Apr 29 17:03:56 CDT 2008
version=1.2.0
-buildNum=496
+buildNum=531
Added: ibatis/trunk/java/tools/ibator/core/devlib/emma.jar
URL:
http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/devlib/emma.jar?rev=652166&view=auto
==============================================================================
Binary file - no diff available.
Propchange: ibatis/trunk/java/tools/ibator/core/devlib/emma.jar
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: ibatis/trunk/java/tools/ibator/core/devlib/emma_ant.jar
URL:
http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/devlib/emma_ant.jar?rev=652166&view=auto
==============================================================================
Binary file - no diff available.
Propchange: ibatis/trunk/java/tools/ibator/core/devlib/emma_ant.jar
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added:
ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/ant/EmmaDumperTask.java
URL:
http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/ant/EmmaDumperTask.java?rev=652166&view=auto
==============================================================================
---
ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/ant/EmmaDumperTask.java
(added)
+++
ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/ant/EmmaDumperTask.java
Tue Apr 29 15:11:09 2008
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2008 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ibatis.ibator.ant;
+
+import java.io.File;
+import java.lang.reflect.Method;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+
+/**
+ * This class is used in the ibator build to force emma to dump
+ * coverage information to disk. This is needed because emma
+ * doesn't normally dump until a JVM exit and there are several
+ * places where emma is run during the build - and most data is
+ * lost if not forced to dump. BTW - this seems like a bug in emma!
+ * <p>
+ * This class is not intended to be used by clients. The class uses
+ * reflection to dump emma so that the build is not dependant on emma.
+ *
+ * @author Jeff Butler
+ *
+ */
+public class EmmaDumperTask extends Task {
+
+ private String fileName;
+
+ @Override
+ public void execute() throws BuildException {
+ try {
+ File file = new File(fileName);
+
+ //com.vladium.emma.rt.RT.dumpCoverageData(file, true, false);
+ Class clazz = Class.forName("com.vladium.emma.rt.RT");
//$NON-NLS-1$
+ Class[] parameters = new Class[3];
+ parameters[0] = File.class;
+ parameters[1] = boolean.class;
+ parameters[2] = boolean.class;
+
+ Method method = clazz.getMethod("dumpCoverageData", parameters);
//$NON-NLS-1$
+
+ Object[] actualParms = new Object[3];
+ actualParms[0] = file;
+ actualParms[1] = true;
+ actualParms[2] = false;
+ method.invoke(null, actualParms);
+ } catch (Exception e) {
+ throw new BuildException(e);
+ }
+ }
+
+ public String getFileName() {
+ return fileName;
+ }
+
+ public void setFileName(String fileName) {
+ this.fileName = fileName;
+ }
+}
Modified:
ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/api/dom/java/Method.java
URL:
http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/api/dom/java/Method.java?rev=652166&r1=652165&r2=652166&view=diff
==============================================================================
---
ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/api/dom/java/Method.java
(original)
+++
ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/api/dom/java/Method.java
Tue Apr 29 15:11:09 2008
@@ -59,6 +59,10 @@
bodyLines.add(line);
}
+ public void addBodyLine(int index, String line) {
+ bodyLines.add(index, line);
+ }
+
public String getFormattedContent(int indentLevel, boolean
interfaceMethod) {
StringBuffer sb = new StringBuffer();
@@ -209,6 +213,10 @@
parameters.add(parameter);
}
+ public void addParameter(int index, Parameter parameter) {
+ parameters.add(index, parameter);
+ }
+
/**
* @return Returns the returnType.
*/
Modified:
ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/api/dom/xml/XmlElement.java
URL:
http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/api/dom/xml/XmlElement.java?rev=652166&r1=652165&r2=652166&view=diff
==============================================================================
---
ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/api/dom/xml/XmlElement.java
(original)
+++
ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/api/dom/xml/XmlElement.java
Tue Apr 29 15:11:09 2008
@@ -62,6 +62,10 @@
elements.add(element);
}
+ public void addElement(int index, Element element) {
+ elements.add(index, element);
+ }
+
/**
* @return Returns the name.
*/