Skip to main content
summaryrefslogtreecommitdiffstats
blob: 16e8af5eaacddef807e19850abe53a1378543a42 (plain) (blame)
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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
<project name="Automated SWTBot Testing" default="all" basedir=".">

	<!--default directory where test-eclipse will be installed-->
	<property name="install" value="${basedir}/test-eclipse" />

	<!--suffix added to test output files to identify platform on which tests ran.-->
	<property name="platform" value="${os}.${ws}.${arch}" />

	<!-- The root of the eclipse installation -->
	<property name="eclipse-home" value="${install}/eclipse" />

	<!-- The directory that will contain all files containing information on the tests that ran.-->
	<property name="results" value="${basedir}/results" />

	<!--Directory for JUnit report output, console log output and .log content for each test suite.
                        Overrides default in org.eclipse.test/library.xml-->
	<property name="junit-report-output" value="${results}/${platform}" />

	<target name="setup" unless="noclean" depends="init">
		<condition property="setupTarget" value="setup-zip">
			<contains string="${runtimeArchive}" substring=".zip" />
		</condition>
		<condition property="setupTarget" value="setup-tar.gz">
			<contains string="${runtimeArchive}" substring=".tar.gz" />
		</condition>
		<antcall target="${setupTarget}" />
	</target>

	<!--setup for zip archives-->
	<target name="setup-zip" description="Reinstall the test Eclipse installation if specified by user">
		<delete dir="${install}" />
		<mkdir dir="${install}" />
		<unzip dest="${install}" src="../externals/${runtimeArchive}" />
		<antcall target="installTestPlugins" />
	</target>

	<!--setup for tar.gz archives-->
	<target name="setup-tar.gz" description="Reinstall the test Eclipse installation if specified by user">
		<delete dir="${install}" />
		<mkdir dir="${install}" />
		<untar compression="gzip" dest="${install}" src="../externals/${runtimeArchive}" />
		<antcall target="installTestPlugins" />
	</target>

	<target name="installTestPlugins">
		<!-- one each for each feature that is tested -->
		<unzip src="${basedir}/../artifacts/${feature.id}-${all.buildId}.zip" dest="${install}" />
		<unzip src="${basedir}/../artifacts/${feature.id.test}-${all.buildId}.zip" dest="${install}" />
		<unzip src="${basedir}/../artifacts/org.eclipse.swtbot.eclipse-${all.buildId}.zip" dest="${install}" />

		<copy todir="${install}/eclipse/plugins" verbose="true">
			<fileset dir="${basedir}/../externals/plugins" />
		</copy>

		<!-- copy over any other dependencies
			<copy todir="${eclipse-home}" includeemptydirs="true">
				<fileset dir="${mylyn-base}" />
			</copy>
		-->
	</target>

	<target name="init" depends="setRuntimeArchive">

		<mkdir dir="${results}/xml" />
		<mkdir dir="${results}/html" />
		<mkdir dir="${junit-report-output}" />

		<!--Unlock files on the Mac before starting tests.
                  Required to delete some workspace directories (org.eclipse.core.filebuffers.tests and Team CVS tests).-->
		<exec dir="${basedir}" executable="chflags" os="Mac OS X">
			<arg line="-R nouchg ${install}" />
		</exec>
	</target>

	<target name="setRuntimeArchive">
		<condition property="runtimeArchive" value="eclipse-SDK-${buildId}-win32.zip">
			<and>
				<equals arg1="${os}" arg2="win32" />
				<equals arg1="${ws}" arg2="win32" />
				<equals arg1="${arch}" arg2="x86" />
			</and>
		</condition>
		<condition property="runtimeArchive" value="eclipse-SDK-${buildId}-win32-wpf.zip">
			<and>
				<equals arg1="${os}" arg2="win32" />
				<equals arg1="${ws}" arg2="wpf" />
				<equals arg1="${arch}" arg2="x86" />
			</and>
		</condition>
		<condition property="runtimeArchive" value="eclipse-SDK-${buildId}-win32-win32-x86_64.zip">
			<and>
				<equals arg1="${os}" arg2="win32" />
				<equals arg1="${ws}" arg2="win32" />
				<equals arg1="${arch}" arg2="x86_64" />
			</and>
		</condition>
		<condition property="runtimeArchive" value="eclipse-SDK-${buildId}-linux-gtk.tar.gz">
			<and>
				<equals arg1="${os}" arg2="linux" />
				<equals arg1="${ws}" arg2="gtk" />
				<equals arg1="${arch}" arg2="x86" />
			</and>
		</condition>
		<condition property="runtimeArchive" value="eclipse-SDK-${buildId}-linux-gtk-x86_64.tar.gz">
			<and>
				<equals arg1="${os}" arg2="linux" />
				<equals arg1="${ws}" arg2="gtk" />
				<equals arg1="${arch}" arg2="x86_64" />
			</and>
		</condition>
		<condition property="runtimeArchive" value="eclipse-SDK-${buildId}-linux-motif.tar.gz">
			<and>
				<equals arg1="${os}" arg2="linux" />
				<equals arg1="${ws}" arg2="motif" />
				<equals arg1="${arch}" arg2="x86" />
			</and>
		</condition>
		<condition property="runtimeArchive" value="eclipse-SDK-${buildId}-linux-gtk-ppc.tar.gz">
			<and>
				<equals arg1="${os}" arg2="linux" />
				<equals arg1="${ws}" arg2="gtk" />
				<equals arg1="${arch}" arg2="ppc" />
			</and>
		</condition>
		<condition property="runtimeArchive" value="eclipse-SDK-${buildId}-linux-gtk-x86_64.tar.gz">
			<and>
				<equals arg1="${os}" arg2="linux" />
				<equals arg1="${ws}" arg2="gtk" />
				<equals arg1="${arch}" arg2="ppc" />
			</and>
		</condition>
		<condition property="runtimeArchive" value="eclipse-SDK-${buildId}-macosx-carbon.tar.gz">
			<and>
				<equals arg1="${os}" arg2="macosx" />
				<equals arg1="${ws}" arg2="carbon" />
				<equals arg1="${arch}" arg2="ppc" />
			</and>
		</condition>
		<condition property="runtimeArchive" value="eclipse-SDK-${buildId}-macosx-carbon.tar.gz">
			<and>
				<equals arg1="${os}" arg2="macosx" />
				<equals arg1="${ws}" arg2="carbon" />
				<equals arg1="${arch}" arg2="x86" />
			</and>
		</condition>
		<condition property="runtimeArchive" value="eclipse-SDK-${buildId}-macosx-cocoa.tar.gz">
			<and>
				<equals arg1="${os}" arg2="macosx" />
				<equals arg1="${ws}" arg2="cocoa" />
				<equals arg1="${arch}" arg2="x86" />
			</and>
		</condition>
		<condition property="runtimeArchive" value="eclipse-SDK-${buildId}-macosx-cocoa-x86_64.tar.gz">
			<and>
				<equals arg1="${os}" arg2="macosx" />
				<equals arg1="${ws}" arg2="cocoa" />
				<equals arg1="${arch}" arg2="x86_64" />
			</and>
		</condition>
		<condition property="runtimeArchive" value="eclipse-SDK-${buildId}-hpux-motif.zip">
			<and>
				<equals arg1="${os}" arg2="hpux" />
				<equals arg1="${ws}" arg2="motif" />
				<equals arg1="${arch}" arg2="PA_RISC" />
			</and>
		</condition>
		<condition property="runtimeArchive" value="eclipse-SDK-${buildId}-solaris-motif.zip">
			<and>
				<equals arg1="${os}" arg2="solaris" />
				<equals arg1="${ws}" arg2="motif" />
				<equals arg1="${arch}" arg2="sparc" />
			</and>
		</condition>
		<condition property="runtimeArchive" value="eclipse-SDK-${buildId}-solaris-gtk.zip">
			<and>
				<equals arg1="${os}" arg2="solaris" />
				<equals arg1="${ws}" arg2="gtk" />
				<equals arg1="${arch}" arg2="sparc" />
			</and>
		</condition>
		<condition property="runtimeArchive" value="eclipse-SDK-${buildId}-aix-motif.zip">
			<and>
				<equals arg1="${os}" arg2="aix" />
				<equals arg1="${ws}" arg2="motif" />
				<equals arg1="${arch}" arg2="ppc" />
			</and>
		</condition>
	</target>

	<macrodef name="runTests">
		<attribute name="testPlugin" />
		<attribute name="testPluginsRequired" default="" />
		<sequential>
			<echo>=========================================================================</echo>
			<echo>Executing tests for @{testPlugin}</echo>
			<echo>=========================================================================</echo>

			<property name="test.target" value="junit" />
			<property name="report" value="@{testPlugin}" />

			<antcall target="${test.target}">
				<param name="testPlugin" value="@{testPlugin}" />
				<param name="testPluginsRequired" value="@{testPluginsRequired}" />
				<param name="output-file" value="@{testPlugin}.xml" />
				<param name="consolelog" value="-consolelog" />
			</antcall>
		</sequential>
	</macrodef>

	<target name="junit" unless="skip.test">
		<antcall target="setup" />
		<ant antfile="${testPlugin}.xml" />
		<antcall target="genResults" />
	</target>

	<target name="genResults">
		<property name="junit.reports.xml.dir" value="${results.dir}/${report}/junit/xml" />
		<property name="junit.reports.html.dir" value="${results.dir}/${report}/junit/html" />

		<mkdir dir="${junit.reports.xml.dir}" />
		<mkdir dir="${junit.reports.html.dir}" />

		<move file="${eclipse-home}/${report}.xml" tofile="${junit.reports.xml.dir}/index.xml" failonerror="false" />

		<available file="${eclipse-home}/plugins/org.eclipse.swtbot.eclipse.junit3.headless_${all.buildId}/JUNIT.XSL" property="junit.xsl" value="${eclipse-home}/plugins/org.eclipse.swtbot.eclipse.junit3.headless_${all.buildId}/JUNIT.XSL" />
		<available file="${eclipse-home}/plugins/org.eclipse.swtbot.eclipse.junit4.headless_${all.buildId}/JUNIT.XSL" property="junit.xsl" value="${eclipse-home}/plugins/org.eclipse.swtbot.eclipse.junit4.headless_${all.buildId}/JUNIT.XSL" />
		
		<mkdir dir="${junit.reports.html.dir}/screenshots" />
		<move todir="${junit.reports.html.dir}/screenshots" failonerror="false">
			<fileset dir="${junit-report-output}/screenshots" includes="*.*" />
		</move>

		<xslt style="${junit.xsl}" in="${junit.reports.xml.dir}/index.xml" out="${junit.reports.html.dir}/index.html">
			<param name="screenshot_dir" expression="screenshots"/>
			<!--
			Only use this if you've set SWTBotPreferences#SCREENSHOT_FORMAT preference
			Optional: possible values are bmp, gif, ico, jpeg, jpg, png or tiff
			<param name="screenshot_format" expression="jpeg"/>
			-->
		</xslt>
		
		<xslt in="${junit.reports.xml.dir}/index.xml" out="./passFail.txt" style="passFail.xsl" />
		<property file="passFail.txt" />
		<fail message="Unit Tests failed." if="test.failed" />
	</target>

	<target name="core-tests">

		<echo>==============================================================</echo>
		<echo>eclipse-home is ${eclipse-home}</echo>
		<echo>Executing tests under ${testPlugin}</echo>
		<echo>==============================================================</echo>

		<ant antfile="${basedir}/${testPlugin}.xml" dir="${eclipse-home}/plugins/${testPlugin}_${all.buildId}">
			<property name="all.buildId" value="${all.buildId}" />
			<property name="build.base" value="${build.base}" />
			<property name="results.dir" value="${results.dir}/${testPlugin}" />
		</ant>
	</target>

	<target name="clean">
		<delete dir="${install}" />
		<delete dir="${results}" />
	</target>

	<target name="test-finder" depends="setup">
		<antcall target="core-tests">
			<param name="testPlugin" value="org.eclipse.swtbot.swt.finder.test" />
		</antcall>
	</target>

	<target name="test-generator" depends="setup">
		<antcall target="core-tests">
			<param name="testPlugin" value="org.eclipse.swtbot.generator.test" />
		</antcall>
	</target>

	<target name="test-eclipse-finder">
		<runTests testPlugin="org.eclipse.swtbot.eclipse.finder.test" />
	</target>

	<target name="test-eclipse-ui">
		<runTests testPlugin="org.eclipse.swtbot.eclipse.ui.test" />
	</target>

	<target name="all" depends="test-finder, test-generator, test-eclipse-finder, test-eclipse-ui" />

</project>

Back to the top