1 <project name="common_qa">
2 <!-- Unitary testing + code coverage -->
4 <property name="base.dir" location="../../"/>
7 <property file="${base.dir}/scilab-lib.properties"/>
8 <property file="${base.dir}/scilab-lib-doc.properties"/>
9 <!-- Configure ANT flags -->
10 <property file="${base.dir}/scilab.properties"/>
12 <!-- Where we can find the test sources -->
13 <property name="test.dir" location="tests/"/>
14 <property name="src.test.dir" location="${test.dir}/java/"/>
15 <property name="report.test.dir" location="${base.dir}/reports/"/>
16 <property name="report.xml.test.dir" location="${report.test.dir}/xml/"/>
17 <property name="report.html.test.dir" location="${report.test.dir}/html/"/>
18 <property name="report.codecoverage.dir" location="${report.test.dir}/codecoverage/"/>
19 <property name="report.codecoverage.html.dir" location="${report.test.dir}/html-codecoverage/"/>
20 <property name="report.codecoverage.xml.dir" location="${report.test.dir}/xml-codecoverage/"/>
22 <!-- Check style definitions -->
23 <property name="checkstyle.config.file" value="${base.dir}/checkstyle/scilab_checkstyle_convention.xml"/>
24 <property name="checkstyle.stylesheet" value="${thirdparty.dir}/checkstyle/contrib/checkstyle-noframes-sorted.xsl"/>
25 <property name="checkstyle.report.dir" value="${build.dir}/checkstyle"/>
26 <property name="checkstyle.xml.report.file" value="${checkstyle.report.dir}/checkstyle_errors.xml"/>
27 <property name="checkstyle.html.report.file" value="${checkstyle.report.dir}/checkstyle_errors.htm"/>
29 <path id="unittest.classpath">
30 <pathelement location="${junit4.jar}"/>
32 <path id="cobertura_classpath">
33 <pathelement location="${cobertura.jar}"/>
37 <target name="clean-test" description="Clean test files">
38 <delete dir="${build.test.dir}"/>
41 <target name="existing-tests">
42 <available property="test-present" file="${src.test.dir}"/>
45 <!-- Compile test sources -->
46 <target name="compile-test" description="Build tests" depends="existing-tests, clean-test, jar" if="test-present">
47 <!-- clean the test to make sure it will build properly -->
48 <javac srcdir="${src.test.dir}" destdir="${classes.test.dir}" deprecation="on" debug="${build.debug}" verbose="off" listfiles="on" includeAntRuntime="no" source="6" target="6" encoding="UTF-8">
50 <path refid="unittest.classpath"/>
51 <path refid="compile.classpath"/>
56 <taskdef resource="checkstyletask.properties" classpathref="checkstyle.classpath"/>
57 <!-- Checkstyle process -->
58 <target name="checkstyle" depends="checkstyle-init" description="Generates a report of code convention violations.">
59 <checkstyle config="${checkstyle.config.file}" failOnViolation="false">
60 <fileset dir="${src.dir}" includes="**/*.java"/>
61 <!-- Location of cache-file. -->
62 <property key="checkstyle.cache.file" file="${cache.dir}"/>
63 <formatter type="plain"/>
64 <formatter type="xml" toFile="${checkstyle.xml.report.file}"/>
66 <xslt in="${checkstyle.xml.report.file}" out="${checkstyle.html.report.file}" style="${checkstyle.stylesheet}"/>
68 <!-- Create the build directory -->
69 <target name="checkstyle-init">
70 <mkdir dir="${checkstyle.report.dir}"/>
72 <!-- Delete the build directory -->
73 <target name="checkstyle-clean">
74 <delete dir="${checkstyle.report.dir}"/>
78 <!-- Allows the override of the forkMode by local build.xml -->
79 <condition property="forkModeAlreadySet">
80 <isset property="junit.forkMode" />
83 <target name="validate">
84 <!-- Empty target to be override by other build.xml -->
87 <taskdef classpathref="cobertura_classpath" resource="tasks.properties" />
89 <target name="instrument">
90 <cobertura-instrument todir="${instrumented.classes.test.dir}" datafile="${report.test.dir}/${library.name}.ser">
91 <fileset dir="${classes.dir}">
92 <include name="**/*.class" />
94 </cobertura-instrument>
97 <target name="codecoverage" depends="compile-test, instrument, test">
99 <fileset dir="${report.test.dir}">
100 <include name="*.ser" />
104 <cobertura-report format="html" destdir="${report.codecoverage.html.dir}">
106 <fileset dir="${library.action_binding.src.dir}">
107 <include name="**/*.java" />
109 <fileset dir="${library.commons.src.dir}">
110 <include name="**/*.java" />
112 <fileset dir="${library.graph.src.dir}">
113 <include name="**/*.java" />
115 <fileset dir="${library.graphic_objects.src.dir}">
116 <include name="**/*.java" />
118 <fileset dir="${library.hdf5.src.dir}">
119 <include name="**/*.java" />
121 <fileset dir="${library.xcos.src.dir}">
122 <include name="**/*.java" />
124 <fileset dir="${library.types.src.dir}">
125 <include name="**/*.java" />
127 <fileset dir="${library.javasci.src.dir}">
128 <include name="**/*.java" />
132 <cobertura-report format="xml" destdir="${report.codecoverage.xml.dir}">
134 <fileset dir="${library.action_binding.src.dir}">
135 <include name="**/*.java" />
137 <fileset dir="${library.commons.src.dir}">
138 <include name="**/*.java" />
140 <fileset dir="${library.graph.src.dir}">
141 <include name="**/*.java" />
143 <fileset dir="${library.graphic_objects.src.dir}">
144 <include name="**/*.java" />
146 <fileset dir="${library.hdf5.src.dir}">
147 <include name="**/*.java" />
149 <fileset dir="${library.xcos.src.dir}">
150 <include name="**/*.java" />
152 <fileset dir="${library.types.src.dir}">
153 <include name="**/*.java" />
155 <fileset dir="${library.javasci.src.dir}">
156 <include name="**/*.java" />
163 <target name="detectForkMode" unless="forkModeAlreadySet">
164 <property name="junit.forkMode" value="perBatch"/>
167 <target name="test" depends="existing-tests, compile-test, validate, detectForkMode" if="test-present">
168 <mkdir dir="${report.xml.test.dir}" />
169 <mkdir dir="${report.html.test.dir}" />
170 <mkdir dir="${report.codecoverage.dir}/" />
171 <junit fork="yes" forkmode="${junit.forkMode}" failureproperty="junit.failure">
172 <sysproperty key="net.sourceforge.cobertura.datafile"
173 file="${report.test.dir}/${library.name}.ser" />
176 <classpath location="${instrumented.classes.test.dir}"/>
177 <classpath location="${classes.test.dir}"/>
180 <path refid="unittest.classpath"/>
181 <path refid="compile.classpath"/>
182 <pathelement location="${cobertura.jar}"/>
183 <pathelement location="${classes.test.dir}"/>
184 <pathelement location="${classes.dir}"/>
188 <!-- Where ${basedir} is the module base directory -->
189 <env key="SCI" value="${basedir}/../.."/>
190 <jvmarg value="-DtestngTests=1"/>
191 <jvmarg value="-Djava.library.path=${base.dir}/modules/.libs/:${base.dir}/modules/javasci/.libs/:${base.dir}/modules/types/.libs/:${base.dir}/modules/localization/.libs/:${base.dir}/modules/commons/.libs/:${base.dir}/modules/action_binding/.libs/:${base.dir}/thirdparty/:${base.dir}/bin/:/usr/lib/jni/:/usr/lib64/jni:/usr/lib/java/:/usr/lib64/java:"/>
193 <formatter type="brief" useFile="no" />
194 <formatter type="xml" />
196 <batchtest fork="yes" todir="${report.xml.test.dir}" >
197 <fileset dir="tests/java/">
198 <include name="**/*.java"/>
203 <junitreport todir="${report.xml.test.dir}">
204 <fileset dir="${report.xml.test.dir}">
205 <include name="*.xml"/>
207 <report format="frames" todir="${report.html.test.dir}"/>
210 <fail if="junit.failure" message="Unit test(s) failed. See the report"/>