mirror of https://github.com/apache/cassandra
enable code coverage using JaCoCo
patch by rhatch reviewed by dbrosius for cassandra-7226
This commit is contained in:
parent
219ab71fe0
commit
46c3896c62
|
|
@ -6,6 +6,8 @@
|
|||
* Optimize fetching multiple cells by name (CASSANDRA-6933)
|
||||
* Allow compilation in java 8 (CASSANDRA-7208)
|
||||
* Make incremental repair default (CASSANDRA-7250)
|
||||
* Enable code coverage thru JaCoCo (CASSANDRA-7226)
|
||||
|
||||
|
||||
|
||||
2.1.0
|
||||
|
|
|
|||
91
build.xml
91
build.xml
|
|
@ -102,6 +102,11 @@
|
|||
<property name="cobertura.report.dir" value="${cobertura.build.dir}/report"/>
|
||||
<property name="cobertura.classes.dir" value="${cobertura.build.dir}/classes"/>
|
||||
<property name="cobertura.datafile" value="${cobertura.build.dir}/cobertura.ser"/>
|
||||
|
||||
<!-- http://www.eclemma.org/jacoco/ -->
|
||||
<property name="jacoco.export.dir" value="${build.dir}/jacoco/" />
|
||||
<property name="jacoco.execfile" value="${jacoco.export.dir}/jacoco.exec" />
|
||||
<property name="jacoco.version" value="0.7.1.201405082137"/>
|
||||
|
||||
<condition property="maven-ant-tasks.jar.exists">
|
||||
<available file="${build.dir}/maven-ant-tasks-${maven-ant-tasks.version}.jar" />
|
||||
|
|
@ -167,6 +172,7 @@
|
|||
<mkdir dir="${test.classes}"/>
|
||||
<mkdir dir="${build.src.gen-java}"/>
|
||||
<mkdir dir="${build.dir.lib}"/>
|
||||
<mkdir dir="${jacoco.export.dir}"/>
|
||||
</target>
|
||||
|
||||
<target name="clean" description="Remove all locally created artifacts">
|
||||
|
|
@ -175,6 +181,7 @@
|
|||
<delete dir="${cobertura.classes.dir}" />
|
||||
<delete dir="${build.src.gen-java}" />
|
||||
<delete dir="${version.properties.dir}" />
|
||||
<delete dir="${jacoco.export.dir}" />
|
||||
</target>
|
||||
<target depends="clean" name="cleanall"/>
|
||||
|
||||
|
|
@ -371,6 +378,8 @@
|
|||
<dependency groupId="net.sourceforge.cobertura" artifactId="cobertura" version="${cobertura.version}">
|
||||
<exclusion groupId="xerces" artifactId="xercesImpl"/>
|
||||
</dependency>
|
||||
<dependency groupId="org.jacoco" artifactId="org.jacoco.agent" version="${jacoco.version}"/>
|
||||
<dependency groupId="org.jacoco" artifactId="org.jacoco.ant" version="${jacoco.version}"/>
|
||||
|
||||
<dependency groupId="org.apache.cassandra" artifactId="cassandra-all" version="${version}" />
|
||||
<dependency groupId="org.apache.cassandra" artifactId="cassandra-thrift" version="${version}" />
|
||||
|
|
@ -423,6 +432,8 @@
|
|||
artifactId="cassandra-parent"
|
||||
version="${version}"/>
|
||||
<dependency groupId="net.sourceforge.cobertura" artifactId="cobertura"/>
|
||||
<dependency groupId="org.jacoco" artifactId="org.jacoco.agent"/>
|
||||
<dependency groupId="org.jacoco" artifactId="org.jacoco.ant"/>
|
||||
</artifact:pom>
|
||||
|
||||
<artifact:pom id="test-deps-pom"
|
||||
|
|
@ -533,11 +544,6 @@
|
|||
<remoteRepository refid="apache"/>
|
||||
<remoteRepository refid="java.net2"/>
|
||||
</artifact:dependencies>
|
||||
<artifact:dependencies pomRefId="coverage-deps-pom"
|
||||
pathId="cobertura.classpath">
|
||||
<remoteRepository refid="central"/>
|
||||
</artifact:dependencies>
|
||||
|
||||
<copy todir="${build.dir.lib}/jars">
|
||||
<fileset refid="build-dependency-jars"/>
|
||||
<mapper type="flatten"/>
|
||||
|
|
@ -546,6 +552,23 @@
|
|||
<fileset refid="build-dependency-sources"/>
|
||||
<mapper type="flatten"/>
|
||||
</copy>
|
||||
<!-- code coverage tools -->
|
||||
<artifact:dependencies pomRefId="coverage-deps-pom"
|
||||
filesetId="coverage-dependency-jars"
|
||||
pathId="cobertura.classpath">
|
||||
<remoteRepository refid="central"/>
|
||||
</artifact:dependencies>
|
||||
<copy todir="${build.dir.lib}/jars">
|
||||
<fileset refid="coverage-dependency-jars"/>
|
||||
<mapper type="flatten"/>
|
||||
</copy>
|
||||
<!-- jacoco agent jar comes wrapped in a jar -->
|
||||
<unzip src="${build.dir.lib}/jars/org.jacoco.agent-${jacoco.version}.jar" dest="${build.dir.lib}/jars">
|
||||
<patternset>
|
||||
<include name="*.jar"/>
|
||||
</patternset>
|
||||
<mapper type="flatten"/>
|
||||
</unzip>
|
||||
</target>
|
||||
|
||||
<target name="maven-ant-tasks-retrieve-test" depends="maven-ant-tasks-init">
|
||||
|
|
@ -663,7 +686,7 @@
|
|||
-->
|
||||
<target name="build"
|
||||
depends="maven-ant-tasks-retrieve-build,build-project" description="Compile Cassandra classes"/>
|
||||
<target name="codecoverage" depends="cobertura-instrument,test,cobertura-report" description="Create code coverage report"/>
|
||||
<target name="codecoverage" depends="jacoco-run,jacoco-report" description="Create code coverage report"/>
|
||||
|
||||
<target depends="init,gen-cli-grammar,gen-cql3-grammar"
|
||||
name="build-project">
|
||||
|
|
@ -1050,7 +1073,14 @@
|
|||
<element name="optjvmargs" implicit="true" optional="true" />
|
||||
<attribute name="filter" default="**/${test.name}.java"/>
|
||||
<attribute name="exclude" default="" />
|
||||
|
||||
<attribute name="usejacoco" default="no"/>
|
||||
<sequential>
|
||||
<condition property="additionalagent"
|
||||
value="-javaagent:${build.dir.lib}/jars/jacocoagent.jar=destfile=${jacoco.execfile}"
|
||||
else="">
|
||||
<istrue value="${usejacoco}"/>
|
||||
</condition>
|
||||
<echo message="running @{suitename} tests"/>
|
||||
<mkdir dir="${build.test.dir}/cassandra"/>
|
||||
<mkdir dir="${build.test.dir}/output"/>
|
||||
|
|
@ -1060,7 +1090,7 @@
|
|||
<formatter type="brief" usefile="false"/>
|
||||
<jvmarg value="-Dstorage-config=${test.conf}"/>
|
||||
<jvmarg value="-Djava.awt.headless=true"/>
|
||||
<jvmarg value="-javaagent:${basedir}/lib/jamm-0.2.6.jar" />
|
||||
<jvmarg line="-javaagent:${basedir}/lib/jamm-0.2.6.jar ${additionalagent}" />
|
||||
<jvmarg value="-ea"/>
|
||||
<jvmarg value="-Xss256k"/>
|
||||
<jvmarg value="-Dcassandra.memtable_row_overhead_computation_step=100"/>
|
||||
|
|
@ -1132,6 +1162,18 @@
|
|||
</fileset>
|
||||
</target>
|
||||
|
||||
<!--
|
||||
Run named ant task with jacoco, such as "ant jacoco-run -Dtaskname=pig-test"
|
||||
the target run must enable the jacoco agent if usejacoco is 'yes' -->
|
||||
<target name="jacoco-run" description="run named task with jacoco instrumentation">
|
||||
<condition property="runtask" value="${taskname}" else="test">
|
||||
<isset property="taskname"/>
|
||||
</condition>
|
||||
<antcall target="${runtask}">
|
||||
<param name="usejacoco" value="yes"/>
|
||||
</antcall>
|
||||
</target>
|
||||
|
||||
<target name="testsome" depends="build-test" description="Execute specific unit tests" >
|
||||
<testmacro suitename="unit" inputdir="${test.unit.src}" exclude="**/pig/*.java" timeout="${test.timeout}">
|
||||
<test name="${test.name}" methods="${test.methods}"/>
|
||||
|
|
@ -1236,6 +1278,41 @@
|
|||
<target name="test-all"
|
||||
depends="test,long-test,test-compression,pig-test,test-clientutil-jar"
|
||||
description="Run all tests" />
|
||||
|
||||
<!-- Use JaCoCo ant extension without needing externally saved lib -->
|
||||
<target name="jacoco-init" depends="maven-ant-tasks-init">
|
||||
<artifact:dependencies pathId="jacocoant.classpath">
|
||||
<dependency groupId="org.jacoco" artifactId="org.jacoco.ant" version="${jacoco.version}" />
|
||||
</artifact:dependencies>
|
||||
<typedef uri="antlib:org.jacoco.ant" classpathref="jacocoant.classpath"/>
|
||||
</target>
|
||||
|
||||
<target name="jacoco-report" depends="jacoco-init">
|
||||
<jacoco:report xmlns:jacoco="antlib:org.jacoco.ant">
|
||||
<executiondata>
|
||||
<file file="${jacoco.execfile}" />
|
||||
</executiondata>
|
||||
<structure name="JaCoCo Cassandara Unit Test Coverage">
|
||||
<classfiles>
|
||||
<fileset dir="${build.classes}">
|
||||
<include name="**/*.class"/>
|
||||
</fileset>
|
||||
</classfiles>
|
||||
<sourcefiles encoding="UTF-8">
|
||||
<fileset dir="${build.src}" />
|
||||
</sourcefiles>
|
||||
</structure>
|
||||
<!-- to produce reports in different formats. -->
|
||||
<html destdir="${jacoco.export.dir}" />
|
||||
<csv destfile="${jacoco.export.dir}/report.csv" />
|
||||
<xml destfile="${jacoco.export.dir}/report.xml" />
|
||||
</jacoco:report>
|
||||
</target>
|
||||
|
||||
<target name="jacoco-cleanup" description="Destroy JaCoCo exec data and reports">
|
||||
<delete file="${jacoco.execfile}"/>
|
||||
<delete dir="${jacoco.export.dir}"/>
|
||||
</target>
|
||||
|
||||
<!-- instruments the classes to later create code coverage reports -->
|
||||
<target name="cobertura-instrument" depends="build,build-test">
|
||||
|
|
|
|||
Loading…
Reference in New Issue