Skip to content

Apache Lucene open-source search software

SOLR-479: Added clover test code coverage

Grant Ingersolle1f97aff7e2e
diff --git a/CHANGES.txt b/CHANGES.txt
index dff0eab6f37..76127725617 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -299,6 +299,9 @@ Build
apache-solr-solrj-1.3-dev.jar
apache-solr-1.3-dev.jar
+2. SOLR-479: Added clover code coverage targets for committers and the nightly build. Requires the Clover library, as licensed to Apache and only available privately. To run:
+ ant -Drun.clover=true clean clover test generate-clover-reports
+
================== Release 1.2, 20070602 ==================
Upgrading from Solr 1.1
diff --git a/build.xml b/build.xml
index dc187f697b2..29deefd5a49 100644
--- a/build.xml
+++ b/build.xml
@@ -94,6 +94,20 @@
<property name="junit.reports" location="${dest}/test-results/reports"/>
<property name="junit.includes" value="**/Test*.java,**/*Test.java"/>
+ <property name="clover.db.dir" location="${dest}/tests/clover/db"/>
+ <property name="clover.report.dir" location="${dest}/tests/clover/reports"/>
+
+ <available
+ property="clover.present"
+ classname="com.cenqua.clover.tasks.CloverReportTask"
+ />
+ <condition property="clover.enabled">
+ <and>
+ <isset property="run.clover"/>
+ <isset property="clover.present"/>
+ </and>
+ </condition>
+
<!-- Macro for compilation -->
<macrodef name="solr-javac">
<attribute name="destdir" />
@@ -434,6 +448,8 @@
<!-- include the solrj classpath and jetty files included in example -->
<path refid="compile.classpath.solrj" />
+
+ <pathelement path="${java.class.path}"/>
</path>
<!-- Compile unit tests. -->
@@ -492,6 +508,45 @@
</junitreport>
</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}/solr_coverage.db">
+ <fileset dir="src/java"/>
+ <fileset dir="src/webapp/src"/>
+ </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>
+ <!--
+ Run after Junit tests.
+ -->
+ <target name="generate-clover-reports" depends="clover.check, clover">
+ <mkdir dir="${clover.report.dir}"/>
+ <clover-report>
+ <current outfile="${clover.report.dir}" title="${fullnamever}">
+ <format type="html"/>
+ </current>
+ </clover-report>
+ </target>
+
<!-- ========================================================================= -->
<!-- ===================== DISTRIBUTION-RELATED TASKS ======================== -->