Merge branch 'palette-browser' into 'master'
[scilab.git] / scilab / build.qa.incl.xml
1     <project name="common_qa">
2     <!--  Unitary testing + code coverage -->
3
4     <property name="base.dir" location="../../"/>
5
6     <!-- JAR names -->
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"/>
11
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/"/>
21
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"/>
28
29     <path id="unittest.classpath">
30         <pathelement location="${junit4.jar}"/>
31         <pathelement location="${hamcrest-all.jar}"/>
32     </path>
33     <path id="cobertura_classpath">
34         <pathelement location="${cobertura.jar}"/>
35     </path>
36
37     <!-- Clean test -->
38     <target name="clean-test" description="Clean test files">
39         <delete dir="${build.test.dir}"/>
40     </target>
41
42     <target name="existing-tests">
43         <available property="test-present" file="${src.test.dir}"/>
44     </target>
45
46     <!-- Compile test sources -->
47     <target name="compile-test" description="Build tests" depends="existing-tests, clean-test, jar" if="test-present">
48         <!-- clean the test to make sure it will build properly -->
49         <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             <classpath>
51                 <path refid="unittest.classpath"/>
52                 <path refid="compile.classpath"/>
53             </classpath>
54         </javac>
55     </target>
56
57     <taskdef resource="checkstyletask.properties" classpathref="checkstyle.classpath"/>
58     <!-- Checkstyle process -->
59     <target name="checkstyle" depends="checkstyle-init" description="Generates a report of code convention violations.">
60         <checkstyle config="${checkstyle.config.file}" failOnViolation="false">
61             <fileset dir="${src.dir}" includes="**/*.java"/>
62             <!-- Location of cache-file. -->
63             <property key="checkstyle.cache.file" file="${cache.dir}"/>
64             <formatter type="plain"/>
65             <formatter type="xml" toFile="${checkstyle.xml.report.file}"/>
66         </checkstyle>
67         <xslt in="${checkstyle.xml.report.file}" out="${checkstyle.html.report.file}" style="${checkstyle.stylesheet}"/>
68     </target>
69     <!-- Create the build directory -->
70     <target name="checkstyle-init">
71         <mkdir dir="${checkstyle.report.dir}"/>
72     </target>
73     <!-- Delete the build directory -->
74     <target name="checkstyle-clean">
75         <delete dir="${checkstyle.report.dir}"/>
76     </target>
77
78
79     <!-- Allows the override of the forkMode by local build.xml -->
80     <condition property="forkModeAlreadySet">
81         <isset property="junit.forkMode" />
82     </condition>
83
84     <target name="validate">
85         <!-- Empty target to be override by other build.xml -->
86     </target>
87
88     <target name="instrument">
89         <cobertura-instrument todir="${instrumented.classes.test.dir}" datafile="${report.test.dir}/${library.name}.ser">
90             <fileset dir="${classes.dir}">
91                 <include name="**/*.class" />
92             </fileset>
93         </cobertura-instrument>
94     </target>
95
96     <target name="codecoverage" depends="compile-test, instrument, test">
97         <cobertura-merge>
98             <fileset dir="${report.test.dir}">
99                 <include name="*.ser" />
100             </fileset>
101         </cobertura-merge>
102
103         <cobertura-report format="html" destdir="${report.codecoverage.html.dir}">
104
105             <fileset dir="${library.action_binding.src.dir}">
106                 <include name="**/*.java" />
107             </fileset>
108             <fileset dir="${library.commons.src.dir}">
109                 <include name="**/*.java" />
110             </fileset>
111             <fileset dir="${library.graph.src.dir}">
112                 <include name="**/*.java" />
113             </fileset>
114             <fileset dir="${library.graphic_objects.src.dir}">
115                 <include name="**/*.java" />
116             </fileset>
117             <fileset dir="${library.xcos.src.dir}">
118                 <include name="**/*.java" />
119             </fileset>
120             <fileset dir="${library.types.src.dir}">
121                 <include name="**/*.java" />
122             </fileset>
123             <fileset dir="${library.javasci.src.dir}">
124                 <include name="**/*.java" />
125             </fileset>
126         </cobertura-report>
127
128         <cobertura-report format="xml" destdir="${report.codecoverage.xml.dir}">
129
130             <fileset dir="${library.action_binding.src.dir}">
131                 <include name="**/*.java" />
132             </fileset>
133             <fileset dir="${library.commons.src.dir}">
134                 <include name="**/*.java" />
135             </fileset>
136             <fileset dir="${library.graph.src.dir}">
137                 <include name="**/*.java" />
138             </fileset>
139             <fileset dir="${library.graphic_objects.src.dir}">
140                 <include name="**/*.java" />
141             </fileset>
142             <fileset dir="${library.xcos.src.dir}">
143                 <include name="**/*.java" />
144             </fileset>
145             <fileset dir="${library.types.src.dir}">
146                 <include name="**/*.java" />
147             </fileset>
148             <fileset dir="${library.javasci.src.dir}">
149                 <include name="**/*.java" />
150             </fileset>
151         </cobertura-report>
152
153     </target>
154
155
156     <target name="detectForkMode" unless="forkModeAlreadySet">
157         <property name="junit.forkMode" value="perBatch"/>
158     </target>
159
160     <target name="test" depends="existing-tests, compile-test, validate, detectForkMode" if="test-present">
161         <mkdir dir="${report.xml.test.dir}" />
162         <mkdir dir="${report.html.test.dir}" />
163         <mkdir dir="${report.codecoverage.dir}/" />
164         <junit fork="yes" forkmode="${junit.forkMode}" failureproperty="junit.failure">
165             <sysproperty key="net.sourceforge.cobertura.datafile"
166                  file="${report.test.dir}/${library.name}.ser" />
167
168
169             <classpath location="${instrumented.classes.test.dir}"/>
170             <classpath location="${classes.test.dir}"/>
171
172             <classpath>
173                 <path refid="unittest.classpath"/>
174                 <path refid="compile.classpath"/>
175                 <pathelement location="${cobertura.jar}"/>
176                 <pathelement location="${classes.test.dir}"/>
177                 <pathelement location="${classes.dir}"/>
178             </classpath>
179
180
181             <!-- Where ${basedir} is the module base directory -->
182             <env key="SCI" value="${basedir}/../.."/>
183             <jvmarg value="-DtestngTests=1"/>
184             <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:"/>
185
186             <formatter type="brief" useFile="no" />
187             <formatter type="xml" />
188
189             <batchtest fork="yes" todir="${report.xml.test.dir}" >
190                 <fileset dir="tests/java/">
191                     <include name="**/*.java"/>
192                 </fileset>
193             </batchtest>
194         </junit>
195
196         <junitreport todir="${report.xml.test.dir}">
197             <fileset dir="${report.xml.test.dir}">
198                 <include name="*.xml"/>
199             </fileset>
200             <report format="frames" todir="${report.html.test.dir}"/>
201         </junitreport>
202
203         <fail if="junit.failure" message="Unit test(s) failed. See the report"/>
204     </target>
205 </project>