<property name="ooxml.jsr173.jar" location="${ooxml.lib}/stax-api-1.0.1.jar"/>
<property name="ooxml.jsr173.url" value="${repository.m2}/maven2/stax/stax-api/1.0.1/stax-api-1.0.1.jar"/>
+ <!-- coverage libs -->
+ <property name="jacoco.zip" location="${main.lib}/jacoco-0.6.2.201302030002.zip"/>
+ <property name="jacoco.url" value="${repository.m2}/maven2/org/jacoco/jacoco/0.6.2.201302030002/jacoco-0.6.2.201302030002.zip"/>
+ <property name="asm.jar" location="${main.lib}/asm-all-4.0.jar"/>
+ <property name="asm.url" value="${repository.m2}/maven2/org/ow2/asm/asm-all/4.0/asm-all-4.0.jar"/>
+
<!-- See http://www.ecma-international.org/publications/standards/Ecma-376.htm -->
<!-- "Copy these file(s), free of charge" -->
<property name="ooxml.xsds.ozip" location="${ooxml.lib}/OfficeOpenXML-Part4.zip"/>
<property name="maven.ooxml.xsds.version.id" value="1.0"/>
<property name="maven.ooxml.xsds.jar" value="ooxml-schemas-${maven.ooxml.xsds.version.id}.jar"/>
+ <!-- Coverage -->
+ <property name="coverage.dir" value="build/coverage"/>
+ <!-- Exclude some uninteresting classes from coverage-instrumentation as we do not want to measure coverage in those packages anyway -->
+ <property name="coverage.excludes" value="org.openxmlformats.*:com.*:org.junit.*:junit.*:"/>
+
<!-- build and distro settings -->
<property name="jar.name" value="poi"/>
<property name="build.site" location="build/tmp/site/build/site"/>
<pathelement location="${main.output.test.dir}"/>
</path>
+ <path id="lib.jacoco">
+ <fileset dir="lib">
+ <include name="org.jacoco*.jar" />
+ <include name="asm-all-4*.jar" />
+ </fileset>
+ </path>
+
<!-- Prints POI's Ant usage help -->
<target name="help" description="Prints Apache POI's Ant usage help">
<echo>
<available file="${main.junit.jar}"/>
<available file="${main.hamcrest.jar}"/>
<available file="${main.ant.jar}"/>
+ <available file="${asm.jar}"/>
+ <available file="${jacoco.zip}"/>
</and>
<isset property="disconnected"/>
</or>
<param name="sourcefile" value="${main.ant.url}"/>
<param name="destfile" value="${main.ant.jar}"/>
</antcall>
+ <antcall target="downloadfile">
+ <param name="sourcefile" value="${asm.url}"/>
+ <param name="destfile" value="${asm.jar}"/>
+ </antcall>
+ <antcall target="downloadfile">
+ <param name="sourcefile" value="${jacoco.url}"/>
+ <param name="destfile" value="${jacoco.zip}"/>
+ </antcall>
+ <unzip src="${jacoco.zip}" dest=".">
+ <patternset>
+ <include name="lib/*.jar"/>
+ </patternset>
+ </unzip>
</target>
<target name="check-ooxml-jars">
<delete file="${version.java}"/>
</target>
- <target name="test" depends="compile,test-main,test-scratchpad,test-ooxml,test-excelant"
+ <target name="jacocotask" depends="">
+ <taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
+ <classpath refid="lib.jacoco"/>
+ </taskdef>
+ </target>
+
+ <target name="test" depends="compile,jacocotask,test-main,test-scratchpad,test-ooxml,test-excelant"
description="Tests main, scratchpad and ooxml"/>
- <target name="test-all" depends="test,test-ooxml-lite"/>
+ <target name="test-all" depends="test,test-ooxml-lite,testcoveragereport"/>
+
+ <target name="testcoveragereport" depends="jacocotask" description="create test-report" xmlns:jacoco="antlib:org.jacoco.ant" if="${coverage.enabled}">
+ <delete dir="${coverage.dir}"/>
+ <mkdir dir="${coverage.dir}"/>
+
+ <jacoco:report>
+ <executiondata>
+ <fileset dir="build">
+ <include name="*.exec"/>
+ </fileset>
+ </executiondata>
+
+ <structure name="Apache POI">
+ <group name="Main">
+ <classfiles>
+ <fileset dir="${main.output.dir}">
+ <exclude name=""/>
+ </fileset>
+ </classfiles>
+ <sourcefiles encoding="UTF-8">
+ <fileset dir="${main.src}"/>
+ </sourcefiles>
+ </group>
+ <group name="Scratchpad">
+ <classfiles>
+ <fileset dir="${scratchpad.output.dir}"/>
+ </classfiles>
+ <sourcefiles encoding="UTF-8">
+ <fileset dir="${scratchpad.src}"/>
+ </sourcefiles>
+ </group>
+ <group name="OOXML">
+ <classfiles>
+ <fileset dir="${ooxml.output.dir}">
+ <exclude name=""/>
+ </fileset>
+ <fileset dir="${ooxml.lite.output.dir}">
+ <exclude name="org/openxmlformats/**"/>
+ <exclude name="schema*/**"/>
+ </fileset>
+ </classfiles>
+ <sourcefiles encoding="UTF-8">
+ <fileset dir="${ooxml.src}"/>
+ <!--fileset dir="${ooxml.lite.src}"/-->
+ </sourcefiles>
+ </group>
+ <group name="Excelant">
+ <classfiles>
+ <fileset dir="${excelant.output.dir}"/>
+ </classfiles>
+ <sourcefiles encoding="UTF-8">
+ <fileset dir="${excelant.src}"/>
+ </sourcefiles>
+ </group>
+ </structure>
+
+ <html destdir="${coverage.dir}"/>
+ <xml destfile="${coverage.dir}/coverage.xml"/>
+ </jacoco:report>
+
+ <echo message="Coverage results are available at coverage\index.html, coverage/coverage.xml" />
+ </target>
<target name="-test-main-check">
<uptodate property="main.test.notRequired" targetfile="${main.testokfile}">
</target>
<target name="test-main" unless="main.test.notRequired"
- depends="compile-main, -test-main-check">
- <junit fork="yes" forkmode="once" printsummary="yes" haltonfailure="${halt.on.test.failure}"
- failureproperty="main.test.failed" showoutput="true">
- <classpath refid="test.classpath"/>
- <syspropertyset refid="junit.properties"/>
- <jvmarg value="${poi.test.locale}"/>
- <jvmarg value="-ea"/>
- <jvmarg value="-Xmx256m"/>
- <formatter type="plain"/>
- <batchtest todir="${main.reports.test}">
- <fileset dir="${main.src.test}">
- <include name="**/${testpattern}.java"/>
- <exclude name="**/All*Tests.java"/>
- <exclude name="**/TestUnfixedBugs.java"/>
- <exclude name="**/TestcaseRecordInputStream.java"/>
- </fileset>
- </batchtest>
- </junit>
+ depends="compile-main, -test-main-check,jacocotask" xmlns:jacoco="antlib:org.jacoco.ant">
+ <jacoco:coverage enabled="${coverage.enabled}" excludes="${coverage.excludes}" destfile="build/jacoco-main.exec">
+ <junit fork="yes" forkmode="once" printsummary="yes" haltonfailure="${halt.on.test.failure}"
+ failureproperty="main.test.failed" showoutput="true">
+ <classpath refid="test.classpath"/>
+ <syspropertyset refid="junit.properties"/>
+ <jvmarg value="${poi.test.locale}"/>
+ <jvmarg value="-ea"/>
+ <jvmarg value="-Xmx256m"/>
+ <formatter type="plain"/>
+ <formatter type="xml"/>
+ <batchtest todir="${main.reports.test}">
+ <fileset dir="${main.src.test}">
+ <include name="**/${testpattern}.java"/>
+ <exclude name="**/All*Tests.java"/>
+ <exclude name="**/TestUnfixedBugs.java"/>
+ <exclude name="**/TestcaseRecordInputStream.java"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ </jacoco:coverage>
<delete file="${main.testokfile}"/>
<antcall target="-test-main-write-testfile"/>
</target>
</uptodate>
</target>
- <target name="test-scratchpad" depends="compile-main,compile-scratchpad,-test-scratchpad-check"
- unless="scratchpad.test.notRequired">
- <junit printsummary="yes" fork="yes" forkmode="once" haltonfailure="${halt.on.test.failure}"
- failureproperty="scratchpad.test.failed">
- <classpath refid="test.scratchpad.classpath"/>
- <syspropertyset refid="junit.properties"/>
- <jvmarg value="${poi.test.locale}"/>
- <jvmarg value="-ea"/>
- <!--
- YK: ensure that JUnit has enough memory to run tests.
- Without the line below tests fail on Mac OS X with jdk-1.6.26
- and on Windows with jdk-1.5.22
- -->
- <jvmarg value="-Xmx256M"/>
- <formatter type="plain"/>
- <batchtest todir="${scratchpad.reports.test}">
- <fileset dir="${scratchpad.src.test}">
- <include name="**/${testpattern}.java"/>
- <exclude name="**/AllTests.java"/>
- </fileset>
- </batchtest>
- </junit>
+ <target name="test-scratchpad" depends="compile-main,compile-scratchpad,-test-scratchpad-check,jacocotask"
+ unless="scratchpad.test.notRequired" xmlns:jacoco="antlib:org.jacoco.ant">
+ <jacoco:coverage enabled="${coverage.enabled}" excludes="${coverage.excludes}" destfile="build/jacoco-scratchpad.exec">
+ <junit printsummary="yes" fork="yes" forkmode="once" haltonfailure="${halt.on.test.failure}"
+ failureproperty="scratchpad.test.failed">
+ <classpath refid="test.scratchpad.classpath"/>
+ <syspropertyset refid="junit.properties"/>
+ <jvmarg value="${poi.test.locale}"/>
+ <jvmarg value="-ea"/>
+ <!--
+ YK: ensure that JUnit has enough memory to run tests.
+ Without the line below tests fail on Mac OS X with jdk-1.6.26
+ and on Windows with jdk-1.5.22
+ -->
+ <jvmarg value="-Xmx256M"/>
+ <formatter type="plain"/>
+ <formatter type="xml"/>
+ <batchtest todir="${scratchpad.reports.test}">
+ <fileset dir="${scratchpad.src.test}">
+ <include name="**/${testpattern}.java"/>
+ <exclude name="**/AllTests.java"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ </jacoco:coverage>
<delete file="${scratchpad.testokfile}"/>
<antcall target="-test-scratchpad-write-testfile"/>
</target>
</uptodate>
</target>
- <macrodef name="ooxml-test-runner">
+ <macrodef name="ooxml-test-runner" xmlns:jacoco="antlib:org.jacoco.ant">
<attribute name="classpath"/>
+ <attribute name="type"/>
<sequential>
- <junit printsummary="yes" fork="yes" forkmode="once" haltonfailure="${halt.on.test.failure}"
- failureproperty="ooxml.test.failed">
- <classpath refid="@{classpath}"/>
- <syspropertyset refid="junit.properties"/>
- <jvmarg value="${poi.test.locale}"/>
-<!-- <jvmarg value="-ea"/> -->
- <formatter type="plain"/>
- <batchtest todir="${ooxml.reports.test}">
- <fileset dir="${ooxml.src.test}">
- <include name="**/${testpattern}.java"/>
- <exclude name="**/TestUnfixedBugs.java"/>
- <exclude name="**/All*Tests.java"/>
- </fileset>
- </batchtest>
- </junit>
+ <jacoco:coverage enabled="${coverage.enabled}" excludes="${coverage.excludes}" destfile="build/jacoco-@{type}.exec">
+ <junit printsummary="yes" fork="yes" forkmode="once" haltonfailure="${halt.on.test.failure}"
+ failureproperty="ooxml.test.failed">
+ <classpath refid="@{classpath}"/>
+ <syspropertyset refid="junit.properties"/>
+ <jvmarg value="${poi.test.locale}"/>
+ <!-- <jvmarg value="-ea"/> -->
+ <formatter type="plain"/>
+ <formatter type="xml"/>
+ <batchtest todir="${ooxml.reports.test}">
+ <fileset dir="${ooxml.src.test}">
+ <include name="**/${testpattern}.java"/>
+ <exclude name="**/TestUnfixedBugs.java"/>
+ <exclude name="**/All*Tests.java"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ </jacoco:coverage>
</sequential>
</macrodef>
- <target name="test-ooxml" depends="compile-main,compile-ooxml,-test-ooxml-check" unless="ooxml.test.notRequired">
- <ooxml-test-runner classpath="test.ooxml.classpath"/>
+ <target name="test-ooxml" depends="compile-main,compile-ooxml,-test-ooxml-check,jacocotask" unless="ooxml.test.notRequired">
+ <ooxml-test-runner classpath="test.ooxml.classpath" type="ooxml"/>
<delete file="${ooxml.testokfile}"/>
<antcall target="-test-ooxml-write-testfile"/>
</target>
</java>
</target>
- <target name="test-ooxml-lite">
+ <target name="test-ooxml-lite" depends="jacocotask">
<delete file="${ooxml.testokfile}"/>
<echo message="Running ooxml tests against 'poi-ooxml-schemas'"/>
- <ooxml-test-runner classpath="ooxml-lite.classpath"/>
+ <ooxml-test-runner classpath="ooxml-lite.classpath" type="ooxml-lite"/>
</target>
<target name="-test-excelant-check">
<echo file="${excelant.testokfile}" append="false" message="testok"/>
</target>
- <target name="test-excelant" depends="compile-excelant,-test-excelant-check"
- unless="excelant.test.notRequired">
- <junit printsummary="yes" fork="yes" forkmode="once" haltonfailure="${halt.on.test.failure}"
- failureproperty="excelant.test.failed">
- <classpath refid="test.excelant.classpath"/>
- <syspropertyset refid="junit.properties"/>
- <jvmarg value="${poi.test.locale}"/>
- <jvmarg value="-ea"/>
- <formatter type="plain"/>
- <batchtest todir="${excelant.reports.test}">
- <fileset dir="${excelant.src.test}">
- <include name="**/${testpattern}.java"/>
- </fileset>
- </batchtest>
- </junit>
+ <target name="test-excelant" depends="compile-excelant,-test-excelant-check,jacocotask"
+ unless="excelant.test.notRequired" xmlns:jacoco="antlib:org.jacoco.ant">
+ <jacoco:coverage enabled="${coverage.enabled}" excludes="${coverage.excludes}" destfile="build/jacoco-excelant.exec">
+ <junit printsummary="yes" fork="yes" forkmode="once" haltonfailure="${halt.on.test.failure}"
+ failureproperty="excelant.test.failed">
+ <classpath refid="test.excelant.classpath"/>
+ <syspropertyset refid="junit.properties"/>
+ <jvmarg value="${poi.test.locale}"/>
+ <jvmarg value="-ea"/>
+ <formatter type="plain"/>
+ <formatter type="xml"/>
+ <batchtest todir="${excelant.reports.test}">
+ <fileset dir="${excelant.src.test}">
+ <include name="**/${testpattern}.java"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ </jacoco:coverage>
<delete file="${excelant.testokfile}"/>
<antcall target="-test-excelant-write-testfile"/>
</target>