blob: 78201c13c2846492565cd343ff9e6fe45013d42d [file] [log] [blame]
david_williams12def432010-08-09 04:42:21 +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 -->
david_williams2398e362011-03-05 02:45:39 +000011 <property environment="env"/>
david_williams12def432010-08-09 04:42:21 +000012 <fail
13 message="testRoot must be set for this task"
14 unless="testRoot"/>
david_williamsba00a342011-03-12 05:11:19 +000015 <!-- required to get proper value of branch specific values -->
david_williams12def432010-08-09 04:42:21 +000016 <property
17 name="keyCfgFile"
18 value="${env.PROJECT_BUILDERS}/${projectname}/${env.RELENG}/maps/build.cfg"/>
19 <echo
david_williams14cadd12011-03-23 06:43:39 +000020 level="debug"
david_williams12def432010-08-09 04:42:21 +000021 message="keyCfgFile: ${keyCfgFile}"/>
david_williams2398e362011-03-05 02:45:39 +000022 <property file="${keyCfgFile}"/>
david_williams12def432010-08-09 04:42:21 +000023 <!--
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 -->
david_williams2398e362011-03-05 02:45:39 +000035 <target name="test">
david_williams12def432010-08-09 04:42:21 +000036 <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 -->
david_williams2398e362011-03-05 02:45:39 +000048 <target name="runTest">
david_williams12def432010-08-09 04:42:21 +000049 <dirname
50 file="${ant.file}"
51 property="test.component.dir"/>
david_williams2398e362011-03-05 02:45:39 +000052 <ant antfile="${wtp.builder.home}/scripts/build/label.xml"/>
53 <property file="${buildDirectory}/label.properties"/>
54 <property file="${wtp.builder.home}/build.properties"/>
david_williams12def432010-08-09 04:42:21 +000055 <fail
56 message="testRoot must be set for this task"
57 unless="testRoot"/>
david_williams2398e362011-03-05 02:45:39 +000058 <mkdir dir="${testRoot}"/>
david_williams12def432010-08-09 04:42:21 +000059
60 <!-- if results already exist, delete them -->
61 <delete
david_williams14cadd12011-03-23 06:43:39 +000062 quiet="true"
david_williams12def432010-08-09 04:42:21 +000063 dir="${testRoot}/results"
64 failOnError="false"/>
david_williams2398e362011-03-05 02:45:39 +000065 <mkdir dir="${testRoot}/results"/>
66 <mkdir dir="${testRoot}/results/consolelogs"/>
david_williams12def432010-08-09 04:42:21 +000067 <copy
68 todir="${testRoot}"
69 overwrite="true">
david_williams2398e362011-03-05 02:45:39 +000070 <fileset dir="${test.component.dir}/testScripts"/>
david_williams12def432010-08-09 04:42:21 +000071 </copy>
david_williams14cadd12011-03-23 06:43:39 +000072 <echo level="debug" message="BASEOS: ${env.BASEOS} BASEWS: ${env.BASEWS} BASEARCH: ${env.BASEARCH} "/>
david_williams12def432010-08-09 04:42:21 +000073
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"/>
david_williams7e568c72010-09-12 09:04:15 +000083 <property
84 name="test.dependency"
david_williamsba00a342011-03-12 05:11:19 +000085 value="${wtp.builder.home}/scripts/dependency/dependency.xml"/>
david_williams7e568c72010-09-12 09:04:15 +000086 <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"/>
david_williams14cadd12011-03-23 06:43:39 +000092 <echo level="debug" message="test.dependency file: ${test.dependency}"/>
david_williams12def432010-08-09 04:42:21 +000093 <ant
94 antfile="${test.dependency}"
95 target="get">
96 <property
97 name="base.install.dir"
98 value="${testRoot}"/>
david_williamsba00a342011-03-12 05:11:19 +000099 <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
david_williams12def432010-08-09 04:42:21 +0000109 </ant>
david_williamsba00a342011-03-12 05:11:19 +0000110 <antcall target="installTests"/>
david_williams2398e362011-03-05 02:45:39 +0000111 <antcall target="runTestEclipse">
david_williams12def432010-08-09 04:42:21 +0000112 <param
113 name="testTarget"
114 value="all"/>
115 </antcall>
david_williams2398e362011-03-05 02:45:39 +0000116 <antcall target="postRunTestEclipse">
david_williams12def432010-08-09 04:42:21 +0000117 <param
118 name="testTarget"
119 value="all"/>
120 </antcall>
121 </target>
david_williamsba00a342011-03-12 05:11:19 +0000122
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
143 <!-- hard code for now
144 <antcall
145 target="installTestsFromZips">
146 <param
147 name="compName"
148 value="patches32x"/>
149 </antcall>
david_williams12def432010-08-09 04:42:21 +0000150 -->
david_williamsba00a342011-03-12 05:11:19 +0000151 <antcall target="installTestsFromRepo">
152 </antcall>
153
154
155 </target>
156
157 <target
158 name="installTestsFromZips"
159 depends="init">
160
161 <!-- a bit hard coded here, will need work for general case -->
162 <property
163 name="zipFile"
164 value="${compName}-${buildLabel}.zip"/>
165
166
167 <!--
168 We use the exec method for unzip, so we won't fail if a
169 prereq can not be unzipped for some reason. See
170 https://bugs.eclipse.org/bugs/show_bug.cgi?id=283968
171-->
172 <mkdir dir="${install.destination}"/>
173 <exec
174 dir="."
175 executable="unzip">
176 <arg line="-o -qq ${buildDirectory}/${buildLabel}/${zipFile} -d ${install.destination}/${compName}"/>
177 </exec>
178
179 </target>
180
181 <target name="installTestsFromRepo">
182
david_williams12def432010-08-09 04:42:21 +0000183 <java
184 taskname="p2Director Install"
185 fork="true"
186 resultProperty="p2DirectorInstallResult"
david_williamsba00a342011-03-12 05:11:19 +0000187 failonerror="false"
david_williams12def432010-08-09 04:42:21 +0000188 timeout="${testTimeLimit}"
189 dir="${testRoot}"
190 jvm="${env.JAVA_6_HOME}/bin/java"
191 classname="org.eclipse.equinox.launcher.Main">
192 <classpath>
david_williams2398e362011-03-05 02:45:39 +0000193 <fileset dir="${testRoot}/eclipse/plugins">
194 <include name="org.eclipse.equinox.launcher_*.jar"/>
david_williams12def432010-08-09 04:42:21 +0000195 </fileset>
196 </classpath>
david_williams2398e362011-03-05 02:45:39 +0000197 <jvmarg value="-Djava.io.tmpdir=${env.RECOMMENDED_TMP_DIR}"/>
david_williamsba00a342011-03-12 05:11:19 +0000198 <jvmarg value="-Dwtp.builder.home=${wtp.builder.home}"/>
199 <jvmarg value="-Dbuild.distribution=${build.distribution}"/>
david_williams2398e362011-03-05 02:45:39 +0000200 <arg value="-nosplash"/>
201 <arg value="-debug"/>
202 <arg value="-consolelog"/>
203 <arg value="-data"/>
204 <arg value="${testRoot}/p2DirectorInstall"/>
205 <arg value="-application"/>
206 <arg value="org.eclipse.equinox.p2.director"/>
207 <arg value="-destination"/>
208 <arg value="${testRoot}/eclipse"/>
david_williamsba00a342011-03-12 05:11:19 +0000209
david_williams2398e362011-03-05 02:45:39 +0000210 <arg value="-repository"/>
david_williamsba00a342011-03-12 05:11:19 +0000211 <arg value="file://${buildDirectory}/${buildLabel}/repository/,file://${buildDirectory}/${buildLabel}/repositoryunittests/"/>
david_williams2398e362011-03-05 02:45:39 +0000212 <arg value="-installIU"/>
213 <arg value="${wtpFeatureIUs},${testFeatureIUs}"/>
david_williams12def432010-08-09 04:42:21 +0000214
215 <!-- make sure our forked env has a DISPLAY -->
216 <env
217 key="DISPLAY"
218 value="${env.DISPLAY}"/>
219 <redirector
220 output="${testRoot}/results/fullOutput.txt"
221 error="${testRoot}/results/fullErrorLog.txt"/>
david_williams18da1202010-09-23 14:34:24 +0000222
david_williams12def432010-08-09 04:42:21 +0000223 </java>
david_williamsba00a342011-03-12 05:11:19 +0000224 <!-- 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,
225 just in case we need it -->
david_williams14cadd12011-03-23 06:43:39 +0000226 <echo level="debug" message="p2DirectorInstallResult: ${p2DirectorInstallResult}"/>
david_williamsba00a342011-03-12 05:11:19 +0000227
228 <condition property="p2DirectorInstallFailed">
229 <not>
230 <equals
231 arg1="0"
232 arg2="${p2DirectorInstallResult}"/>
233 </not>
234 </condition>
235
236<!-- always copy to test results, even when successful -->
237 <copy
238 file="${testRoot}/results/fullOutput.txt"
239 tofile="${buildDirectory}/${buildLabel}/testResults/p2DirectorInstall.log.txt"
240 overwrite="false"
241 failonerror="false">
242 </copy>
243
244 <antcall target="handleFailedInstall"/>
245
246
247 </target>
248 <target
249 name="handleFailedInstall"
250 if="p2DirectorInstallFailed">
251
252 <!-- copy to direct location, as a signal (to web pages) it failed and link should be provided -->
253 <copy
254 file="${testRoot}/results/fullOutput.txt"
255 tofile="${buildDirectory}/${buildLabel}/p2DirectorInstall.log.txt"
256 overwrite="false"
257 failonerror="false">
258 </copy>
259
260 <fail
261 message="installation of tests failed. See p2DirectorInstall.log.txt."
david_williams12def432010-08-09 04:42:21 +0000262 if="p2DirectorInstallResult"/>
david_williamsba00a342011-03-12 05:11:19 +0000263
david_williams12def432010-08-09 04:42:21 +0000264 </target>
265 <!--
266 time out may need to be set/adjust for api or performance tests?
267 This testTimeLimit is the whole, overall limit on tests. There's
268 a shorter one for individual suites. some common values, of
269 milliseconds to more recognizable units:
270 14400000: 4 hours
271 7200000: 2 hours
272 3600000: 1 hour
273 1800000: 30 minutes
274 600000: 10 minutes
275 -->
276 <property
277 name="testTimeLimit"
278 value="28800000"/>
279 <property
280 name="testFailOnError"
281 value="false"/>
282 <target
283 name="runTestEclipse"
284 description="Run our JUnit's within an instance of antRunner">
285 <property
286 name="test-vm"
287 value="${env.JAVA_6_HOME}/bin/java"/>
288 <!--
289 set path to eclipse folder. If local folder, use '.';
290 otherwise, use c:\path\to\eclipse or /path/to/eclipse/
291 -->
292 <property
293 name="eclipse.home"
294 value="${testRoot}"/>
david_williams14cadd12011-03-23 06:43:39 +0000295 <echo level="debug" message="testTarget: ${testTarget}"/>
david_williams12def432010-08-09 04:42:21 +0000296 <!--
297 can not pass in empty values in jvmargs so if not testBundle
298 specified, we'll pass a junk (unused) value
299 -->
300 <condition
301 property="testBundleParam"
302 value="-DtestBundle=${testBundle}"
303 else="-Dunused=nouse">
david_williams2398e362011-03-05 02:45:39 +0000304 <isset property="testBundle"/>
david_williams12def432010-08-09 04:42:21 +0000305 </condition>
david_williams2398e362011-03-05 02:45:39 +0000306 <echo message="Running junits"/>
david_williams12def432010-08-09 04:42:21 +0000307 <!--
308 If there is not exactly one launcher in the stack, we'd best
309 fail fast, since we are not expecting that, and may indicate
310 an installation that would produce unpredictable results
311 -->
312 <!--
313 requires ant 1.7, and at this point, we're running 1.6 from
314 eclipse ... <condition property="expectedNumberOfLaunchers">
315 <resourcecount when="equal" count="1" > <fileset
316 dir="${testRoot}/eclipse/plugins"> <include
317 name="org.eclipse.equinox.launcher_*.jar" /> </fileset>
318 </resourcecount> </condition> <fail message="Did not find
319 expected number of launcher jars. Check installation."
320 unless="expectedNumberOfLaunchers" />
321 -->
david_williamsef62fc42011-03-18 02:33:39 +0000322
david_williamsba00a342011-03-12 05:11:19 +0000323 <condition
324 property="antQuietValue"
325 value="-quiet"
326 else="">
327 <istrue value="${env.USE_QUIET}"/>
328 </condition>
david_williams12def432010-08-09 04:42:21 +0000329 <java
330 taskname="unit-test-masterprocess"
331 fork="true"
332 resultProperty="wtpmasterjunitresult"
333 failonerror="false"
334 timeout="${testTimeLimit}"
335 dir="${testRoot}/eclipse"
336 jvm="${env.JAVA_6_HOME}/bin/java"
337 classname="org.eclipse.equinox.launcher.Main">
338 <classpath>
david_williams2398e362011-03-05 02:45:39 +0000339 <fileset dir="${testRoot}/eclipse/plugins">
340 <include name="org.eclipse.equinox.launcher_*.jar"/>
david_williams12def432010-08-09 04:42:21 +0000341 </fileset>
342 </classpath>
david_williams2398e362011-03-05 02:45:39 +0000343 <jvmarg value="-Dosgi.ws=${env.BASEWS}"/>
344 <jvmarg value="-Dosgi.os=${env.BASEOS}"/>
345 <jvmarg value="-Dosgi.arch=${env.BASEARCH}"/>
346 <jvmarg value="-Dws=${env.BASEWS}"/>
347 <jvmarg value="-Dos=${env.BASEOS}"/>
348 <jvmarg value="-Darch=${env.BASEARCH}"/>
349 <jvmarg value="-DbuildBranch=${buildBranch}"/>
350 <jvmarg value="-DbuildType=${buildType}"/>
351 <jvmarg value="-DdependencyFileLocation=${dependencyFileLocation}"/>
david_williams2398e362011-03-05 02:45:39 +0000352 <jvmarg value="-DbuildId=${buildId}"/>
353 <jvmarg value="-Dprojectname=${projectname}"/>
354 <jvmarg value="-Djava.io.tmpdir=${env.RECOMMENDED_TMP_DIR}"/>
david_williamsba00a342011-03-12 05:11:19 +0000355 <jvmarg value="-Dwtp.builder.home=${wtp.builder.home}"/>
356 <jvmarg value="-Dbuild.distribution=${build.distribution}"/>
david_williams2398e362011-03-05 02:45:39 +0000357 <jvmarg value="${testBundleParam}"/>
358 <arg value="-nosplash"/>
359 <arg value="-consolelog"/>
360 <arg value="-data"/>
361 <arg value="${testRoot}/overallTestWorkspace"/>
362 <arg value="-application"/>
363 <arg value="org.eclipse.ant.core.antRunner"/>
david_williamsba00a342011-03-12 05:11:19 +0000364 <arg value="${antQuietValue}"/>
david_williams2398e362011-03-05 02:45:39 +0000365 <arg value="-logger"/>
366 <arg value="org.apache.tools.ant.DefaultLogger"/>
367 <arg value="-file"/>
368 <arg value="${testRoot}/test.xml"/>
369 <arg value="${testTarget}"/>
david_williams12def432010-08-09 04:42:21 +0000370
371 <!-- make sure our forked env has a DISPLAY -->
372 <env
373 key="DISPLAY"
374 value="${env.DISPLAY}"/>
375 <redirector
376 output="${testRoot}/results/fullOutput.txt"
377 error="${testRoot}/results/fullErrorLog.txt"/>
david_williams2398e362011-03-05 02:45:39 +0000378 <jvmarg value="-Dbuild.home=${env.BUILD_HOME}"/>
379 <jvmarg value="-DbuildDirectory=${buildDirectory}"/>
380 <jvmarg value="-DbuildLabel=${buildLabel}"/>
381 <jvmarg value="-DbaseLocation=${baseLocation}"/>
382 <jvmarg value="-DtestRoot=${testRoot}"/>
383 <jvmarg value="-DtestDir=${testRoot}"/>
384 <jvmarg value="-DeclipseBuilderDirectory=${pde.builder.path}"/>
david_williams12def432010-08-09 04:42:21 +0000385 <!--
386 <!- - IBM_JAVA_OPTIONS contains JIT work arounds for bug
387 284441 - -> <env key="IBM_JAVA_OPTIONS"
388 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)"/>
389 -->
390 </java>
david_williams2398e362011-03-05 02:45:39 +0000391 <echo message="wtpmasterjunitresult ${wtpmasterjunitresult}"/>
david_williams12def432010-08-09 04:42:21 +0000392 </target>
david_williams2398e362011-03-05 02:45:39 +0000393 <target name="postRunTestEclipse">
david_williams12def432010-08-09 04:42:21 +0000394 <copy
395 todir="${buildDirectory}/${buildLabel}/testResults/consolelogs/testLogs"
396 overwrite="true"
397 failonerror="false">
david_williams2398e362011-03-05 02:45:39 +0000398 <fileset dir="${testRoot}/results">
399 <include name="*output.txt"/>
david_williams12def432010-08-09 04:42:21 +0000400 </fileset>
401 </copy>
402 <copy
403 todir="${buildDirectory}/${buildLabel}/testResults/consolelogs/testSysErrorLogs"
404 overwrite="true"
405 failonerror="false">
david_williams2398e362011-03-05 02:45:39 +0000406 <fileset dir="${testRoot}/results">
407 <include name="*error.txt"/>
david_williams12def432010-08-09 04:42:21 +0000408 </fileset>
409 </copy>
410 <copy
411 file="${testRoot}/results/fullOutput.txt"
412 toDir="${buildDirectory}/${buildLabel}/testResults/consolelogs/full"
413 overwrite="true"
414 failonerror="false">
415 </copy>
416 <copy
417 file="${testRoot}/results/fullErrorLog.txt"
418 toDir="${buildDirectory}/${buildLabel}/testResults/consolelogs/full"
419 overwrite="true"
420 failonerror="false">
421 </copy>
422 <copy
423 todir="${buildDirectory}/${buildLabel}/testResults/xml"
424 overwrite="true"
425 failonerror="false">
david_williams2398e362011-03-05 02:45:39 +0000426 <fileset dir="${testRoot}/results/xml">
427 <include name="*.xml"/>
david_williams12def432010-08-09 04:42:21 +0000428 </fileset>
429 </copy>
430 <copy
431 todir="${buildDirectory}/${buildLabel}/testResults/html"
432 overwrite="true"
433 failonerror="false">
david_williams2398e362011-03-05 02:45:39 +0000434 <fileset dir="${testRoot}/results/html">
435 <include name="*.html"/>
david_williams12def432010-08-09 04:42:21 +0000436 </fileset>
437 </copy>
david_williams7e568c72010-09-12 09:04:15 +0000438 <copy
david_williamsefc103a2011-09-25 04:57:53 +0000439 todir="${buildDirectory}/${buildLabel}/testResults/httplogstest"
440 overwrite="true"
441 failonerror="false">
442 <fileset dir="${testRoot}/results/httplogstest">
443 <include name="*.log"/>
444 </fileset>
445 </copy>
446 <copy
david_williams7e568c72010-09-12 09:04:15 +0000447 todir="${buildDirectory}/${buildLabel}/testResults/"
448 overwrite="true"
449 failonerror="false">
david_williams2398e362011-03-05 02:45:39 +0000450 <fileset dir="${testRoot}/results/">
451 <include name="*.html"/>
david_williams7e568c72010-09-12 09:04:15 +0000452 </fileset>
453 </copy>
david_williams12def432010-08-09 04:42:21 +0000454 </target>
david_williamsba00a342011-03-12 05:11:19 +0000455
456 <target name="init">
457
david_williams14cadd12011-03-23 06:43:39 +0000458 <echo level="debug" message="dropinsFolder: ${dropinsFolder} "/>
david_williamsba00a342011-03-12 05:11:19 +0000459 <condition
460 property="install.destination"
461 value="${testRoot}${dropinsFolder}/"
462 else="${testRoot}/eclipse">
463 <isset property="dropinsFolder"/>
464 </condition>
465
466 </target>
467
david_williams12def432010-08-09 04:42:21 +0000468</project>