xref: /aoo41x/test/build.xml (revision 0e2e75f4)
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="out" value="output"/>
30	<property name="classes" value="${out}/class" />
31	<property name="dist" value="${out}/dist" />
32
33	<property name="env.TESTSPACE" value="testspace" />
34	<property name="env.JUNIT_HOME" value="${out}/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	<path id="testgui.classpath">
50		<pathelement location="${classes}" />
51		<path refid="junit.classpath"/>
52	</path>
53
54	<path id="testuno.classpath">
55		<pathelement location="${classes}" />
56		<path refid="junit.classpath"/>
57		<fileset dir="${openoffice.home}/../" erroronmissingdir="false">
58			<include name="**/juh.jar" />
59			<include name="**/unoil.jar" />
60			<include name="**/ridl.jar" />
61			<include name="**/jurt.jar" />
62		</fileset>
63	</path>
64
65	<path id="test.classpath">
66		<pathelement location="${classes}" />
67		<path refid="junit.classpath" />
68		<fileset dir="${openoffice.home}/../" erroronmissingdir="false">
69			<include name="**/juh.jar" />
70			<include name="**/unoil.jar" />
71			<include name="**/ridl.jar" />
72			<include name="**/jurt.jar" />
73		</fileset>
74	</path>
75
76	<target name="testcommon.init">
77		<mkdir dir="${classes}" />
78		<copy includeemptydirs="false" todir="${classes}">
79			<fileset dir="testcommon/source">
80				<exclude name="**/*.java" />
81			</fileset>
82		</copy>
83	</target>
84
85	<target name="testcommon.compile" depends="testcommon.init">
86		<javac destdir="${classes}" debug="on" source="1.6" includeantruntime="false">
87			<src path="testcommon/source"/>
88		</javac>
89	</target>
90
91	<target name="testgui.init">
92		<mkdir dir="${classes}" />
93		<copy includeemptydirs="false" todir="${classes}">
94			<fileset dir="testgui/source">
95				<exclude name="**/*.java" />
96			</fileset>
97		</copy>
98		<copy includeemptydirs="false" todir="${classes}">
99			<fileset dir="testgui/data">
100				<exclude name="**/*.java" />
101			</fileset>
102		</copy>
103	</target>
104
105	<target name="testgui.compile" depends="testgui.init, prepare.junit">
106		<javac destdir="${classes}" debug="on" source="1.6" includeantruntime="false">
107			<src path="testgui/source"/>
108			<src path="testgui/data"/>
109			<classpath refid="testgui.classpath"/>
110		</javac>
111	</target>
112
113	<target name="testuno.init">
114		<mkdir dir="${classes}" />
115		<copy includeemptydirs="false" todir="${classes}">
116			<fileset dir="testuno/source">
117				<exclude name="**/*.java" />
118			</fileset>
119		</copy>
120	</target>
121
122	<target name="testuno.compile" depends="testuno.init, prepare.junit">
123		<javac destdir="${classes}" debug="on" source="1.6" includeantruntime="false">
124			<src path="testuno/source"/>
125			<classpath refid="testuno.classpath"/>
126		</javac>
127	</target>
128
129	<target name="clean" description="Clean all output">
130		<delete dir="${out}" />
131	</target>
132
133	<target name="check.junit">
134		<available file="junit.jar" property="junit.jar.exists">
135			<filepath refid="junit.classpath" />
136		</available>
137	</target>
138
139	<target name="prepare.junit" depends="check.junit" unless="junit.jar.exists">
140		<property name="junit.jar.repos" value="http://repo1.maven.org/maven2/junit/junit/4.10/junit-4.10.jar" />
141		<mkdir dir="${junit.home}" />
142		<get src="${junit.jar.repos}" dest="${junit.home}/junit.jar" skipexisting="true" />
143	</target>
144
145	<target name="compile" depends="testcommon.init, testcommon.compile, testgui.init, testgui.compile, testuno.init, testuno.compile" description="Compile source code">
146	</target>
147
148	<target name="dist" depends="compile">
149		<tstamp />
150		<property name="dist.archive" value="aoo_test_${DSTAMP}.zip" />
151	</target>
152
153	<target name="check.build" description="Check the build context">
154		<condition property="openoffice.archive.dir" value="${env.SRC_ROOT}/instsetoo_native/${env.INPATH}/OpenOffice/archive/install/en-US">
155			<and>
156				<isset property="env.SRC_ROOT" />
157				<isset property="env.INPATH" />
158			</and>
159		</condition>
160
161		<condition property="openoffice.build" value="localbuild">
162			<isset property="openoffice.archive.dir" />
163		</condition>
164
165		<condition property="find.build.skip">
166			<or>
167				<isset property="openoffice.build" />
168				<isset property="openoffice.archive.url" />
169				<isset property="openoffice.archive.dir" />
170				<isset property="openoffice.home" />
171			</or>
172		</condition>
173		<condition property="download.build.skip">
174			<or>
175				<isset property="openoffice.archive.dir" />
176				<isset property="openoffice.home" />
177			</or>
178		</condition>
179		<condition property="install.build.skip">
180			<or>
181				<isset property="openoffice.home" />
182			</or>
183		</condition>
184	</target>
185
186	<target name="find.build" unless="find.build.skip" description="Find the newest build on the remote server">
187		<loadresource property="openoffice.build">
188			<url url="${openoffice.build.url}" />
189			<filterchain>
190				<deletecharacters chars=" \t\r\n" />
191			</filterchain>
192		</loadresource>
193		<echo>Latest build: ${openoffice.build}</echo>
194	</target>
195
196	<target name="download.build" unless="download.build.skip" description="Download the specified build from the remote server">
197		<script language="javascript">
198					  	value = project.getProperty("openoffice.archive.url");
199					    resolvedValue = project.replaceProperties(value);
200						project.setProperty("openoffice.archive.url", resolvedValue);
201		</script>
202		<echo>Archive address: ${openoffice.archive.url}</echo>
203		<property name="openoffice.archive.dir" value="${testspace}/download/${openoffice.build}" />
204		<mkdir dir="${openoffice.archive.dir}" />
205		<get src="${openoffice.archive.url}" dest="${openoffice.archive.dir}" verbose="false" usetimestamp="true" skipexisting="true" />
206	</target>
207
208	<target name="install.build" unless="install.build.skip" description="Install the build to the local">
209		<property name="openoffice.installation.dir" value="${testspace}/installation/${openoffice.build}" />
210		<mkdir dir="${openoffice.installation.dir}" />
211		<unzip dest="${openoffice.installation.dir}">
212			<fileset dir="${openoffice.archive.dir}">
213				<include name="**/*.zip" />
214			</fileset>
215		</unzip>
216		<pathconvert property="gz.files" pathsep=" " setonempty="false">
217			<path>
218				<fileset dir="${openoffice.archive.dir}" includes="*.gz" />
219			</path>
220		</pathconvert>
221		<exec dir="${openoffice.installation.dir}" executable="tar" failifexecutionfails="false">
222			<arg line="-zxf ${gz.files}" />
223		</exec>
224		<pathconvert property="openoffice.bin" pathsep=" " setonempty="false">
225			<path>
226				<fileset dir="${openoffice.installation.dir}" includes="**/*/soffice.bin" followsymlinks="false" />
227			</path>
228		</pathconvert>
229		<dirname property="openoffice.home" file="${openoffice.bin}" />
230		<fail unless="openoffice.home" />
231		<echo>Openoffice is installed to ${openoffice.home}</echo>
232	</target>
233
234	<target name="run.test" depends="compile" description="Run junit">
235		<tstamp>
236			<format property="output.stamp" pattern="yyMMdd.hhmm" />
237		</tstamp>
238
239		<move file="${test.output}" tofile="${test.output}.${output.stamp}" failonerror="false" />
240		<mkdir dir="${test.result}" />
241		<mkdir dir="${test.report}" />
242		<mkdir dir="${test.output}/temp" />
243		<property file="${openoffice.home}/versionrc" prefix="version" />
244		<property file="${openoffice.home}/version.ini" />
245
246		<junit fork="yes" forkmode="once" tempdir="${test.output}/temp" printsummary="yes" showoutput="false" errorProperty="test.failed" failureProperty="test.failed" dir=".">
247			<sysproperty key="openoffice.home" value="${openoffice.home}" />
248			<sysproperty key="testspace" value="${testspace}" />
249			<syspropertyset>
250				<propertyref builtin="commandline" />
251			</syspropertyset>
252			<batchtest todir="${test.result}">
253				<fileset dir="${classes}" includes="${test.classes}" />
254			</batchtest>
255
256			<formatter type="xml" />
257			<classpath refid="test.classpath" />
258		</junit>
259
260		<junitreport todir="${test.report}">
261			<fileset dir="${test.result}">
262				<include name="TEST-*.xml" />
263			</fileset>
264			<report format="frames" styledir="${junit.style.dir}" todir="${test.report}">
265				<param name="TITLE" expression="GUI Test Result" />
266			</report>
267		</junitreport>
268	</target>
269
270	<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.">
271		<fail message="Test Failed" if="test.failed" />
272	</target>
273
274	<target name="report.test" unless="report.test.skip" description="Upload the testing result to report repository.">
275		<exec executable="hostname" outputproperty="host.name" />
276		<property name="report.to" value="${openoffice.build}_${host.name}" />
277		<!--
278		<echo>Sending report to ${report.repos.server}/${report.repos.dir}/${report.to}</echo>
279		<ftp server="${report.repos.server}" remotedir="${report.repos.dir}/${report.to}" userid="${report.repos.user}" password="${report.repos.password}" action="mkdir" />
280		<ftp server="${report.repos.server}" remotedir="${report.repos.dir}/${report.to}" userid="${report.repos.user}" password="${report.repos.password}" depends="yes">
281			<fileset dir="${test.output}">
282			</fileset>
283		</ftp>
284		-->
285		<echo>Uploading report to ${report.repos}/${report.to}</echo>
286		<tempfile property="report.to.temp" suffix=".output" destDir="${testspace}" deleteonexit="true"/>
287		<copy todir="${report.to.temp}/${report.to}">
288			<fileset dir="${test.output}" />
289		</copy>
290
291		<scp todir="${report.repos}">
292			<fileset dir="${report.to.temp}"/>
293		</scp>
294	</target>
295
296	<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.">
297		<loadfile property="local.build" srcFile="${testspace}/build.txt" quiet="true" failonerror="false" />
298		<fail message="The build has been tested! We don't want to test it twice.">
299			<condition>
300				<equals arg1="${openoffice.build}" arg2="${local.build}" trim="true" />
301			</condition>
302		</fail>
303		<mkdir dir="${testspace}" />
304		<echo file="${testspace}/build.txt">${openoffice.build}</echo>
305	</target>
306
307	<target name="routine.test" depends="detect.build,download.build,install.build,run.test,report.test" description="Periodically run testing.">
308		<fail message="Test Failed" if="test.failed" />
309	</target>
310</project>
311