forked from cwarden/kettle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_coverage.xml
199 lines (166 loc) · 6.5 KB
/
build_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
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
<?xml version="1.0" encoding="UTF-8"?>
<project name="cobertura.examples.basic" default="coverage" basedir=".">
<tstamp>
<format property="current.date" pattern="MM-dd-yyyy" locale="en" />
</tstamp>
<property file="build.properties"/>
<path id="kettle_classpath">
<fileset dir="${cobertura.dir}">
<include name="cobertura.jar" />
</fileset>
<fileset dir="${lib.dir}">
<include name="**/*.jar" />
<!-- exclude name="**/asm*.jar" / -->
</fileset>
<fileset dir="${lib}" includes="kettle-engine-3.0.jar"/>
<fileset dir="test/libext/" includes="kettle.jar"/>
<!-- fileset dir="test/libext/" includes="junit.jar"/ -->
<pathelement path="${testClasses}"/>
<fileset dir="${libext}" includes="*.jar *.zip"/>
<fileset dir="${libext}/" includes="**/*.jar *.zip"/>
<fileset dir="${libswt}" includes="*.jar *.zip"/>
<fileset dir="${libswt}/win32/" includes="*.jar *.zip"/>
</path>
<!-- Declare filesets for classes that will be instrumented. -->
<!-- Ignore classes with names ending in "Test". -->
<fileset id="classes" dir="${classes}">
<include name="**/*.class" />
<exclude name="**/*Test.class" />
</fileset>
<fileset id="classes-core" dir="${classes-core}">
<include name="**/*.class" />
<exclude name="**/*Test.class" />
</fileset>
<fileset id="classes-ui" dir="${classes-ui}">
<include name="**/*.class" />
<exclude name="**/*Test.class" />
</fileset>
<taskdef classpathref="kettle_classpath" resource="tasks.properties" />
<target name="clean-all" description="Remove all files created by the build/test process.">
<delete dir="${instrumented.dir}" />
<delete dir="${reports.dir}" />
<delete dir="${coverage.dir}" />
<delete file="cobertura.log" />
<delete file="cobertura.ser" />
</target>
<target name="clean-kettle-instrumented-classes">
<!--
Remove the coverage data file and any old instrumentation.
-->
<delete file="cobertura.ser" />
<delete dir="${instrumented.dir}" />
</target>
<target name="clean-kettle-test-reports">
<delete dir="${reports.dir}" />
</target>
<target name="clean-kettle-coverage-reports">
<delete dir="${coverage.dir}" />
</target>
<target name="init-instrument-kettle-classes">
<mkdir dir="${instrumented.dir}" />
</target>
<target name="init-kettle-test-reports">
<mkdir dir="${reports.xml.dir}" />
<mkdir dir="${reports.html.dir}" />
</target>
<target name="init-kettle-coverage-reports">
<mkdir dir="${coverage.xml.dir}" />
<mkdir dir="${coverage.html.dir}" />
</target>
<target name="compile">
<javac destdir="${classes}" debug="yes" source="5" target="5" fork="true">
<src path="${src}" />
<src path="${test}" />
<classpath refid="kettle_classpath" />
</javac>
</target>
<target name="instrument-kettle-classes" depends="init-instrument-kettle-classes">
<!--
Instrument the application classes, writing the
instrumented classes into ${build.instrumented.dir}.
-->
<cobertura-instrument todir="${instrumented.dir}">
<!--
The following line causes instrument to ignore any
source line containing a reference to log4j, for the
purposes of coverage reporting.
-->
<ignore regex="org.pentaho.logging.*" />
<fileset refid="classes"/>
<fileset refid="classes-core"/>
<fileset refid="classes-ui"/>
</cobertura-instrument>
<!--
Cobertura does not instrument all of the classes. Some are skipped, which
leaves an incomplete list of classes for testing, which will cause the tests
to throw exceptions for the missing classes. To fix this, we do a non-overwriting
copy from the original classs directory tree to the instrumented class directory tree.
This finds the missing class files and puts copies of them into the instrumented tree.
-->
<copy todir="${instrumented.dir}" overwrite="false" verbose="true">
<fileset refid="classes"/>
<fileset refid="classes-core"/>
<fileset refid="classes-ui"/>
</copy>
</target>
<target name="test" depends="init-kettle-test-reports">
<junit fork="yes" dir="${basedir}" failureProperty="test.failed">
<!--
Note the classpath order: instrumented classes are before the
original (uninstrumented) classes. This is important.
-->
<classpath location="${instrumented.dir}" />
<classpath location="${classes}" />
<!--
The instrumented classes reference classes used by the
Cobertura runtime, so Cobertura and its dependencies
must be on your classpath.
-->
<classpath refid="kettle_classpath" />
<formatter type="xml" />
<test name="${testcase}" todir="${reports.xml.dir}" if="testcase" />
<batchtest todir="${reports.xml.dir}" unless="testcase">
<fileset dir="${test}">
<include name="**/*Test.java" />
</fileset>
</batchtest>
</junit>
<junitreport todir="${reports.xml.dir}">
<fileset dir="${reports.xml.dir}">
<include name="TEST-*.xml" />
</fileset>
<report format="frames" todir="${reports.html.dir}" />
</junitreport>
</target>
<target name="coverage-check">
<cobertura-check branchrate="34" totallinerate="100" />
</target>
<target name="coverage-report">
<!--
Generate an XML file containing the coverage data using
the "srcdir" attribute.
-->
<cobertura-report srcdir="${src}" destdir="${coverage.xml.dir}" format="xml" />
</target>
<target name="alternate-coverage-report">
<!--
Generate a series of HTML files containing the coverage
data in a user-readable form using nested source filesets.
-->
<cobertura-report destdir="${coverage.html.dir}">
<fileset dir="${src}">
<include name="**/*.java" />
</fileset>
</cobertura-report>
</target>
<target name="zip-reports" depends="coverage">
<mkdir dir="${dist.dir}"/>
<mkdir dir="${deploy.dir}"/>
<zip destfile="${dist.dir}/${product.name}-${product.release.type}-reports-${release.version}${release.status.token}.zip">
<zipfileset dir="${reports.dir}" prefix="kettle-tests" />
<zipfileset dir="${coverage.dir}" prefix="kettle-coverage" />
</zip>
<unzip src="${dist.dir}/${product.name}-${product.release.type}-reports-${release.version}${release.status.token}.zip" dest="${deploy.dir}"/>
</target>
<target name="coverage" depends="clean-all, instrument-kettle-classes,test,coverage-report,alternate-coverage-report" description="Compile, instrument ourself, run the tests and generate JUnit and coverage reports." />
</project>