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