-
Notifications
You must be signed in to change notification settings - Fork 46
/
coverage.xml
152 lines (135 loc) · 6.81 KB
/
coverage.xml
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
<!--
Copyright 2006-2012 The Scriptella Project Team.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<project name="scriptella coverage build file" default="report">
<description>
Coverage for JUnit tests. PerfTests are excluded to make coverage testing faster.
</description>
<property name="build.dir" value="${basedir}/build"/>
<property name="tmp.dir" value="${build.dir}/tmp/coverage"/>
<property name="classes" value="${tmp.dir}/classes"/>
<property name="testclasses" value="${tmp.dir}/testclasses"/>
<property name="tests.xml.report.dir" value="${tmp.dir}/junit-xml"/>
<property name="instrumented.dir" value="${tmp.dir}/instrumented"/>
<property name="reports.dir" value="${build.dir}/reports"/>
<property name="coverage.report.dir" value="${reports.dir}/coverage"/>
<property name="coverage.junit.report.dir" value="${reports.dir}/coverage-junit"/>
<property file="custom.build.properties"/>
<property file="build.properties"/>
<path id="cobertura.classpath">
<fileset dir="${cobertura.dir}">
<include name="cobertura.jar"/>
<include name="lib/**/*.jar"/>
</fileset>
</path>
<path id="classpath">
<fileset dir="lib" includes="**/*.jar"/>
</path>
<target name="instrument">
<delete file="${instrumented.dir}/cobertura.ser"/>
<!--
Instrument the application classes, writing the
instrumented classes into ${instrumented.dir}.
-->
<cobertura-instrument todir="${instrumented.dir}" datafile="${instrumented.dir}/cobertura.ser">
<!--
The following line causes instrument to ignore any
source line containing a reference to log4j, for the
purposes of coverage reporting.
-->
<ignore regex="java.util.logging.Logger"/>
<ignore regex="java.lang.UnsupportedOperationException"/>
<ignore regex="java.lang.IllegalStateException"/>
<fileset dir="${classes}">
<!--
Instrument all the application classes.
-->
<include name="**/*.class"/>
</fileset>
</cobertura-instrument>
</target>
<target name="clean" unless="noclean">
<delete dir="${tmp.dir}"/>
</target>
<target name="init" depends="clean" description="Initializes test classes/resources">
<condition property="cobertura.notfound">
<and>
<isset property="cobertura.dir"/>
<not>
<available file="${cobertura.dir}"/>
</not>
</and>
</condition>
<fail if="cobertura.notfound" message="cobertura.dir should point to an exisiting directory where Cobertura is installed."/>
<taskdef classpathref="cobertura.classpath" resource="tasks.properties"/>
<mkdir dir="${classes}"/>
<mkdir dir="${testclasses}"/>
<javac srcdir="core/src/java;drivers/src/java;tools/src/java"
destdir="${classes}" debug="on" debuglevel="lines,vars,source" classpathref="classpath"/>
<javac srcdir="core/src/test;drivers/src/test;tools/src/test"
destdir="${testclasses}" debug="on" debuglevel="lines,vars,source">
<classpath refid="classpath"/>
<classpath location="${classes}"/>
</javac>
<!--Copying resources-->
<copy todir="${testclasses}">
<fileset dir="core/src/test" includes="**/*.properties **/*.sql **/*.xml"/>
<fileset dir="core/src/conf" includes="**"/>
<fileset dir="drivers/src/test" includes="**/*.properties **/*.sql **/*.xml"/>
<fileset dir="drivers/src/conf" includes="**"/>
<fileset dir="tools/src/test" includes="**/*.properties **/*.sql **/*.xml"/>
<fileset dir="tools/src/conf" includes="**"/>
</copy>
<mkdir dir="${tests.xml.report.dir}"/>
</target>
<target name="run" depends="init, instrument">
<!--Executing junit-->
<junit fork="on" forkmode="once" errorproperty="unit.tests.failed">
<sysproperty key="net.sourceforge.cobertura.datafile" file="${instrumented.dir}/cobertura.ser"/>
<classpath>
<pathelement location="${instrumented.dir}"/>
<pathelement location="${classes}"/>
<pathelement location="${testclasses}"/>
<path refid="classpath"/>
<path refid="cobertura.classpath"/>
</classpath>
<formatter type="xml"/>
<batchtest todir="${tests.xml.report.dir}">
<fileset dir="core/src/test" includes="**/*Test.java" excludes="**/*PerfTest.java"/>
<fileset dir="drivers/src/test" includes="**/*Test.java" excludes="**/*PerfTest.java"/>
<fileset dir="tools/src/test" includes="**/*Test.java" excludes="**/*PerfTest.java"/>
</batchtest>
</junit>
</target>
<target name="report" depends="init, instrument, run">
<description>
Generate an HTML file containing the coverage data
</description>
<!--Deletes report dir to clear previous reports-->
<delete dir="${coverage.junit.report.dir}" failonerror="no"/>
<mkdir dir="${coverage.junit.report.dir}"/>
<junitreport todir="${coverage.junit.report.dir}">
<fileset dir="${tests.xml.report.dir}">
<include name="TEST-*.xml"/>
</fileset>
<report todir="${coverage.junit.report.dir}"/>
</junitreport>
<delete dir="${coverage.report.dir}" failonerror="no"/>
<mkdir dir="${coverage.report.dir}"/>
<cobertura-report destdir="${coverage.report.dir}" datafile="${instrumented.dir}/cobertura.ser">
<fileset dir="core/src/java" includes="**/*.java" excludes="**/*Test.java"/>
<fileset dir="drivers/src/java" includes="**/*.java" excludes="**/*Test.java"/>
<fileset dir="tools/src/java" includes="**/*.java" excludes="**/*Test.java"/>
</cobertura-report>
<fail if="unit.tests.failed" message="JUnit test failed see ${coverage.junit.report.dir}"/>
</target>
</project>