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