xref: /aoo42x/test/build.xml (revision 6b55ece7)
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="." />
36	<property name="test.name" value="BVT" />
37	<property name="test.classes" value="testcase/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, prepare.junit">
59		<javac destdir="${classes}" debug="on" source="1.6" encoding="utf-8" includeantruntime="false">
60			<src path="testcommon/source"/>
61			<classpath>
62				<path refid="junit.classpath"/>
63			</classpath>
64		</javac>
65	</target>
66
67	<target name="testgui.init">
68		<mkdir dir="${classes}" />
69		<copy includeemptydirs="false" todir="${classes}">
70			<fileset dir="testgui/source">
71				<exclude name="**/*.java" />
72			</fileset>
73		</copy>
74	</target>
75
76	<target name="testgui.compile" depends="testgui.init, prepare.junit">
77		<javac destdir="${classes}" debug="on" source="1.6" encoding="utf-8" includeantruntime="false">
78			<src path="testgui/source"/>
79			<classpath>
80				<pathelement location="${classes}" />
81				<path refid="junit.classpath"/>
82			</classpath>
83		</javac>
84	</target>
85
86	<target name="testuno.init">
87		<mkdir dir="${classes}" />
88		<copy includeemptydirs="false" todir="${classes}">
89			<fileset dir="testuno/source">
90				<exclude name="**/*.java" />
91			</fileset>
92		</copy>
93	</target>
94
95	<target name="testuno.compile" depends="testuno.init">
96		<path id="uno.classpath">
97			<fileset dir="${openoffice.home}" erroronmissingdir="false">
98				<include name="**/juh.jar" />
99				<include name="**/unoil.jar" />
100				<include name="**/ridl.jar" />
101				<include name="**/jurt.jar" />
102			</fileset>
103		</path>
104		<javac destdir="${classes}" debug="on" source="1.6" encoding="utf-8" includeantruntime="false">
105			<src path="testuno/source"/>
106			<classpath>
107				<pathelement location="${classes}" />
108				<path refid="junit.classpath"/>
109				<path refid="uno.classpath"/>
110			</classpath>
111		</javac>
112	</target>
113
114	<target name="clean" description="Clean all output">
115		<delete dir="${testspace}" />
116	</target>
117
118	<target name="check.junit">
119		<available file="junit.jar" property="junit.jar.exists">
120			<filepath refid="junit.classpath" />
121		</available>
122	</target>
123
124	<target name="prepare.junit" depends="check.junit" unless="junit.jar.exists">
125		<property name="junit.jar.repos" value="http://repo1.maven.org/maven2/junit/junit/4.10/junit-4.10.jar" />
126		<mkdir dir="${junit.home}" />
127		<get src="${junit.jar.repos}" dest="${junit.home}/junit.jar" skipexisting="true" />
128	</target>
129
130	<target name="compile" depends="testcommon.init, testcommon.compile, testgui.init, testgui.compile, testuno.init, testuno.compile" description="Compile source code">
131	</target>
132
133	<target name="dist">
134		<tstamp />
135		<property name="dist.archive" value="aoo_test_${DSTAMP}.zip" />
136        <zip destfile="${dist}/${dist.archive}" basedir="." update="true" includes="testcommon/**,testgui/**,testuno/**,build.xml,build.example.properties,external/**,reportstyle/**" excludes="**/bin/**">
137        </zip>
138	</target>
139
140	<target name="check.build" description="Check the build context">
141		<condition property="openoffice.pack.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="find.build.skip">
145			<or>
146				<isset property="openoffice.pack.url" />
147				<isset property="openoffice.pack.dir" />
148				<isset property="openoffice.home" />
149			</or>
150		</condition>
151		<condition property="download.build.skip">
152			<or>
153				<isset property="openoffice.pack.dir" />
154				<isset property="openoffice.home" />
155			</or>
156		</condition>
157		<condition property="install.build.skip">
158            <isset property="openoffice.home" />
159		</condition>
160	</target>
161
162	<target name="find.build" unless="find.build.skip" description="Find the newest build on the remote server">
163		<loadresource property="openoffice.build">
164			<url url="${openoffice.build.url}" />
165			<filterchain>
166				<deletecharacters chars=" \t\r\n" />
167			</filterchain>
168		</loadresource>
169
170        <echo message="openoffice.pack.url=${openoffice.archive.url}" file="${testspace}/.temp.properties" />
171        <property file="${testspace}/.temp.properties"/>
172        <property name="openoffice.build.name" value="${openoffice.build}" />
173        <echo>#OpenOffice Build Name: ${openoffice.build.name}</echo>
174        <echo>#OpenOffice Package URL: ${openoffice.pack.url}</echo>
175	</target>
176
177    <target name="download" unless="${skip}">
178        <delete dir="${dest}" />
179        <mkdir dir="${dest}" />
180        <get src="${src}" dest="${dest}" verbose="false" usetimestamp="true" skipexisting="true" />
181    </target>
182
183	<target name="download.build" unless="download.build.skip" description="Download the specified build from the remote server">
184		<property name="openoffice.pack.dir" value="${testspace}/download" />
185        <property name="openoffice.pack.download.mark" value="${testspace}/download/url.txt"/>
186        <loadfile property="openoffice.pack.download.url" srcFile="${openoffice.pack.download.mark}" quiet="true" failonerror="false"/>
187        <condition property="download.build.skip" value="true" else="false">
188            <equals arg1="${openoffice.pack.download.url}" arg2="${openoffice.pack.url}"/>
189		</condition>
190
191        <echo>#Build is Downloaded: ${download.build.skip}</echo>
192        <antcall target="download" inheritAll="false">
193            <param name="skip" value="${download.build.skip}"/>
194            <param name="src" value="${openoffice.pack.url}"/>
195            <param name="dest" value="${openoffice.pack.dir}"/>
196        </antcall>
197        <!--
198		<get src="${openoffice.pack.url}" dest="${openoffice.pack.dir}" verbose="false" usetimestamp="true" skipexisting="true" />
199        -->
200        <echo message="${openoffice.pack.url}" file="${openoffice.pack.download.mark}" />
201        <echo>#OpenOffice Package Dir: ${openoffice.pack.dir}</echo>
202	</target>
203
204	<target name="install.build" unless="install.build.skip" description="Install the build to the local">
205		<property name="openoffice.install.dir" value="${testspace}/install/aoo" />
206        <property name="openoffice.install.temp" value="${testspace}/install/temp" />
207        <delete dir="${openoffice.install.temp}"/>
208		<mkdir dir="${openoffice.install.temp}" />
209		<unzip dest="${openoffice.install.temp}">
210			<fileset dir="${openoffice.pack.dir}">
211				<include name="**/Apache_OpenOffice*.zip" />
212			</fileset>
213		</unzip>
214		<pathconvert property="gz.files" pathsep=" " setonempty="false">
215			<path>
216				<fileset dir="${openoffice.pack.dir}" includes="Apache_OpenOffice*.gz" />
217			</path>
218		</pathconvert>
219		<exec dir="${openoffice.install.temp}" executable="tar" failifexecutionfails="false">
220			<arg line="-zxpf ${gz.files}" />
221		</exec>
222        <pathconvert property="openoffice.root.dir" pathsep=" " setonempty="false">
223			<path>
224				<dirset dir="${openoffice.install.temp}">
225                    <include name="*"/>
226                </dirset>
227			</path>
228		</pathconvert>
229        <delete dir="${openoffice.install.dir}"/>
230        <move file="${openoffice.root.dir}" tofile="${openoffice.install.dir}"/>
231        <delete dir="${openoffice.install.temp}"/>
232		<pathconvert property="openoffice.bin" pathsep=" " setonempty="false">
233			<path>
234				<fileset dir="${openoffice.install.dir}" includes="**/*/soffice.bin" followsymlinks="false" />
235			</path>
236		</pathconvert>
237		<dirname property="openoffice.bin.parent" file="${openoffice.bin}" />
238		<property name="openoffice.home" location="${openoffice.bin.parent}/../" />
239		<fail unless="openoffice.home" />
240		<echo>#Openoffice Home: ${openoffice.home}</echo>
241	</target>
242
243	<target name="run.test" depends="compile, detect.testenv" description="Run junit">
244		<tstamp>
245			<format property="output.stamp" pattern="yyMMdd.hhmm" />
246		</tstamp>
247
248		<move file="${test.output}" tofile="${test.output}.${output.stamp}" failonerror="false" />
249		<mkdir dir="${test.result}" />
250		<mkdir dir="${test.report}" />
251		<mkdir dir="${test.output}/temp" />
252
253		<junit fork="yes" forkmode="once" tempdir="${test.output}/temp" printsummary="yes" showoutput="false" errorProperty="test.failed" failureProperty="test.failed" dir=".">
254			<env key="DISPLAY" value="${env.DISPLAY}"/>
255            <sysproperty key="openoffice.home" value="${openoffice.home}" />
256			<sysproperty key="testspace" value="${testspace}" />
257			<syspropertyset>
258				<propertyref builtin="commandline" />
259			</syspropertyset>
260			<batchtest todir="${test.result}">
261				<fileset dir="${classes}" includes="${test.classes}" />
262			</batchtest>
263
264			<formatter type="xml" />
265			<classpath>
266				<pathelement location="${classes}" />
267                <pathelement location="testgui/data" />
268                <pathelement location="testuno/data" />
269				<path refid="junit.classpath"/>
270				<path refid="uno.classpath"/>
271			</classpath>
272		</junit>
273
274		<junitreport todir="${test.report}">
275			<fileset dir="${test.result}">
276				<include name="TEST-*.xml" />
277			</fileset>
278			<report format="frames" styledir="${junit.style.dir}" todir="${test.report}">
279				<param name="TITLE" expression="${test.name}: ${openoffice.build.name}, ${test.os.name}-${test.os.version}-${test.os.arch}"/>
280			</report>
281		</junitreport>
282		<property name="test.report.index" location="${test.report}/index.html" />
283		<echo>Open ${test.report.index} in browser to view the test report.</echo>
284	</target>
285
286	<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.">
287		<fail message="Test Failed" if="test.failed" />
288	</target>
289
290	<target name="detect.testenv">
291		<exec outputproperty="test.os.name" executable="lsb_release" failifexecutionfails="false" os="Linux">
292			<arg line="-is" />
293		</exec>
294		<exec outputproperty="test.os.version" executable="lsb_release" failifexecutionfails="false" os="Linux">
295			<arg line="-rs" />
296		</exec>
297		<property name="test.os.name" value="${os.name}" />
298		<property name="test.os.version" value="${os.version}" />
299		<property name="test.os.arch" value="${os.arch}" />
300		<echo>${test.os.name}-${test.os.version}-${test.os.arch}</echo>
301        <property file="${openoffice.home}/program/versionrc" prefix="openoffice"/>
302        <property file="${openoffice.home}/program/version.ini" prefix="openoffice"/>
303        <property name="openoffice.build.name" value=""/>
304	</target>
305
306
307	<target name="report.test" unless="report.test.skip" description="Upload the testing result to report repository." depends="detect.testenv">
308		<property name="report.to" value="${openoffice.build.name}/${test.name}/${test.os.name}-${test.os.version}-${test.os.arch}" />
309		<echo>Uploading report to ${report.repos}/${report.to}</echo>
310		<property name="report.to.temp" location="${testspace}/.temp.ouput"/>
311        <delete dir="${report.to.temp}" deleteonexit="true"/>
312		<copy todir="${report.to.temp}/${report.to}">
313			<fileset dir="${test.output}" />
314		</copy>
315		<scp todir="${report.repos}" trust="true">
316			<fileset dir="${report.to.temp}"/>
317		</scp>
318        <delete dir="${report.to.temp}" deleteonexit="true"/>
319	</target>
320
321	<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.">
322		<property name="test.mark.file" location="${testspace}/${test.name}.build"/>
323		<loadfile property="local.build" srcFile="${test.mark.file}" quiet="true" failonerror="false" />
324		<fail message="The build has been tested! We don't want to test it twice.">
325			<condition>
326				<equals arg1="${openoffice.build}" arg2="${local.build}" trim="true" />
327			</condition>
328		</fail>
329		<mkdir dir="${testspace}" />
330		<echo file="${test.mark.file}">${openoffice.build}</echo>
331	</target>
332
333	<target name="routine.test" depends="detect.build,download.build,install.build,run.test,report.test" description="Periodically run testing.">
334		<fail message="Test Failed" if="test.failed" />
335	</target>
336</project>
337