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