Added ScalaTest support to core build.xml

The old JUnit tests are still present, but "ant test" and "ant fulltest" default
to the (pending) ScalaTest ones. To run the ScalaTest tests with Cobertura, execute
the following:

ant -Dscalatest.libs=./lib -Dwith.cobertura=/usr/share/java/cobertura.jar fulltest

The scalatest.libs property must point to a directory containing scala-compiler.jar,
scala-library.jar and scalatest.jar.
This commit is contained in:
str4d
2012-07-30 12:26:35 +00:00
parent 48df91f796
commit 618f214a4f
101 changed files with 72 additions and 8 deletions

View File

@ -68,27 +68,50 @@
<javadoc sourcepath="./src:./test" destdir="./build/javadoc" packagenames="*" use="true" splitindex="true" windowtitle="I2P SDK" /> <javadoc sourcepath="./src:./test" destdir="./build/javadoc" packagenames="*" use="true" splitindex="true" windowtitle="I2P SDK" />
</target> </target>
<!-- scala paths -->
<target name="scala.init">
<property name="scala-library.jar" value="${scalatest.libs}/scala-library.jar" />
<property name="scalatest.jar" value="${scalatest.libs}/scalatest.jar" />
<taskdef resource="scala/tools/ant/antlib.xml">
<classpath>
<pathelement location="${scalatest.libs}/scala-compiler.jar" />
<pathelement location="${scala-library.jar}" />
</classpath>
</taskdef>
</target>
<!-- unit tests --> <!-- unit tests -->
<target name="compileTest"> <target name="scalatest.compileTest" depends="jar, scala.init">
<mkdir dir="./build" />
<mkdir dir="./build/obj_scala" />
<scalac srcdir="./test/scalatest" destdir="./build/obj_scala" deprecation="on" >
<classpath>
<pathelement location="${scala-library.jar}" />
<pathelement location="${scalatest.jar}" />
<pathelement location="./build/i2p.jar" />
</classpath>
</scalac>
</target>
<target name="junit.compileTest" depends="compile">
<mkdir dir="./build" /> <mkdir dir="./build" />
<mkdir dir="./build/obj" /> <mkdir dir="./build/obj" />
<!-- junit and hamcrest classes should be in ant runtime --> <!-- junit and hamcrest classes should be in ant runtime -->
<javac srcdir="./src:./test" debug="true" source="1.5" target="1.5" deprecation="on" <javac srcdir="./test/junit" debug="true" source="1.5" target="1.5" deprecation="on"
includeAntRuntime="true" includeAntRuntime="true"
destdir="./build/obj" > destdir="./build/obj" >
<compilerarg line="${javac.compilerargs}" /> <compilerarg line="${javac.compilerargs}" />
</javac> </javac>
</target> </target>
<target name="jarTest" depends="compileTest"> <target name="jarTest" depends="junit.compileTest">
<jar destfile="./build/i2ptest.jar" basedir="./build/obj" includes="**/*.class" /> <jar destfile="./build/i2ptest.jar" basedir="./build/obj" includes="**/*.class" />
</target> </target>
<!-- preparation of code coverage tool of choice --> <!-- preparation of code coverage tool of choice -->
<target name="prepareClover" depends="compileTest" if="with.clover"> <target name="prepareClover" depends="compile" if="with.clover">
<taskdef resource="clovertasks"/> <taskdef resource="clovertasks"/>
<mkdir dir="../../reports/core/clover" /> <mkdir dir="../../reports/core/clover" />
<clover-setup initString="../../reports/core/clover/coverage.db"/> <clover-setup initString="../../reports/core/clover/coverage.db"/>
</target> </target>
<target name="prepareCobertura" depends="compileTest" if="with.cobertura"> <target name="prepareCobertura" depends="compile" if="with.cobertura">
<taskdef classpath="${with.cobertura}" resource="tasks.properties" onerror="report" /> <taskdef classpath="${with.cobertura}" resource="tasks.properties" onerror="report" />
<mkdir dir="./build/obj_cobertura" /> <mkdir dir="./build/obj_cobertura" />
<delete file="./cobertura.ser" /> <delete file="./cobertura.ser" />
@ -115,7 +138,39 @@
</target> </target>
<target name="prepareTest" depends="prepareClover, prepareCobertura" /> <target name="prepareTest" depends="prepareClover, prepareCobertura" />
<!-- end preparation of code coverage tool --> <!-- end preparation of code coverage tool -->
<target name="test" depends="clean, compileTest, prepareTest"> <target name="scalatest.test" depends="clean, scalatest.compileTest, prepareTest">
<mkdir dir="../../reports/core/scalatest/" />
<delete>
<fileset dir="../../reports/core/scalatest">
<include name="TEST-*.xml"/>
</fileset>
</delete>
<taskdef name="scalatest" classname="org.scalatest.tools.ScalaTestAntTask">
<classpath>
<pathelement location="${scala-library.jar}" />
<pathelement location="${scalatest.jar}" />
<pathelement location="./build/obj_cobertura" />
<pathelement location="./build/obj" />
<pathelement location="../../build/jbigi.jar" />
<pathelement location="${with.clover}" />
<pathelement location="${with.cobertura}" />
</classpath>
</taskdef>
<scalatest runpath="./build/obj_scala" fork="yes" maxmemory="384M">
<tagsToExclude>
SlowTests
</tagsToExclude>
<reporter type="stdout" />
<reporter type="junitxml" directory="../../reports/core/scalatest/" />
</scalatest>
<!-- fetch the real hostname of this machine -->
<exec executable="hostname" outputproperty="host.name"/>
<!-- set if unset -->
<property name="host.fakename" value="i2ptester" />
<!-- replace hostname that junit inserts into reports with fake one -->
<replace dir="../../reports/core/scalatest/" token="${host.name}" value="${host.fakename}"/>
</target>
<target name="junit.test" depends="clean, junit.compileTest, prepareTest">
<mkdir dir="../../reports/core/junit/" /> <mkdir dir="../../reports/core/junit/" />
<delete> <delete>
<fileset dir="../../reports/core/junit"> <fileset dir="../../reports/core/junit">
@ -136,7 +191,7 @@
<pathelement location="${with.cobertura}" /> <pathelement location="${with.cobertura}" />
</classpath> </classpath>
<batchtest todir="../../reports/core/junit/"> <batchtest todir="../../reports/core/junit/">
<fileset dir="./junittest/"> <fileset dir="./test/junit/">
<include name="**/*Test.java" /> <include name="**/*Test.java" />
<exclude name="**/ElGamalAESEngineTest.java" /> <exclude name="**/ElGamalAESEngineTest.java" />
<exclude name="**/StructureTest.java" /> <exclude name="**/StructureTest.java" />
@ -157,7 +212,16 @@
<!-- replace hostname that junit inserts into reports with fake one --> <!-- replace hostname that junit inserts into reports with fake one -->
<replace dir="../../reports/core/junit/" token="${host.name}" value="${host.fakename}"/> <replace dir="../../reports/core/junit/" token="${host.name}" value="${host.fakename}"/>
</target> </target>
<target name="test" depends="scalatest.test"/>
<!-- test reports --> <!-- test reports -->
<target name="scalatest.report">
<junitreport todir="../../reports/core/scalatest">
<fileset dir="../../reports/core/scalatest">
<include name="TEST-*.xml"/>
</fileset>
<report format="frames" todir="../../reports/core/html/scalatest"/>
</junitreport>
</target>
<target name="junit.report"> <target name="junit.report">
<junitreport todir="../../reports/core/junit"> <junitreport todir="../../reports/core/junit">
<fileset dir="../../reports/core/junit"> <fileset dir="../../reports/core/junit">
@ -180,7 +244,7 @@
<cobertura-report format="html" srcdir="./src" destdir="../../reports/core/html/cobertura" /> <cobertura-report format="html" srcdir="./src" destdir="../../reports/core/html/cobertura" />
<delete file="./cobertura.ser" /> <delete file="./cobertura.ser" />
</target> </target>
<target name="test.report" depends="junit.report, clover.report, cobertura.report"/> <target name="test.report" depends="scalatest.report, clover.report, cobertura.report"/>
<!-- end test reports --> <!-- end test reports -->
<target name="fulltest" depends="test, test.report" /> <target name="fulltest" depends="test, test.report" />
<!-- end unit tests --> <!-- end unit tests -->

Some files were not shown because too many files have changed in this diff Show More