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