Also use graphic_objects for the code coverage
[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   </path>
32   <path id="cobertura_classpath">
33     <pathelement location="${cobertura.jar}"/>
34   </path>
35   
36   <!-- Clean test -->
37   <target name="clean-test" description="Clean test files">
38     <delete dir="${build.test.dir}"/>
39   </target>
40   
41   <target name="existing-tests">
42     <available property="test-present" file="${src.test.dir}"/>
43   </target>
44   
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">
49       <classpath>
50         <path refid="unittest.classpath"/>
51         <path refid="compile.classpath"/>
52       </classpath>
53     </javac>
54   </target>
55   
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}"/>
65     </checkstyle>
66     <xslt in="${checkstyle.xml.report.file}" out="${checkstyle.html.report.file}" style="${checkstyle.stylesheet}"/>
67   </target>
68   <!-- Create the build directory -->
69   <target name="checkstyle-init">
70     <mkdir dir="${checkstyle.report.dir}"/>
71   </target>
72   <!-- Delete the build directory -->
73   <target name="checkstyle-clean">
74     <delete dir="${checkstyle.report.dir}"/>
75   </target>
76   
77   
78   <!-- Allows the override of the forkMode by local build.xml -->
79   <condition property="forkModeAlreadySet">
80     <isset property="junit.forkMode" />
81   </condition>
82   
83   <target name="validate">
84     <!-- Empty target to be override by other build.xml -->
85   </target>
86   
87   <taskdef classpathref="cobertura_classpath" resource="tasks.properties" />
88   
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" />
93       </fileset>
94     </cobertura-instrument>
95   </target>
96   
97   <target name="codecoverage" depends="compile-test, instrument, test">
98     <cobertura-merge>
99       <fileset dir="${report.test.dir}">
100         <include name="*.ser" />
101       </fileset>
102     </cobertura-merge>
103     
104     <cobertura-report format="html" destdir="${report.codecoverage.html.dir}"> 
105       
106       <fileset dir="${library.action_binding.src.dir}">
107         <include name="**/*.java" />
108       </fileset>
109       <fileset dir="${library.commons.src.dir}">
110         <include name="**/*.java" />
111       </fileset>
112       <fileset dir="${library.graph.src.dir}">
113         <include name="**/*.java" />
114       </fileset>
115       <fileset dir="${library.graphic_objects.src.dir}">
116         <include name="**/*.java" />
117       </fileset>
118       <fileset dir="${library.hdf5.src.dir}">
119         <include name="**/*.java" />
120       </fileset>
121       <fileset dir="${library.xcos.src.dir}">
122         <include name="**/*.java" />
123       </fileset>
124       <fileset dir="${library.types.src.dir}">
125         <include name="**/*.java" />
126       </fileset>
127       <fileset dir="${library.javasci.src.dir}">
128         <include name="**/*.java" />
129       </fileset>
130     </cobertura-report>
131     
132     <cobertura-report format="xml" destdir="${report.codecoverage.xml.dir}"> 
133       
134       <fileset dir="${library.action_binding.src.dir}">
135         <include name="**/*.java" />
136       </fileset>
137       <fileset dir="${library.commons.src.dir}">
138         <include name="**/*.java" />
139       </fileset>
140       <fileset dir="${library.graph.src.dir}">
141         <include name="**/*.java" />
142       </fileset>
143       <fileset dir="${library.graphic_objects.src.dir}">
144         <include name="**/*.java" />
145       </fileset>
146       <fileset dir="${library.hdf5.src.dir}">
147         <include name="**/*.java" />
148       </fileset>
149       <fileset dir="${library.xcos.src.dir}">
150         <include name="**/*.java" />
151       </fileset>
152       <fileset dir="${library.types.src.dir}">
153         <include name="**/*.java" />
154       </fileset>
155       <fileset dir="${library.javasci.src.dir}">
156         <include name="**/*.java" />
157       </fileset>
158     </cobertura-report>
159     
160   </target>
161   
162   
163   <target name="detectForkMode" unless="forkModeAlreadySet">
164     <property name="junit.forkMode" value="perBatch"/>
165   </target>
166   
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" />
174       
175       
176       <classpath location="${instrumented.classes.test.dir}"/>
177       <classpath location="${classes.test.dir}"/>
178       
179       <classpath>
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}"/>
185       </classpath>
186       
187       
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:"/>
192       
193       <formatter type="brief" useFile="no" />
194       <formatter type="xml" />
195       
196       <batchtest fork="yes" todir="${report.xml.test.dir}" >
197         <fileset dir="tests/java/">
198           <include name="**/*.java"/>
199         </fileset>
200       </batchtest>
201     </junit>
202     
203     <junitreport todir="${report.xml.test.dir}">
204       <fileset dir="${report.xml.test.dir}">
205         <include name="*.xml"/>
206       </fileset>
207       <report format="frames" todir="${report.html.test.dir}"/>
208     </junitreport>
209     
210     <fail if="junit.failure" message="Unit test(s) failed. See the report"/>
211   </target>
212 </project>