blob: cf71907f45d6c9ea5f7d8228691ef4acc499a5f1 [file] [log] [blame]
Stephan Herrmann20dbe5d2022-05-03 16:36:38 +02001<?xml version="1.0" encoding="UTF-8"?>
2<!--
3 Copyright (c) 2001,2015 IBM Corporation and others.
4
5 This program and the accompanying materials
6 are made available under the terms of the Eclipse Public License 2.0
7 which accompanies this distribution, and is available at
8 https://www.eclipse.org/legal/epl-2.0/
9
10 SPDX-License-Identifier: EPL-2.0
11
12 Contributors:
13 IBM Corporation - initial API and implementation
14 -->
15
16<project
17 name="Library"
18 default="usage"
19 basedir=".">
20
21 <target name="usage">
22 <echo message="Please refer to https://wiki.eclipse.org/Platform-releng/Eclipse_Test_Framework for instructions on usage." />
23 </target>
24
25 <target
26 name="init"
27 unless="testframeworkinitialized">
28 <!--
29
30 Parameters:
31
32 (Mandatory)
33
34 data-dir - the directory for Eclipse to write its data
35
36 plugin-name - the name of the plugin to test
37
38 classname - the name of the test class
39
40
41 (Optional - added to (or overrides) defaults set in infrastructure scripts)
42
43 vmargs (1) - a string containing arguments to pass to the VM. These
44 parameters should be specific, but permanent, to the test plugin
45 that uses them. For example, a jdt core test plugin might use
46 vmargs="-DstoreMemory=jdtcoremodel_mem_trace,dir=${basedir}/../..".
47 Note, normally test plugins do not need to specify -Xmx
48 or -XX:MaxPermSize type parameters as they are set by
49 the test infrastructure depending machine, OS, VM version, etc,
50 unless of course the test plugins needs especially low or high values,
51 as part of the test.
52
53 extraVMargs (1) - allows separate setting of VM args in a setting other than
54 the production runs of automated tests. Should not normally be
55 "hard coded" in to the test plugin itself, but instead reserved
56 for someone to add arguments in some other setting other then
57 the production test environment. For example,
58 a committer to jdt.core might want to do a quick test before
59 a commit, and use
60 extraVMargs="-Dcompliance=1.7"
61 in some local version of testing scripts.
62 Can also be used to do "remote debugging"; See
63 https://wiki.eclipse.org/Platform-releng/Automated_Testing#Running_Tests
64
65 timeout - overrides default test timeout value (in milliseconds). [May not currently override default?]
66
67 test-output - overrides default output file produced from test run. [May not currently override default?]
68
69 plugin-path - path to root of plug-in
70
71 useEclipseExe - property setting forces test to launch via eclipse executable. [Not fully supported. See bug 387638.]
72
73 junit-report-output - output directory for junit reports produced for specified classname.
74
75
76 (Environment Variables - environment variables that the test framework uses or passes through)
77
78 ANT_OPTS (1) - Carry through the ANT_OPTS environment variable settings, if any. As described in
79 http://ant.apache.org/manual/running.html
80 <quote>
81 ANT_OPTS - command-line arguments that should be passed to the JVM.
82 For example, you can define system properties or set the
83 maximum Java heap size here.
84 </quote>
85 This can be important for some environments such as running tests on eclipse.org Hudson,
86 where proxy servers, etc., can be defined for that Hudson instance by the machine itself.
87
88 (Reserved - documented here for awareness, but reserved for use by the test infrastructure
89 itself. The test infrastructure sets these based on typical, common, or required values
90 for the production test environment.)
91
92 frameworkvmargs (1) - vm args provided by the automated test infrastructure. Normally, these arguments
93 provide parameters for cases that apply to all test suites as ran in a production environment,
94 such as -Xms, -Xmx, -XstartOnFirstThread
95 where these values may vary based on machine or VM being used.
96
97 loglocation - some VMs allow crash log location to specified as VM parameter (but,
98 pretty special, limited usefulness and may be removed.
99
100 Notes:
101
102 1) Note how vm arguments are ordered. The vm arguments variables are combined in order:
103
104 ${frameworkvmargs} ${ANT_OPTS} ${vmargs} ${extraVMargs}
105
106 Typically (as far as is known) if the same argument is specified twice,
107 the one appearing last in the line takes priority. For example, if
108 vmargs specified -Dtestarg=one and
109 extraVMargs specified -Dtestarg=two,
110 then "two" could be the value of the testarg property at runtime.
111
112 -->
113 <property environment="env" />
114
115 <condition
116 property="envantopts"
117 value="${env.ANT_OPTS}"
118 else="">
119 <isset property="env.ANT_OPTS" />
120 </condition>
121
122
123 <echo message="ANT_OPTS: ${env.ANT_OPTS}" />
124
125 <tstamp>
126 <format
127 property="TIMENOW"
128 pattern="HHmmssSSSS" />
129 </tstamp>
130 <!--property setting useEclipseExe launches tests using the eclipse executable-->
131 <condition
132 property="launchTarget"
133 value="eclipse-test">
134 <isset property="useEclipseExe" />
135 </condition>
136 <!--default launch target for launching tests-->
137 <property
138 name="launchTarget"
139 value="java-test" />
140 <property
141 name="formatter"
142 value="org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter" />
143
144 <tstamp prefix="NOW" />
145 <property
146 name="coverage-output"
147 value="${eclipse-home}/coverage" />
148 <property file="${basedir}/finalPluginsVersions.properties" />
149 <echo message="basedir = ${basedir}" />
150 <property
151 name="vmargs"
152 value="" />
153 <property
154 name="extraVMargs"
155 value="" />
156 <property
157 name="plugin-path"
158 value="" />
159
160 <property
161 name="timeout"
162 value="7200000" />
163 <property
164 name="test-output"
165 value="${eclipse-home}/${classname}.xml" />
166 <property
167 name="junit-report-output"
168 value="${eclipse-home}/results" />
169 <mkdir dir="${junit-report-output}" />
170 <property
171 name="junit-stylesheet"
172 value="${basedir}/JUNIT.XSL" />
173 <property
174 name="testframeworkinitialized"
175 value="true" />
176 <echoproperties description="Echo Properties at end of init in library.xml" />
177 </target>
178
179 <target
180 name="core-test"
181 description="Eclipse application used to launch HEADLESS plugin tests."
182 depends="init">
183 <antcall target="${launchTarget}">
184 <param
185 name="application"
186 value="org.eclipse.test.coretestapplication" />
187 </antcall>
188 </target>
189
190 <target
191 name="ui-test"
192 description="Eclipse application used to launch UI plugin tests."
193 depends="init">
194 <antcall target="${launchTarget}">
195 <param
196 name="application"
197 value="org.eclipse.test.uitestapplication" />
198 </antcall>
199 </target>
200
201 <target
202 name="java-test"
203 depends="init">
204 <echo
205 level="debug"
206 message="DEBUG: Running tests using java-test" />
207 <!--default vm args Note: the goal is to use same values as what would be in eclipse.ini -->
208 <condition
209 property="frameworkvmargs"
210 value=" -Xms256m -Xmx2048m ${envantopts}">
211 <os family="windows" />
212 </condition>
213 <!--
214 For more info on -XstartOnFirstThread, see
215 http://stackoverflow.com/questions/3976342/running-swt-based-cross-platform-jar-properly-on-a-mac
216 -->
217 <condition
218 property="frameworkvmargs"
219 value=" -XstartOnFirstThread -Xms256m -Xmx2048m ${envantopts}">
220 <os family="mac" />
221 </condition>
222 <property
223 name="frameworkvmargs"
224 value=" -Xms256m -Xmx2048m ${envantopts}" />
225
226 <condition
227 property="loglocation"
228 value=" ${loglocationarg}=${junit-report-output}/${classname}-crash.log"
229 else="">
230 <isset property="loglocationarg" />
231 </condition>
232
233 <!--set default jvm to use for testing-->
234 <property
235 name="jvm"
236 value="${java.home}/bin/java" />
237
238 <!-- if not set by caller, set frameworkperfargs to blank -->
239 <property name="frameworkperfargs" value=""/>
240
241 <echo message="Running ${classname}. Result file: ${junit-report-output}/${classname}.xml" />
242 <echo message="timout property: ${timeout}" />
243
244 <echo message="frameworkvmargs: ${frameworkvmargs}" />
245 <echo message="vmargs: ${vmargs}" />
246 <echo message="extraVMargs: ${extraVMargs}" />
247 <echo message="frameworkperfargs: ${frameworkperfargs}" />
248 <echo message="crash loglocationarg (if any): ${loglocationarg}" />
249 <echo message="crash loglocation (if not default): ${loglocation}" />
250
251 <java
252 fork="true"
253 dir="."
254 timeout="${timeout}"
255 jvm="${jvm}"
256 logError="true"
257 classname="org.eclipse.core.launcher.Main"
258 output="${junit-report-output}/${classname}.txt">
259 <classpath>
260 <fileset dir="${eclipse-home}/plugins">
261 <include name="org.eclipse.equinox.launcher_*.jar" />
262 </fileset>
263 </classpath>
264 <arg line="-application ${application}" />
265 <arg line="-data ${data-dir}" />
266 <arg line="formatter=${formatter},${test-output}" />
267 <arg line="-testPluginName ${plugin-name}" />
268 <arg line="-className ${classname}" />
269 <arg line="-os ${os}" />
270 <arg line="-ws ${ws}" />
271 <arg line="-arch ${arch}" />
272 <arg line="-consolelog" />
273 <arg line="-timeout ${timeout}" />
274 <arg value="-junitReportOutput" />
275 <arg path="${junit-report-output}" />
276 <jvmarg line="${frameworkvmargs} ${loglocation} ${vmargs} ${extraVMargs} ${frameworkperfargs}" />
277 <sysproperty
278 key="PLUGIN_PATH"
279 value="${plugin-path}" />
280 </java>
281 <antcall target="collect-results" />
282 </target>
283
284 <target
285 name="eclipse-test"
286 description="Runs the specified classname as a plug-in test."
287 depends="init">
288 <echo
289 level="debug"
290 message="DEBUG: Running tests using eclipse-test" />
291
292 <!--use -consolelog if launching a headless test-->
293 <condition
294 property="consolelog"
295 value="-consolelog">
296 <equals
297 arg1="${application}"
298 arg2="org.eclipse.test.coretestapplication" />
299 </condition>
300 <property
301 name="consolelog"
302 value="" />
303
304 <!--
305 vm selection priority:
306 1. user-specified java executable via outer Ant property setting of "jvm".
307 2. java executable on path.
308 -->
309 <condition
310 property="test-vm"
311 value="-vm ${jvm}">
312 <isset property="jvm" />
313 </condition>
314 <property
315 name="test-vm"
316 value="" />
317
318 <!--ensure executable has execute permission-->
319 <chmod
320 file="${eclipse-home}/eclipse"
321 perm="ugo+rx" />
322
323
324 <echo message="Running ${classname}. Result file: ${junit-report-output}/${classname}.xml." />
325
326 <exec
327 executable="${eclipse-home}/eclipse"
328 dir="${eclipse-home}"
329 timeout="${timeout}"
330 logError="true"
331 failonerror="false"
332 output="${junit-report-output}/${classname}.txt">
333 <arg line="-data ${data-dir}" />
334 <arg line="${test-vm}" />
335 <arg line="-application ${application}" />
336 <arg line="formatter=${formatter},${test-output}" />
337 <arg line="-testPluginName ${plugin-name}" />
338 <arg line="-className ${classname}" />
339 <arg line="-nosplash" />
340 <arg line="--launcher.suppressErrors" />
341 <arg line="${consolelog}" />
342 <arg line="-vmargs ${frameworkvmargs} ${loglocation} ${vmargs} ${extraVMargs} -DPLUGIN_PATH=${plugin-path}" />
343 </exec>
344 <antcall target="collect-results" />
345 </target>
346
347 <target name="collect-results">
348 <dirname
349 property="output-dir"
350 file="${test-output}" />
351 <basename
352 property="output-file-name"
353 file="${test-output}" />
354 <junitreport
355 todir="${junit-report-output}"
356 tofile="${classname}.xml">
357 <fileset dir="${output-dir}">
358 <include name="${output-file-name}" />
359 </fileset>
360 </junitreport>
361
362
363 <!--save .log content and *.log content from configuration directory-->
364 <concat destfile="${junit-report-output}/${classname}.log">
365 <fileset
366 dir="${eclipse-home}"
367 includes="${data-dir}/.metadata/*.log" />
368 <fileset
369 dir="${eclipse-home}"
370 includes="configuration/*.log" />
371 </concat>
372
373 <!-- save any crash logs generated (before they are deleted by subsequent test runs -->
374 <!--
375 TODO: not all VM's call their crash logs "hs_err_pid*.log".
376 We can expand the list as we learn of others
377 -->
378 <copy todir="${junit-report-output}/crashlogs/">
379 <fileset dir="${eclipse-home}">
380 <include name="**/hs_err_pid*.log" />
381 </fileset>
382 <globmapper
383 from="*"
384 to="${classname}.*" />
385 </copy>
386 </target>
387
388 <target name="collect">
389 <!--
390 This target can be used to aggragate test runs from multiple test suites into a single report.
391
392 Parameters to this target:
393 includes - the names of the files to include
394 output-file - the name of the output file to produce
395 -->
396 <junitreport
397 todir="."
398 tofile="${output-file}">
399 <fileset dir=".">
400 <include name="${includes}" />
401 </fileset>
402 </junitreport>
403 </target>
404
405</project>