浏览代码

HADOOP-1718. Add ant targets for measuring code coverage with clover. Contributed by Simon Willnauer

git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk@575016 13f79535-47bb-0310-9956-ffa450edef68
Nigel Daley 17 年之前
父节点
当前提交
d1e15a5d48
共有 2 个文件被更改,包括 58 次插入1 次删除
  1. 3 0
      CHANGES.txt
  2. 55 1
      build.xml

+ 3 - 0
CHANGES.txt

@@ -202,6 +202,9 @@ Trunk (unreleased changes)
     HADOOP-1018.  Improve documentation w.r.t handling of lost hearbeats between 
     TaskTrackers and JobTracker. (acmurthy)
 
+    HADOOP-1718.  Add ant targets for measuring code coverage with clover.
+    (simonwillnauer via nigel)
+
 Release 0.14.1 - 2007-09-04
 
   BUG FIXES

+ 55 - 1
build.xml

@@ -85,6 +85,18 @@
   <property name="javac.args" value=""/>
   <property name="javac.args.warnings" value="-Xlint:unchecked"/>
 
+  <property name="clover.db.dir" location="${build.dir}/test/clover/db"/>
+  <property name="clover.report.dir" location="${build.dir}/test/clover/reports"/>
+
+  <available property="clover.present" classname="com.cenqua.clover.tasks.CloverReportTask" />
+  <!-- check if clover reports should be generated -->
+  <condition property="clover.enabled">
+    <and>
+        <isset property="run.clover"/>
+        <isset property="clover.present"/>
+    </and>
+  </condition>
+
   <!-- the normal classpath -->
   <path id="classpath">
     <pathelement location="${build.classes}"/>
@@ -297,7 +309,7 @@
   </target>
 
   <target name="compile-core" 
-          depends="compile-core-classes,compile-core-native,compile-c++">
+          depends="clover,compile-core-classes,compile-core-native,compile-c++">
   </target>
 
   <target name="compile-contrib" depends="compile-core">
@@ -933,4 +945,46 @@
     </jar>
   </target>
 
+
+
+ <target name="clover" depends="clover.setup, clover.info" description="Instrument the Unit tests using Clover.  Requires a Clover license and clover.jar in the ANT classpath.  To use, specify -Drun.clover=true on the command line."/>
+
+<target name="clover.setup" if="clover.enabled">
+   <taskdef resource="clovertasks"/>
+   <mkdir dir="${clover.db.dir}"/>
+   <clover-setup initString="${clover.db.dir}/hadoop_coverage.db">
+     <fileset dir="src/java"/>
+   </clover-setup>
+</target>
+
+<target name="clover.info" unless="clover.present">
+  <echo>
+     Clover not found. Code coverage reports disabled.
+  </echo>
+</target>
+
+<target name="clover.check">
+  <fail unless="clover.present">
+  ##################################################################
+   Clover not found.
+   Please make sure clover.jar is in ANT_HOME/lib, or made available
+   to Ant using other mechanisms like -lib or CLASSPATH.
+  ##################################################################
+  </fail>
+</target>
+
+<target name="generate-clover-reports" depends="clover.check, clover">
+  <mkdir dir="${clover.report.dir}"/>
+  <clover-report>
+     <current outfile="${clover.report.dir}" title="${final.name}">
+     <format type="html"/>
+     </current>
+  </clover-report>
+  <clover-report>
+     <current outfile="${clover.report.dir}/clover.xml" title="${final.name}">
+     <format type="xml"/>
+     </current>
+  </clover-report>
+</target>
+
 </project>