blob: 90b3d986a61c58367834b5e37a9f78a3288e0665 [file] [log] [blame]
david_williams2ba99e92011-05-12 23:08:09 +00001<project
2 name="Build specific targets and properties"
3 default="runTest">
4 <!--
5 Note to be cross-platform, "environment variables" are only
6 appropriate for some variables, e.g. ones we set, since
7 properties are case sensitive, even if the environment variables
8 on your operating system are not, e.g. it will be ${env.Path}
9 not ${env.PATH} on Windows
10 -->
11 <property environment="env"/>
12 <fail
13 message="testRoot must be set for this task"
14 unless="testRoot"/>
15 <!-- required to get proper value of branch specific values -->
16 <property
17 name="keyCfgFile"
18 value="${env.PROJECT_BUILDERS}/${projectname}/${env.RELENG}/maps/build.cfg"/>
19 <echo
20 level="debug"
21 message="keyCfgFile: ${keyCfgFile}"/>
22 <property file="${keyCfgFile}"/>
23 <!--
24 typcially already set, but in case of standalone tests, may not
25 be
26 -->
27 <property
28 name="buildLabel"
29 value="${buildType}-${buildId}-${timestamp}"/>
30
31
32 <!--
33 Steps to do after the build is done.
34 -->
35 <target name="test">
36 <dirname
37 file="${ant.file}"
38 property="currentDirectory"/>
39 <ant
40 antfile="${ant.file}"
41 target="runTest"
42 dir="${currentDirectory}"/>
43 </target>
44
45 <!--
46 Steps to do to test the build results
47 -->
48 <target name="runTest">
49 <dirname
50 file="${ant.file}"
51 property="test.component.dir"/>
52 <ant antfile="${wtp.builder.home}/scripts/build/label.xml"/>
53 <property file="${buildDirectory}/label.properties"/>
54 <property file="${wtp.builder.home}/build.properties"/>
55 <fail
56 message="testRoot must be set for this task"
57 unless="testRoot"/>
58 <mkdir dir="${testRoot}"/>
59
60 <!-- if results already exist, delete them -->
61 <delete
62 quiet="true"
63 dir="${testRoot}/results"
64 failOnError="false"/>
65 <mkdir dir="${testRoot}/results"/>
66 <mkdir dir="${testRoot}/results/consolelogs"/>
67 <copy
68 todir="${testRoot}"
69 overwrite="true">
70 <fileset dir="${test.component.dir}/testScripts"/>
71 </copy>
72 <echo level="debug" message="BASEOS: ${env.BASEOS} BASEWS: ${env.BASEWS} BASEARCH: ${env.BASEARCH} "/>
73
74 <property
75 name="dependency.properties"
76 value="${buildDirectory}/maps/${env.RELENG}/${dependencyFileLocation}"/>
77 <available
78 file="${dependency.properties}"
79 property="dependency.properties.exists"/>
80 <fail
81 message="dependency file not found: ${dependency.properties}"
82 unless="dependency.properties.exists"/>
83 <property
84 name="test.dependency"
85 value="${wtp.builder.home}/scripts/dependency/dependency.xml"/>
86 <available
87 file="${test.dependency}"
88 property="test.dependency.exists"/>
89 <fail
90 message="test dependency file not found: ${test.dependency}"
91 unless="test.dependency.exists"/>
92 <echo level="debug" message="test.dependency file: ${test.dependency}"/>
93 <ant
94 antfile="${test.dependency}"
95 target="get">
96 <property
97 name="base.install.dir"
98 value="${testRoot}"/>
99 <property
100 name="tobeinstalled.properties"
101 value="${buildDirectory}/maps/${env.RELENG}/distribution/${build.distribution}.tests/tobeInstalled.properties"/>
102
103 <property
104 name="installWorkingDirectory"
105 value="${testRoot}"/>
106
107
108
109 </ant>
110 <antcall target="installTests"/>
111 <antcall target="runTestEclipse">
112 <param
113 name="testTarget"
114 value="all"/>
115 </antcall>
116 <antcall target="postRunTestEclipse">
117 <param
118 name="testTarget"
119 value="all"/>
120 </antcall>
121 </target>
122
123 <!--
124 note: the 'test.installed' attribute is a temporary hack
125 to allow standalone tests to do the install themselves.
126 Eventually, this script should be improved so this hack would
127 be not required. The "location" of the
128 zips/repos are indirectly currently "hard coded" to
129 be in /projects/... but
130 this should become a variable, sometimes (maybe)
131 set to /projects/...,
132 more often set to some URL from committers or downloads pages.
133 See the repos values below in repo install:
134 value="file://${buildDirectory}/${buildLabel}/repository/,file://${buildDirectory}/${buildLabel}/repositoryunittests/"/>
135 These should be changed to be something like
136 value="${coderepo},${unittestsrepo}"/>
137 Or similar. Then could be set as desired.
138 -->
139 <target
140 name="installTests"
141 unless="test.installed">
142
david_williams23380612011-05-16 23:24:28 +0000143
david_williams2ba99e92011-05-12 23:08:09 +0000144 <antcall target="installTestsFromRepo">
145 </antcall>
david_williams23380612011-05-16 23:24:28 +0000146
david_williams2ba99e92011-05-12 23:08:09 +0000147
148 </target>
149
150 <target
151 name="installTestsFromZips"
152 depends="init">
153
154 <!-- a bit hard coded here, will need work for general case -->
155 <property
156 name="zipFile"
157 value="${compName}-${buildLabel}.zip"/>
158
159
160 <!--
161 We use the exec method for unzip, so we won't fail if a
162 prereq can not be unzipped for some reason. See
163 https://bugs.eclipse.org/bugs/show_bug.cgi?id=283968
164-->
165 <mkdir dir="${install.destination}"/>
166 <exec
167 dir="."
168 executable="unzip">
169 <arg line="-o -qq ${buildDirectory}/${buildLabel}/${zipFile} -d ${install.destination}/${compName}"/>
170 </exec>
171
172 </target>
173
174 <target name="installTestsFromRepo">
175
176 <java
177 taskname="p2Director Install"
178 fork="true"
179 resultProperty="p2DirectorInstallResult"
180 failonerror="false"
181 timeout="${testTimeLimit}"
182 dir="${testRoot}"
183 jvm="${env.JAVA_6_HOME}/bin/java"
184 classname="org.eclipse.equinox.launcher.Main">
185 <classpath>
186 <fileset dir="${testRoot}/eclipse/plugins">
187 <include name="org.eclipse.equinox.launcher_*.jar"/>
188 </fileset>
189 </classpath>
190 <jvmarg value="-Djava.io.tmpdir=${env.RECOMMENDED_TMP_DIR}"/>
191 <jvmarg value="-Dwtp.builder.home=${wtp.builder.home}"/>
192 <jvmarg value="-Dbuild.distribution=${build.distribution}"/>
193 <arg value="-nosplash"/>
194 <arg value="-debug"/>
195 <arg value="-consolelog"/>
196 <arg value="-data"/>
197 <arg value="${testRoot}/p2DirectorInstall"/>
198 <arg value="-application"/>
199 <arg value="org.eclipse.equinox.p2.director"/>
200 <arg value="-destination"/>
201 <arg value="${testRoot}/eclipse"/>
202
203 <arg value="-repository"/>
david_williamsa07c6b32011-05-16 23:47:06 +0000204 <arg value="file://${buildDirectory}/${buildLabel}/repository/"/>
205 <!--
206 <arg value="file://${buildDirectory}/${buildLabel}/repository/,file://${buildDirectory}/${buildLabel}/repositoryunittests/"/>
207 -->
208 <arg value="-installIU"/>
david_williams2ba99e92011-05-12 23:08:09 +0000209 <arg value="${wtpFeatureIUs},${testFeatureIUs}"/>
210
211 <!-- make sure our forked env has a DISPLAY -->
212 <env
213 key="DISPLAY"
214 value="${env.DISPLAY}"/>
215 <redirector
216 output="${testRoot}/results/fullOutput.txt"
217 error="${testRoot}/results/fullErrorLog.txt"/>
218
219 </java>
220 <!-- If the task succeeds, this ouput log won't be that relevent ... (can be make better in future ... but for now we'll make a copy,
221 just in case we need it -->
222 <echo level="debug" message="p2DirectorInstallResult: ${p2DirectorInstallResult}"/>
223
224 <condition property="p2DirectorInstallFailed">
225 <not>
226 <equals
227 arg1="0"
228 arg2="${p2DirectorInstallResult}"/>
229 </not>
230 </condition>
231
232<!-- always copy to test results, even when successful -->
233 <copy
234 file="${testRoot}/results/fullOutput.txt"
235 tofile="${buildDirectory}/${buildLabel}/testResults/p2DirectorInstall.log.txt"
236 overwrite="false"
237 failonerror="false">
238 </copy>
239
240 <antcall target="handleFailedInstall"/>
241
242
243 </target>
244 <target
245 name="handleFailedInstall"
246 if="p2DirectorInstallFailed">
247
248 <!-- copy to direct location, as a signal (to web pages) it failed and link should be provided -->
249 <copy
250 file="${testRoot}/results/fullOutput.txt"
251 tofile="${buildDirectory}/${buildLabel}/p2DirectorInstall.log.txt"
252 overwrite="false"
253 failonerror="false">
254 </copy>
255
256 <fail
257 message="installation of tests failed. See p2DirectorInstall.log.txt."
258 if="p2DirectorInstallResult"/>
259
260 </target>
261 <!--
262 time out may need to be set/adjust for api or performance tests?
263 This testTimeLimit is the whole, overall limit on tests. There's
264 a shorter one for individual suites. some common values, of
265 milliseconds to more recognizable units:
266 14400000: 4 hours
267 7200000: 2 hours
268 3600000: 1 hour
269 1800000: 30 minutes
270 600000: 10 minutes
271 -->
272 <property
273 name="testTimeLimit"
274 value="28800000"/>
275 <property
276 name="testFailOnError"
277 value="false"/>
278 <target
279 name="runTestEclipse"
280 description="Run our JUnit's within an instance of antRunner">
281 <property
282 name="test-vm"
283 value="${env.JAVA_6_HOME}/bin/java"/>
284 <!--
285 set path to eclipse folder. If local folder, use '.';
286 otherwise, use c:\path\to\eclipse or /path/to/eclipse/
287 -->
288 <property
289 name="eclipse.home"
290 value="${testRoot}"/>
291 <echo level="debug" message="testTarget: ${testTarget}"/>
292 <!--
293 can not pass in empty values in jvmargs so if not testBundle
294 specified, we'll pass a junk (unused) value
295 -->
296 <condition
297 property="testBundleParam"
298 value="-DtestBundle=${testBundle}"
299 else="-Dunused=nouse">
300 <isset property="testBundle"/>
301 </condition>
302 <echo message="Running junits"/>
303 <!--
304 If there is not exactly one launcher in the stack, we'd best
305 fail fast, since we are not expecting that, and may indicate
306 an installation that would produce unpredictable results
307 -->
308 <!--
309 requires ant 1.7, and at this point, we're running 1.6 from
310 eclipse ... <condition property="expectedNumberOfLaunchers">
311 <resourcecount when="equal" count="1" > <fileset
312 dir="${testRoot}/eclipse/plugins"> <include
313 name="org.eclipse.equinox.launcher_*.jar" /> </fileset>
314 </resourcecount> </condition> <fail message="Did not find
315 expected number of launcher jars. Check installation."
316 unless="expectedNumberOfLaunchers" />
317 -->
318
319 <condition
320 property="antQuietValue"
321 value="-quiet"
322 else="">
323 <istrue value="${env.USE_QUIET}"/>
324 </condition>
325 <java
326 taskname="unit-test-masterprocess"
327 fork="true"
328 resultProperty="wtpmasterjunitresult"
329 failonerror="false"
330 timeout="${testTimeLimit}"
331 dir="${testRoot}/eclipse"
332 jvm="${env.JAVA_6_HOME}/bin/java"
333 classname="org.eclipse.equinox.launcher.Main">
334 <classpath>
335 <fileset dir="${testRoot}/eclipse/plugins">
336 <include name="org.eclipse.equinox.launcher_*.jar"/>
337 </fileset>
338 </classpath>
339 <jvmarg value="-Dosgi.ws=${env.BASEWS}"/>
340 <jvmarg value="-Dosgi.os=${env.BASEOS}"/>
341 <jvmarg value="-Dosgi.arch=${env.BASEARCH}"/>
342 <jvmarg value="-Dws=${env.BASEWS}"/>
343 <jvmarg value="-Dos=${env.BASEOS}"/>
344 <jvmarg value="-Darch=${env.BASEARCH}"/>
345 <jvmarg value="-DbuildBranch=${buildBranch}"/>
346 <jvmarg value="-DbuildType=${buildType}"/>
347 <jvmarg value="-DdependencyFileLocation=${dependencyFileLocation}"/>
348 <jvmarg value="-DbuildId=${buildId}"/>
349 <jvmarg value="-Dprojectname=${projectname}"/>
350 <jvmarg value="-Djava.io.tmpdir=${env.RECOMMENDED_TMP_DIR}"/>
351 <jvmarg value="-Dwtp.builder.home=${wtp.builder.home}"/>
352 <jvmarg value="-Dbuild.distribution=${build.distribution}"/>
353 <jvmarg value="${testBundleParam}"/>
354 <arg value="-nosplash"/>
355 <arg value="-consolelog"/>
356 <arg value="-data"/>
357 <arg value="${testRoot}/overallTestWorkspace"/>
358 <arg value="-application"/>
359 <arg value="org.eclipse.ant.core.antRunner"/>
360 <arg value="${antQuietValue}"/>
361 <arg value="-logger"/>
362 <arg value="org.apache.tools.ant.DefaultLogger"/>
363 <arg value="-file"/>
364 <arg value="${testRoot}/test.xml"/>
365 <arg value="${testTarget}"/>
366
367 <!-- make sure our forked env has a DISPLAY -->
368 <env
369 key="DISPLAY"
370 value="${env.DISPLAY}"/>
371 <redirector
372 output="${testRoot}/results/fullOutput.txt"
373 error="${testRoot}/results/fullErrorLog.txt"/>
374 <jvmarg value="-Dbuild.home=${env.BUILD_HOME}"/>
375 <jvmarg value="-DbuildDirectory=${buildDirectory}"/>
376 <jvmarg value="-DbuildLabel=${buildLabel}"/>
377 <jvmarg value="-DbaseLocation=${baseLocation}"/>
378 <jvmarg value="-DtestRoot=${testRoot}"/>
379 <jvmarg value="-DtestDir=${testRoot}"/>
380 <jvmarg value="-DeclipseBuilderDirectory=${pde.builder.path}"/>
381 <!--
382 <!- - IBM_JAVA_OPTIONS contains JIT work arounds for bug
383 284441 - -> <env key="IBM_JAVA_OPTIONS"
384 value="-Xjit:{org/eclipse/wst/html/core/internal/contenttype/HTMLHeadTokenizer.primGetNextToken()Ljava/lang/String;}(disableLookahead),{org/eclipse/jst/jsp/core/internal/parser/internal/JSPTokenizer.primGetNextToken()Ljava/lang/String;}(disableLookahead)"/>
385 -->
386 </java>
387 <echo message="wtpmasterjunitresult ${wtpmasterjunitresult}"/>
388 </target>
389 <target name="postRunTestEclipse">
390 <copy
391 todir="${buildDirectory}/${buildLabel}/testResults/consolelogs/testLogs"
392 overwrite="true"
393 failonerror="false">
394 <fileset dir="${testRoot}/results">
395 <include name="*output.txt"/>
396 </fileset>
397 </copy>
398 <copy
399 todir="${buildDirectory}/${buildLabel}/testResults/consolelogs/testSysErrorLogs"
400 overwrite="true"
401 failonerror="false">
402 <fileset dir="${testRoot}/results">
403 <include name="*error.txt"/>
404 </fileset>
405 </copy>
406 <copy
407 file="${testRoot}/results/fullOutput.txt"
408 toDir="${buildDirectory}/${buildLabel}/testResults/consolelogs/full"
409 overwrite="true"
410 failonerror="false">
411 </copy>
412 <copy
413 file="${testRoot}/results/fullErrorLog.txt"
414 toDir="${buildDirectory}/${buildLabel}/testResults/consolelogs/full"
415 overwrite="true"
416 failonerror="false">
417 </copy>
418 <copy
419 todir="${buildDirectory}/${buildLabel}/testResults/xml"
420 overwrite="true"
421 failonerror="false">
422 <fileset dir="${testRoot}/results/xml">
423 <include name="*.xml"/>
424 </fileset>
425 </copy>
426 <copy
427 todir="${buildDirectory}/${buildLabel}/testResults/html"
428 overwrite="true"
429 failonerror="false">
430 <fileset dir="${testRoot}/results/html">
431 <include name="*.html"/>
432 </fileset>
433 </copy>
434 <copy
435 todir="${buildDirectory}/${buildLabel}/testResults/"
436 overwrite="true"
437 failonerror="false">
438 <fileset dir="${testRoot}/results/">
439 <include name="*.html"/>
440 </fileset>
441 </copy>
442 </target>
443
444 <target name="init">
445
446 <echo level="debug" message="dropinsFolder: ${dropinsFolder} "/>
447 <condition
448 property="install.destination"
449 value="${testRoot}${dropinsFolder}/"
450 else="${testRoot}/eclipse">
451 <isset property="dropinsFolder"/>
452 </condition>
453
454 </target>
455
456</project>