Automate unit tests

This commit is contained in:
Victor Shcherb 2012-07-09 01:09:05 +02:00
parent f90027684c
commit 24f769849b
3 changed files with 42 additions and 19 deletions

View file

@ -25,34 +25,34 @@
</path> </path>
<target name="-dirs"> <target name="-dirs">
<mkdir dir="${bin.absolute.dir}"/> <mkdir dir="${bin.absolute.dir}"/>
</target> </target>
<target name="-copy-resources"> <target name="-copy-resources">
<mkdir dir="${icons.absolute.dir}"/> <mkdir dir="${icons.absolute.dir}"/>
<copy todir="${icons.absolute.dir}"> <copy todir="${icons.absolute.dir}">
<fileset dir="../OsmAnd/res/drawable-mdpi/"> <fileset dir="../OsmAnd/res/drawable-mdpi/">
<include name="h_*.png"/> <include name="h_*.png"/>
<include name="g_*.png"/> <include name="g_*.png"/>
</fileset> </fileset>
</copy> </copy>
</target> </target>
<target name="-version" if="build.version"> <target name="-version" if="build.version">
<replace file="src/net/osmand/MapCreatorVersion.java" token="String APP_DESCRIPTION" value="String APP_DESCRIPTION=&quot;${build.version}&quot;;//"/> <replace file="src/net/osmand/MapCreatorVersion.java" token="String APP_DESCRIPTION" value="String APP_DESCRIPTION=&quot;${build.version}&quot;;//"/>
</target> </target>
<target name="clean"> <target name="clean">
<delete dir="${bin.absolute.dir}"/> <delete dir="${bin.absolute.dir}"/>
</target> </target>
<target name="compile" depends="-copy-resources,-dirs,-version"> <target name="compile" depends="-copy-resources,-dirs,-version">
<copy todir="${bin.absolute.dir}"> <copy todir="${bin.absolute.dir}">
<fileset dir="${src.absolute.dir}"> <fileset dir="${src.absolute.dir}">
<exclude name="**/*.java" /> <exclude name="**/*.java" />
</fileset> </fileset>
</copy> </copy>
<javac srcdir="${src.absolute.dir}" <javac srcdir="${src.absolute.dir}"
destdir="${bin.absolute.dir}" destdir="${bin.absolute.dir}"
encoding="${java.encoding}" encoding="${java.encoding}"
classpathref="build.path" classpathref="build.path"
@ -61,6 +61,23 @@
/> />
</target> </target>
<path id="test.classpath">
<pathelement location="${bin.absolute.dir}" />
<fileset dir="${lib.absolute.dir}">
<include name="*.jar" />
</fileset>
</path>
<target name="routetest" depends="compile">
<junit >
<sysproperty key="basedir" value="${basedir}"/>
<sysproperty key="obfdir" value="${obfdir}"/>
<classpath refid="test.classpath"/>
<formatter type="xml" />
<test name="net.osmand.router.test.JUnitRouteTest" todir="${basedir}/test-results" />
</junit>
</target>
<target name="jar" depends="-copy-resources, -dirs"> <target name="jar" depends="-copy-resources, -dirs">
<manifestclasspath property="lib.list" jarfile="OsmAndMapCreator.jar"> <manifestclasspath property="lib.list" jarfile="OsmAndMapCreator.jar">
<classpath refid="build.path"/> <classpath refid="build.path"/>
@ -90,7 +107,7 @@
<delete file="MANIFEST.MF" /> <delete file="MANIFEST.MF" />
</target> </target>
<target name="build" depends="jar"> <target name="build" depends="jar, routetest">
<delete dir="build"/> <delete dir="build"/>
<copy todir="build"> <copy todir="build">
<fileset dir="."> <fileset dir=".">
@ -121,10 +138,10 @@
<taskdef name="cpd" classname="net.sourceforge.pmd.cpd.CPDTask" classpathref="ant.lib.path"/> <taskdef name="cpd" classname="net.sourceforge.pmd.cpd.CPDTask" classpathref="ant.lib.path"/>
<target name="cpd" description="Search for cut-and-pasted code"> <target name="cpd" description="Search for cut-and-pasted code">
<property name="cpd.report.xml" location="cpd.xml"/> <property name="cpd.report.xml" location="cpd.xml"/>
<cpd minimumTokenCount="100" format="xml" outputFile="${cpd.report.xml}" <cpd minimumTokenCount="100" format="xml" outputFile="${cpd.report.xml}"
ignoreLiterals="true" ignoreIdentifiers="true"> ignoreLiterals="true" ignoreIdentifiers="true">
<fileset dir="${src.absolute.dir}" includes="**/*.java"/> <fileset dir="${src.absolute.dir}" includes="**/*.java"/>
</cpd> </cpd>
</target> </target>
</project> </project>

View file

@ -8,6 +8,7 @@ import java.util.List;
import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.ParserConfigurationException;
import net.osmand.Algoritms;
import net.osmand.binary.BinaryMapIndexReader; import net.osmand.binary.BinaryMapIndexReader;
import net.osmand.router.BinaryRoutePlanner; import net.osmand.router.BinaryRoutePlanner;
import net.osmand.router.RoutingConfiguration; import net.osmand.router.RoutingConfiguration;
@ -27,9 +28,13 @@ public class JUnitRouteTest {
return; return;
} }
BinaryRoutePlanner.PRINT_TO_CONSOLE_ROUTE_INFORMATION_TO_TEST = false; BinaryRoutePlanner.PRINT_TO_CONSOLE_ROUTE_INFORMATION_TO_TEST = false;
String obfdir = System.getenv("obfdir");
if(Algoritms.isEmpty(obfdir)){
obfdir = DataExtractionSettings.getSettings().getBinaryFilesDir();
}
List<File> files = new ArrayList<File>(); List<File> files = new ArrayList<File>();
for (File f : new File(DataExtractionSettings.getSettings().getBinaryFilesDir()).listFiles()) { for (File f : new File(obfdir).listFiles()) {
if (f.getName().endsWith(".obf")) { if (f.getName().endsWith(".obf")) {
files.add(f); files.add(f);
} }

View file

@ -0,0 +1 @@
*.xml