xref: /aoo42x/test/build.xml (revision 7dd7871f)
1<?xml version="1.0"?>
2<!--************************************************************************
3 *
4 * Licensed Materials - Property of IBM.
5 * (C) Copyright IBM Corporation 2003, 2012.  All Rights Reserved.
6 * U.S. Government Users Restricted Rights:
7 * Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
8 *
9 ************************************************************************ -->
10
11<project basedir="." default="test">
12	<property file="build.properties" />
13	<property environment="env" />
14	<property name="src" value="./src" />
15	<property name="out" value="output"/>
16	<property name="classes" value="${out}/class" />
17	<property name="lib" value="${out}/lib" />
18	<property name="dist" value="${out}/dist" />
19
20	<property name="env.TESTSPACE" value="../testspace" />
21	<property name="junit.home" value="${env.JUNIT_HOME}" />
22	<property name="testspace" value="${env.TESTSPACE}" />
23	<property name="test.classes" value="testsuite/BVT.class" />
24	<property name="test.output" value="${testspace}/output" />
25	<property name="test.result" value="${test.output}/result" />
26	<property name="test.report" value="${test.output}/report" />
27	<property name="junit.style.dir" value="./reportstyle" />
28
29	<path id="classpath">
30		<pathelement location="${classes}" />
31		<fileset dir="${lib}" erroronmissingdir="false">
32			<include name="**/testcommon.jar" />
33			<include name="**/junit.jar" />
34		</fileset>
35		<fileset dir="${solar.jar}" erroronmissingdir="false">
36			<include name="**/testcommon.jar" />
37			<include name="**/junit.jar" />
38		</fileset>
39		<fileset dir="${junit.home}" erroronmissingdir="false">
40			<include name="*.jar" />
41		</fileset>
42	</path>
43
44	<target name="init">
45		<mkdir dir="${classes}" />
46		<mkdir dir="${lib}" />
47		<copy includeemptydirs="false" todir="${classes}">
48			<fileset dir="src">
49				<exclude name="**/*.java" />
50			</fileset>
51		</copy>
52	</target>
53
54	<target name="clean" description="Clean all output">
55		<delete dir="${classes}" />
56		<delete dir="${testspace}" />
57	</target>
58
59	<target name="check.dependencies">
60		<available file="testcommon.jar" property="testcommon.jar.exists">
61			<filepath refid="classpath" />
62		</available>
63		<available file="junit.jar" property="junit.jar.exists">
64			<filepath refid="classpath" />
65		</available>
66	</target>
67
68	<target name="prepare.junit" unless="junit.jar.exists">
69		<property name="junit.jar.repos" value="http://repo1.maven.org/maven2/junit/junit/4.10/junit-4.10.jar" />
70		<get src="${junit.jar.repos}" dest="${lib}/junit.jar" skipexisting="true" />
71	</target>
72
73	<target name="prepare.testcommon" unless="testcommon.jar.exists">
74		<ant dir="../testcommon" target="dist" inheritAll="false">
75			<property name="dist" location="${lib}" />
76		</ant>
77	</target>
78
79	<target name="prepare.dependencies" depends="init, check.dependencies, prepare.junit, prepare.testcommon" description="Download all dependencies">
80	</target>
81
82	<target name="compile" depends="init, prepare.dependencies" description="Compile source code">
83		<javac srcdir="${src}" destdir="${classes}" debug="on" source="1.6">
84			<classpath refid="classpath" />
85		</javac>
86	</target>
87
88	<target name="dist" depends="compile">
89		<tstamp />
90		<property name="dist.archive" value="testoo_${DSTAMP}.zip" />
91		<zip destfile="../${dist.archive}" basedir="." update="true" />
92	</target>
93
94	<target name="check.build" description="Check the build context">
95		<condition property="openoffice.archive.dir" value="${env.SRC_ROOT}/instsetoo_native/${env.INPATH}/OpenOffice/archive/install/en-US">
96			<and>
97				<isset property="env.SRC_ROOT" />
98				<isset property="env.INPATH" />
99			</and>
100		</condition>
101
102		<condition property="openoffice.build" value="localbuild">
103			<isset property="openoffice.archive.dir" />
104		</condition>
105
106		<condition property="find.build.skip">
107			<or>
108				<isset property="openoffice.build" />
109				<isset property="openoffice.archive.url" />
110				<isset property="openoffice.archive.dir" />
111				<isset property="openoffice.home" />
112			</or>
113		</condition>
114		<condition property="download.build.skip">
115			<or>
116				<isset property="openoffice.archive.dir" />
117				<isset property="openoffice.home" />
118			</or>
119		</condition>
120		<condition property="install.build.skip">
121			<or>
122				<isset property="openoffice.home" />
123			</or>
124		</condition>
125	</target>
126
127	<target name="find.build" unless="find.build.skip" description="Find the newest build on the remote server">
128		<loadresource property="openoffice.build">
129			<url url="${openoffice.build.url}" />
130			<filterchain>
131				<deletecharacters chars=" \t\r\n" />
132			</filterchain>
133		</loadresource>
134		<echo>Latest build: ${openoffice.build}</echo>
135	</target>
136
137	<target name="download.build" unless="download.build.skip" description="Download the specified build from the remote server">
138		<script language="javascript">
139					  	value = project.getProperty("openoffice.archive.url");
140					    resolvedValue = project.replaceProperties(value);
141						project.setProperty("openoffice.archive.url", resolvedValue);
142		</script>
143		<echo>Archive address: ${openoffice.archive.url}</echo>
144		<property name="openoffice.archive.dir" value="${testspace}/download/${openoffice.build}" />
145		<mkdir dir="${openoffice.archive.dir}" />
146		<get src="${openoffice.archive.url}" dest="${openoffice.archive.dir}" verbose="false" usetimestamp="true" skipexisting="true" />
147	</target>
148
149	<target name="install.build" unless="install.build.skip" description="Install the build to the local">
150		<property name="openoffice.installation.dir" value="${testspace}/installation/${openoffice.build}" />
151		<mkdir dir="${openoffice.installation.dir}" />
152		<unzip dest="${openoffice.installation.dir}">
153			<fileset dir="${openoffice.archive.dir}">
154				<include name="**/*.zip" />
155			</fileset>
156		</unzip>
157		<pathconvert property="gz.files" pathsep=" " setonempty="false">
158			<path>
159				<fileset dir="${openoffice.archive.dir}" includes="*.gz" />
160			</path>
161		</pathconvert>
162		<exec dir="${openoffice.installation.dir}" executable="tar" failifexecutionfails="false">
163			<arg line="-zxf ${gz.files}" />
164		</exec>
165		<pathconvert property="openoffice.bin" pathsep=" " setonempty="false">
166			<path>
167				<fileset dir="${openoffice.installation.dir}" includes="**/*/soffice.bin" followsymlinks="false" />
168			</path>
169		</pathconvert>
170		<dirname property="openoffice.home" file="${openoffice.bin}" />
171		<fail unless="openoffice.home" />
172		<echo>Openoffice is installed to ${openoffice.home}</echo>
173	</target>
174
175	<target name="clean.test" unless="clean.test.skip" description="Clean testing footprint">
176		<delete dir="${testspace}/oouser" quiet="true" failonerror="false" />
177	</target>
178
179	<target name="run.test" depends="compile" description="Run junit">
180		<tstamp>
181			<format property="output.stamp" pattern="yyMMdd.hhmm" />
182		</tstamp>
183
184		<move file="${test.output}" tofile="${test.output}.${output.stamp}" failonerror="false" />
185		<mkdir dir="${test.result}" />
186		<mkdir dir="${test.report}" />
187		<mkdir dir="${test.output}/temp" />
188		<property file="${openoffice.home}/versionrc" prefix="version" />
189		<property file="${openoffice.home}/version.ini" />
190
191		<junit fork="yes" forkmode="once" tempdir="${test.output}/temp" printsummary="yes" showoutput="false" errorProperty="test.failed" failureProperty="test.failed" dir=".">
192			<sysproperty key="openoffice.home" value="${openoffice.home}" />
193			<sysproperty key="testspace" value="${testspace}" />
194			<syspropertyset>
195				<propertyref builtin="commandline" />
196			</syspropertyset>
197			<batchtest todir="${test.result}">
198				<fileset dir="${classes}" includes="${test.classes}" />
199			</batchtest>
200
201			<formatter type="xml" />
202			<classpath refid="classpath" />
203		</junit>
204
205		<junitreport todir="${test.report}">
206			<fileset dir="${test.result}">
207				<include name="TEST-*.xml" />
208			</fileset>
209			<report format="frames" styledir="${junit.style.dir}" todir="${test.report}">
210				<param name="TITLE" expression="GUI Test Result" />
211			</report>
212		</junitreport>
213	</target>
214
215	<target name="test" depends="check.build,find.build,download.build,install.build,clean.test,run.test" description="Run testing on the specified build. The build is automatically downloaded and installed according to the context.">
216		<fail message="Test Failed" if="test.failed" />
217	</target>
218
219	<target name="report.test" unless="report.test.skip" description="Upload the testing result to report repository.">
220		<exec executable="hostname" outputproperty="host.name" />
221		<property name="report.to" value="${openoffice.build}/${host.name}" />
222		<echo>Sending report to ${report.repos.server}/${report.repos.dir}/${report.to}</echo>
223		<ftp server="${report.repos.server}" remotedir="${report.repos.dir}/${report.to}" userid="${report.repos.user}" password="${report.repos.password}" action="mkdir" />
224		<ftp server="${report.repos.server}" remotedir="${report.repos.dir}/${report.to}" userid="${report.repos.user}" password="${report.repos.password}" depends="yes">
225			<fileset dir="${test.output}">
226			</fileset>
227		</ftp>
228	</target>
229
230	<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.">
231		<loadfile property="local.build" srcFile="${testspace}/build.txt" quiet="true" failonerror="false" />
232		<fail message="The build has been tested! We don't want to test it twice.">
233			<condition>
234				<equals arg1="${openoffice.build}" arg2="${local.build}" trim="true" />
235			</condition>
236		</fail>
237		<mkdir dir="${testspace}" />
238		<echo file="${testspace}/build.txt">${openoffice.build}</echo>
239	</target>
240
241	<target name="routine.test" depends="detect.build,download.build,install.build,clean.test,run.test,report.test" description="Periodically run testing.">
242		<fail message="Test Failed" if="test.failed" />
243	</target>
244</project>
245