xref: /aoo41x/test/build.xml (revision 7acce70d)
1<?xml version="1.0"?>
2<!--***********************************************************
3 *
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements.  See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership.  The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License.  You may obtain a copy of the License at
11 *
12 *   http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied.  See the License for the
18 * specific language governing permissions and limitations
19 * under the License.
20 *
21 ***********************************************************-->
22
23
24
25<project basedir="." default="test">
26	<property file="build.properties" />
27	<property environment="env" />
28
29	<property name="env.INPATH" value="output"/>
30	<property name="classes" value="${env.INPATH}/class" />
31	<property name="dist" value="${env.INPATH}/dist" />
32
33	<property name="env.TESTSPACE" value="testspace" />
34	<property name="env.JUNIT_HOME" value="${env.INPATH}/junit" />
35	<property name="junit.home" value="${env.JUNIT_HOME}" />
36	<property name="testspace" value="${env.TESTSPACE}" />
37	<property name="test.classes" value="testsuite/gui/BVT.class" />
38	<property name="test.output" value="${testspace}/output" />
39	<property name="test.result" value="${test.output}/result" />
40	<property name="test.report" value="${test.output}/report" />
41	<property name="junit.style.dir" value="reportstyle" />
42
43	<path id="junit.classpath">
44		<fileset dir="${junit.home}" erroronmissingdir="false">
45			<include name="*.jar" />
46		</fileset>
47	</path>
48
49	<target name="testcommon.init">
50		<mkdir dir="${classes}" />
51		<copy includeemptydirs="false" todir="${classes}">
52			<fileset dir="testcommon/source">
53				<exclude name="**/*.java" />
54			</fileset>
55		</copy>
56	</target>
57
58	<target name="testcommon.compile" depends="testcommon.init">
59		<javac destdir="${classes}" debug="on" source="1.6" includeantruntime="false">
60			<src path="testcommon/source"/>
61		</javac>
62	</target>
63
64	<target name="testgui.init">
65		<mkdir dir="${classes}" />
66		<copy includeemptydirs="false" todir="${classes}">
67			<fileset dir="testgui/source">
68				<exclude name="**/*.java" />
69			</fileset>
70		</copy>
71		<copy includeemptydirs="false" todir="${classes}">
72			<fileset dir="testgui/data">
73				<exclude name="**/*.java" />
74			</fileset>
75		</copy>
76	</target>
77
78	<target name="testgui.compile" depends="testgui.init, prepare.junit">
79		<javac destdir="${classes}" debug="on" source="1.6" includeantruntime="false">
80			<src path="testgui/source"/>
81			<src path="testgui/data"/>
82			<classpath>
83				<pathelement location="${classes}" />
84				<path refid="junit.classpath"/>
85			</classpath>
86		</javac>
87	</target>
88
89	<target name="testuno.init">
90		<mkdir dir="${classes}" />
91		<copy includeemptydirs="false" todir="${classes}">
92			<fileset dir="testuno/source">
93				<exclude name="**/*.java" />
94			</fileset>
95		</copy>
96	</target>
97
98	<target name="testuno.compile" depends="testuno.init, prepare.junit">
99		<property name="uno.jar.dir" location="${openoffice.home}/../" />
100		<path id="uno.classpath">
101			<fileset dir="${uno.jar.dir}" erroronmissingdir="false">
102				<include name="**/juh.jar" />
103				<include name="**/unoil.jar" />
104				<include name="**/ridl.jar" />
105				<include name="**/jurt.jar" />
106			</fileset>
107		</path>
108		<javac destdir="${classes}" debug="on" source="1.6" includeantruntime="false">
109			<src path="testuno/source"/>
110			<classpath>
111				<pathelement location="${classes}" />
112				<path refid="junit.classpath"/>
113				<path refid="uno.classpath"/>
114			</classpath>
115		</javac>
116	</target>
117
118	<target name="clean" description="Clean all output">
119		<delete dir="${out}" />
120	</target>
121
122	<target name="check.junit">
123		<available file="junit.jar" property="junit.jar.exists">
124			<filepath refid="junit.classpath" />
125		</available>
126	</target>
127
128	<target name="prepare.junit" depends="check.junit" unless="junit.jar.exists">
129		<property name="junit.jar.repos" value="http://repo1.maven.org/maven2/junit/junit/4.10/junit-4.10.jar" />
130		<mkdir dir="${junit.home}" />
131		<get src="${junit.jar.repos}" dest="${junit.home}/junit.jar" skipexisting="true" />
132	</target>
133
134	<target name="compile" depends="testcommon.init, testcommon.compile, testgui.init, testgui.compile, testuno.init, testuno.compile" description="Compile source code">
135	</target>
136
137	<target name="dist" depends="compile">
138		<tstamp />
139		<property name="dist.archive" value="aoo_test_${DSTAMP}.zip" />
140	</target>
141
142	<target name="check.build" description="Check the build context">
143		<condition property="openoffice.archive.dir" value="${env.SRC_ROOT}/instsetoo_native/${env.INPATH}/OpenOffice/archive/install/en-US">
144			<isset property="env.SRC_ROOT" />
145		</condition>
146		<condition property="openoffice.build" value="localbuild">
147			<isset property="openoffice.archive.dir" />
148		</condition>
149		<condition property="find.build.skip">
150			<or>
151				<isset property="openoffice.build" />
152				<isset property="openoffice.archive.url" />
153				<isset property="openoffice.archive.dir" />
154				<isset property="openoffice.home" />
155			</or>
156		</condition>
157		<condition property="download.build.skip">
158			<or>
159				<isset property="openoffice.archive.dir" />
160				<isset property="openoffice.home" />
161			</or>
162		</condition>
163		<condition property="install.build.skip">
164			<isset property="openoffice.home" />
165		</condition>
166	</target>
167
168	<target name="find.build" unless="find.build.skip" description="Find the newest build on the remote server">
169		<loadresource property="openoffice.build">
170			<url url="${openoffice.build.url}" />
171			<filterchain>
172				<deletecharacters chars=" \t\r\n" />
173			</filterchain>
174		</loadresource>
175		<echo>Latest build: ${openoffice.build}</echo>
176	</target>
177
178	<target name="download.build" unless="download.build.skip" description="Download the specified build from the remote server">
179		<script language="javascript">
180					  	value = project.getProperty("openoffice.archive.url");
181					    resolvedValue = project.replaceProperties(value);
182						project.setProperty("openoffice.archive.url", resolvedValue);
183		</script>
184		<echo>Archive address: ${openoffice.archive.url}</echo>
185		<property name="openoffice.archive.dir" value="${testspace}/download/${openoffice.build}" />
186		<mkdir dir="${openoffice.archive.dir}" />
187		<get src="${openoffice.archive.url}" dest="${openoffice.archive.dir}" verbose="false" usetimestamp="true" skipexisting="true" />
188	</target>
189
190	<target name="install.build" unless="install.build.skip" description="Install the build to the local">
191		<property name="openoffice.installation.dir" value="${testspace}/installation/${openoffice.build}" />
192		<mkdir dir="${openoffice.installation.dir}" />
193		<unzip dest="${openoffice.installation.dir}">
194			<fileset dir="${openoffice.archive.dir}">
195				<include name="**/Apache_OpenOffice*.zip" />
196			</fileset>
197		</unzip>
198		<pathconvert property="gz.files" pathsep=" " setonempty="false">
199			<path>
200				<fileset dir="${openoffice.archive.dir}" includes="Apache_OpenOffice*.gz" />
201			</path>
202		</pathconvert>
203		<exec dir="${openoffice.installation.dir}" executable="tar" failifexecutionfails="false">
204			<arg line="-zxf ${gz.files}" />
205		</exec>
206		<pathconvert property="openoffice.bin" pathsep=" " setonempty="false">
207			<path>
208				<fileset dir="${openoffice.installation.dir}" includes="**/*/soffice.bin" followsymlinks="false" />
209			</path>
210		</pathconvert>
211		<dirname property="openoffice.home" file="${openoffice.bin}" />
212		<fail unless="openoffice.home" />
213		<echo>Openoffice is installed to ${openoffice.home}</echo>
214	</target>
215
216	<target name="run.test" depends="compile" description="Run junit">
217		<tstamp>
218			<format property="output.stamp" pattern="yyMMdd.hhmm" />
219		</tstamp>
220
221		<move file="${test.output}" tofile="${test.output}.${output.stamp}" failonerror="false" />
222		<mkdir dir="${test.result}" />
223		<mkdir dir="${test.report}" />
224		<mkdir dir="${test.output}/temp" />
225		<property file="${openoffice.home}/versionrc" prefix="version" />
226		<property file="${openoffice.home}/version.ini" />
227
228		<junit fork="yes" forkmode="once" tempdir="${test.output}/temp" printsummary="yes" showoutput="false" errorProperty="test.failed" failureProperty="test.failed" dir=".">
229			<sysproperty key="openoffice.home" value="${openoffice.home}" />
230			<sysproperty key="testspace" value="${testspace}" />
231			<syspropertyset>
232				<propertyref builtin="commandline" />
233			</syspropertyset>
234			<batchtest todir="${test.result}">
235				<fileset dir="${classes}" includes="${test.classes}" />
236			</batchtest>
237
238			<formatter type="xml" />
239			<classpath>
240				<pathelement location="${classes}" />
241				<path refid="junit.classpath"/>
242				<path refid="uno.classpath"/>
243			</classpath>
244		</junit>
245
246		<junitreport todir="${test.report}">
247			<fileset dir="${test.result}">
248				<include name="TEST-*.xml" />
249			</fileset>
250			<report format="frames" styledir="${junit.style.dir}" todir="${test.report}">
251				<param name="TITLE" expression="GUI Test Result" />
252			</report>
253		</junitreport>
254		<property name="test.report.index" location="${test.report}/index.html" />
255		<echo>Open ${test.report.index} in browser to view the test report.</echo>
256	</target>
257
258	<target name="test" depends="check.build,find.build,download.build,install.build,run.test" description="Run testing on the specified build. The build is automatically downloaded and installed according to the context.">
259		<fail message="Test Failed" if="test.failed" />
260	</target>
261
262	<target name="report.test" unless="report.test.skip" description="Upload the testing result to report repository.">
263		<exec executable="hostname" outputproperty="host.name" />
264		<property name="report.to" value="${openoffice.build}_${host.name}" />
265		<!--
266		<echo>Sending report to ${report.repos.server}/${report.repos.dir}/${report.to}</echo>
267		<ftp server="${report.repos.server}" remotedir="${report.repos.dir}/${report.to}" userid="${report.repos.user}" password="${report.repos.password}" action="mkdir" />
268		<ftp server="${report.repos.server}" remotedir="${report.repos.dir}/${report.to}" userid="${report.repos.user}" password="${report.repos.password}" depends="yes">
269			<fileset dir="${test.output}">
270			</fileset>
271		</ftp>
272		-->
273		<echo>Uploading report to ${report.repos}/${report.to}</echo>
274		<tempfile property="report.to.temp" suffix=".output" destDir="${testspace}" deleteonexit="true"/>
275		<copy todir="${report.to.temp}/${report.to}">
276			<fileset dir="${test.output}" />
277		</copy>
278
279		<scp todir="${report.repos}">
280			<fileset dir="${report.to.temp}"/>
281		</scp>
282	</target>
283
284	<target name="detect.build" depends="find.build" description="Check if new build is available. If no new build is available, the target will be failed.">
285		<loadfile property="local.build" srcFile="${testspace}/build.txt" quiet="true" failonerror="false" />
286		<fail message="The build has been tested! We don't want to test it twice.">
287			<condition>
288				<equals arg1="${openoffice.build}" arg2="${local.build}" trim="true" />
289			</condition>
290		</fail>
291		<mkdir dir="${testspace}" />
292		<echo file="${testspace}/build.txt">${openoffice.build}</echo>
293	</target>
294
295	<target name="routine.test" depends="detect.build,download.build,install.build,run.test,report.test" description="Periodically run testing.">
296		<fail message="Test Failed" if="test.failed" />
297	</target>
298</project>
299