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