summaryrefslogtreecommitdiffstats
path: root/scilab/build.qa.incl.xml
blob: db9b6fba3fb56359d06172bffbaae1bd4cd4dc93 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
        <project name="common_qa">
    <!--  Unitary testing + code coverage -->

    <property name="base.dir" location="../../"/>

    <!-- JAR names -->
    <property file="${base.dir}/scilab-lib.properties"/>
    <property file="${base.dir}/scilab-lib-doc.properties"/>
    <!-- Configure ANT flags -->
    <property file="${base.dir}/scilab.properties"/>

    <!-- Where we can find the test sources -->
    <property name="test.dir" location="tests/"/>
    <property name="src.test.dir" location="${test.dir}/java/"/>
    <property name="report.test.dir" location="${base.dir}/reports/"/>
    <property name="report.xml.test.dir" location="${report.test.dir}/xml/"/>
    <property name="report.html.test.dir" location="${report.test.dir}/html/"/>
    <property name="report.codecoverage.dir" location="${report.test.dir}/codecoverage/"/>
    <property name="report.codecoverage.html.dir" location="${report.test.dir}/html-codecoverage/"/>
    <property name="report.codecoverage.xml.dir" location="${report.test.dir}/xml-codecoverage/"/>

    <!-- Check style definitions -->
    <property name="checkstyle.config.file" value="${base.dir}/checkstyle/scilab_checkstyle_convention.xml"/>
    <property name="checkstyle.stylesheet" value="${thirdparty.dir}/checkstyle/contrib/checkstyle-noframes-sorted.xsl"/>
    <property name="checkstyle.report.dir" value="${build.dir}/checkstyle"/>
    <property name="checkstyle.xml.report.file" value="${checkstyle.report.dir}/checkstyle_errors.xml"/>
    <property name="checkstyle.html.report.file" value="${checkstyle.report.dir}/checkstyle_errors.htm"/>

    <path id="unittest.classpath">
        <pathelement location="${junit4.jar}"/>
        <pathelement location="${hamcrest-all.jar}"/>
    </path>
    <path id="cobertura_classpath">
        <pathelement location="${cobertura.jar}"/>
    </path>

    <!-- Clean test -->
    <target name="clean-test" description="Clean test files">
        <delete dir="${build.test.dir}"/>
    </target>

    <target name="existing-tests">
        <available property="test-present" file="${src.test.dir}"/>
    </target>

    <!-- Compile test sources -->
    <target name="compile-test" description="Build tests" depends="existing-tests, clean-test, jar" if="test-present">
        <!-- clean the test to make sure it will build properly -->
        <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">
            <classpath>
                <path refid="unittest.classpath"/>
                <path refid="compile.classpath"/>
            </classpath>
        </javac>
    </target>

    <taskdef resource="checkstyletask.properties" classpathref="checkstyle.classpath"/>
    <!-- Checkstyle process -->
    <target name="checkstyle" depends="checkstyle-init" description="Generates a report of code convention violations.">
        <checkstyle config="${checkstyle.config.file}" failOnViolation="false">
            <fileset dir="${src.dir}" includes="**/*.java"/>
            <!-- Location of cache-file. -->
            <property key="checkstyle.cache.file" file="${cache.dir}"/>
            <formatter type="plain"/>
            <formatter type="xml" toFile="${checkstyle.xml.report.file}"/>
        </checkstyle>
        <xslt in="${checkstyle.xml.report.file}" out="${checkstyle.html.report.file}" style="${checkstyle.stylesheet}"/>
    </target>
    <!-- Create the build directory -->
    <target name="checkstyle-init">
        <mkdir dir="${checkstyle.report.dir}"/>
    </target>
    <!-- Delete the build directory -->
    <target name="checkstyle-clean">
        <delete dir="${checkstyle.report.dir}"/>
    </target>


    <!-- Allows the override of the forkMode by local build.xml -->
    <condition property="forkModeAlreadySet">
        <isset property="junit.forkMode" />
    </condition>

    <target name="validate">
        <!-- Empty target to be override by other build.xml -->
    </target>

    <target name="instrument">
        <cobertura-instrument todir="${instrumented.classes.test.dir}" datafile="${report.test.dir}/${library.name}.ser">
            <fileset dir="${classes.dir}">
                <include name="**/*.class" />
            </fileset>
        </cobertura-instrument>
    </target>

    <target name="codecoverage" depends="compile-test, instrument, test">
        <cobertura-merge>
            <fileset dir="${report.test.dir}">
                <include name="*.ser" />
            </fileset>
        </cobertura-merge>

        <cobertura-report format="html" destdir="${report.codecoverage.html.dir}">

            <fileset dir="${library.action_binding.src.dir}">
                <include name="**/*.java" />
            </fileset>
            <fileset dir="${library.commons.src.dir}">
                <include name="**/*.java" />
            </fileset>
            <fileset dir="${library.graph.src.dir}">
                <include name="**/*.java" />
            </fileset>
            <fileset dir="${library.graphic_objects.src.dir}">
                <include name="**/*.java" />
            </fileset>
            <fileset dir="${library.xcos.src.dir}">
                <include name="**/*.java" />
            </fileset>
            <fileset dir="${library.types.src.dir}">
                <include name="**/*.java" />
            </fileset>
            <fileset dir="${library.javasci.src.dir}">
                <include name="**/*.java" />
            </fileset>
        </cobertura-report>

        <cobertura-report format="xml" destdir="${report.codecoverage.xml.dir}">

            <fileset dir="${library.action_binding.src.dir}">
                <include name="**/*.java" />
            </fileset>
            <fileset dir="${library.commons.src.dir}">
                <include name="**/*.java" />
            </fileset>
            <fileset dir="${library.graph.src.dir}">
                <include name="**/*.java" />
            </fileset>
            <fileset dir="${library.graphic_objects.src.dir}">
                <include name="**/*.java" />
            </fileset>
            <fileset dir="${library.xcos.src.dir}">
                <include name="**/*.java" />
            </fileset>
            <fileset dir="${library.types.src.dir}">
                <include name="**/*.java" />
            </fileset>
            <fileset dir="${library.javasci.src.dir}">
                <include name="**/*.java" />
            </fileset>
        </cobertura-report>

    </target>


    <target name="detectForkMode" unless="forkModeAlreadySet">
        <property name="junit.forkMode" value="perBatch"/>
    </target>

    <target name="test" depends="existing-tests, compile-test, validate, detectForkMode" if="test-present">
        <mkdir dir="${report.xml.test.dir}" />
        <mkdir dir="${report.html.test.dir}" />
        <mkdir dir="${report.codecoverage.dir}/" />
        <junit fork="yes" forkmode="${junit.forkMode}" failureproperty="junit.failure">
            <sysproperty key="net.sourceforge.cobertura.datafile"
                 file="${report.test.dir}/${library.name}.ser" />


            <classpath location="${instrumented.classes.test.dir}"/>
            <classpath location="${classes.test.dir}"/>

            <classpath>
                <path refid="unittest.classpath"/>
                <path refid="compile.classpath"/>
                <pathelement location="${cobertura.jar}"/>
                <pathelement location="${classes.test.dir}"/>
                <pathelement location="${classes.dir}"/>
            </classpath>


            <!-- Where ${basedir} is the module base directory -->
            <env key="SCI" value="${basedir}/../.."/>
            <jvmarg value="-DtestngTests=1"/>
            <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:"/>

            <formatter type="brief" useFile="no" />
            <formatter type="xml" />

            <batchtest fork="yes" todir="${report.xml.test.dir}" >
                <fileset dir="tests/java/">
                    <include name="**/*.java"/>
                </fileset>
            </batchtest>
        </junit>

        <junitreport todir="${report.xml.test.dir}">
            <fileset dir="${report.xml.test.dir}">
                <include name="*.xml"/>
            </fileset>
            <report format="frames" todir="${report.html.test.dir}"/>
        </junitreport>

        <fail if="junit.failure" message="Unit test(s) failed. See the report"/>
    </target>
</project>