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