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.pack.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="find.build.skip"> 151 <or> 152 <isset property="openoffice.pack.url" /> 153 <isset property="openoffice.pack.dir" /> 154 <isset property="openoffice.home" /> 155 </or> 156 </condition> 157 <condition property="download.build.skip"> 158 <or> 159 <isset property="openoffice.pack.dir" /> 160 <isset property="openoffice.home" /> 161 </or> 162 </condition> 163 <condition property="install.build.skip"> 164 <isset property="openoffice.home" /> 165 </condition> 166 </target> 167 168 <target name="find.build" unless="find.build.skip" description="Find the newest build on the remote server"> 169 <loadresource property="openoffice.build"> 170 <url url="${openoffice.build.url}" /> 171 <filterchain> 172 <deletecharacters chars=" \t\r\n" /> 173 </filterchain> 174 </loadresource> 175 176 <echo message="openoffice.pack.url=${openoffice.archive.url}" file="${testspace}/.temp.properties" /> 177 <property file="${testspace}/.temp.properties"/> 178 <property name="openoffice.build.name" value="${openoffice.build}" /> 179 <echo>#OpenOffice Build Name: ${openoffice.build.name}</echo> 180 <echo>#OpenOffice Package URL: ${openoffice.pack.url}</echo> 181 </target> 182 183 <target name="download" unless="${skip}"> 184 <delete dir="${dest}" /> 185 <mkdir dir="${dest}" /> 186 <get src="${src}" dest="${dest}" verbose="false" usetimestamp="true" skipexisting="true" /> 187 </target> 188 189 <target name="download.build" unless="download.build.skip" description="Download the specified build from the remote server"> 190 <property name="openoffice.pack.dir" value="${testspace}/download" /> 191 <property name="openoffice.pack.download.mark" value="${testspace}/download/url.txt"/> 192 <loadfile property="openoffice.pack.download.url" srcFile="${openoffice.pack.download.mark}" quiet="true" failonerror="false"/> 193 <condition property="download.build.skip" value="true" else="false"> 194 <equals arg1="${openoffice.pack.download.url}" arg2="${openoffice.pack.url}"/> 195 </condition> 196 197 <echo>#Build is Downloaded: ${download.build.skip}</echo> 198 <antcall target="download" inheritAll="false"> 199 <param name="skip" value="${download.build.skip}"/> 200 <param name="src" value="${openoffice.pack.url}"/> 201 <param name="dest" value="${openoffice.pack.dir}"/> 202 </antcall> 203 <!-- 204 <get src="${openoffice.pack.url}" dest="${openoffice.pack.dir}" verbose="false" usetimestamp="true" skipexisting="true" /> 205 --> 206 <echo message="${openoffice.pack.url}" file="${openoffice.pack.download.mark}" /> 207 <echo>#OpenOffice Package Dir: ${openoffice.pack.dir}</echo> 208 </target> 209 210 <target name="install.build" unless="install.build.skip" description="Install the build to the local"> 211 <property name="openoffice.install.dir" value="${testspace}/install/aoo" /> 212 <property name="openoffice.install.temp" value="${testspace}/install/temp" /> 213 <delete dir="${openoffice.install.temp}"/> 214 <mkdir dir="${openoffice.install.temp}" /> 215 <unzip dest="${openoffice.install.temp}"> 216 <fileset dir="${openoffice.pack.dir}"> 217 <include name="**/Apache_OpenOffice*.zip" /> 218 </fileset> 219 </unzip> 220 <pathconvert property="gz.files" pathsep=" " setonempty="false"> 221 <path> 222 <fileset dir="${openoffice.pack.dir}" includes="Apache_OpenOffice*.gz" /> 223 </path> 224 </pathconvert> 225 <exec dir="${openoffice.install.temp}" executable="tar" failifexecutionfails="false"> 226 <arg line="-zxpf ${gz.files}" /> 227 </exec> 228 <pathconvert property="openoffice.root.dir" pathsep=" " setonempty="false"> 229 <path> 230 <dirset dir="${openoffice.install.temp}"> 231 <include name="*"/> 232 </dirset> 233 </path> 234 </pathconvert> 235 <delete dir="${openoffice.install.dir}"/> 236 <move file="${openoffice.root.dir}" tofile="${openoffice.install.dir}"/> 237 <delete dir="${openoffice.install.temp}"/> 238 <pathconvert property="openoffice.bin" pathsep=" " setonempty="false"> 239 <path> 240 <fileset dir="${openoffice.install.dir}" includes="**/*/soffice.bin" followsymlinks="false" /> 241 </path> 242 </pathconvert> 243 <dirname property="openoffice.bin.parent" file="${openoffice.bin}" /> 244 <property name="openoffice.home" location="${openoffice.bin.parent}/../" /> 245 <fail unless="openoffice.home" /> 246 <echo>#Openoffice Home: ${openoffice.home}</echo> 247 </target> 248 249 <target name="run.test" depends="compile, detect.testenv" description="Run junit"> 250 <tstamp> 251 <format property="output.stamp" pattern="yyMMdd.hhmm" /> 252 </tstamp> 253 254 <move file="${test.output}" tofile="${test.output}.${output.stamp}" failonerror="false" /> 255 <mkdir dir="${test.result}" /> 256 <mkdir dir="${test.report}" /> 257 <mkdir dir="${test.output}/temp" /> 258 259 <junit fork="yes" forkmode="once" tempdir="${test.output}/temp" printsummary="yes" showoutput="false" errorProperty="test.failed" failureProperty="test.failed" dir="."> 260 <env key="DISPLAY" value="${env.DISPLAY}"/> 261 <sysproperty key="openoffice.home" value="${openoffice.home}" /> 262 <sysproperty key="testspace" value="${testspace}" /> 263 <syspropertyset> 264 <propertyref builtin="commandline" /> 265 </syspropertyset> 266 <batchtest todir="${test.result}"> 267 <fileset dir="${classes}" includes="${test.classes}" /> 268 </batchtest> 269 270 <formatter type="xml" /> 271 <classpath> 272 <pathelement location="${classes}" /> 273 <path refid="junit.classpath"/> 274 <path refid="uno.classpath"/> 275 </classpath> 276 </junit> 277 278 <junitreport todir="${test.report}"> 279 <fileset dir="${test.result}"> 280 <include name="TEST-*.xml" /> 281 </fileset> 282 <report format="frames" styledir="${junit.style.dir}" todir="${test.report}"> 283 <param name="TITLE" expression="${test.name}: ${openoffice.build.name}, ${test.os.name}-${test.os.version}-${test.os.arch}"/> 284 </report> 285 </junitreport> 286 <property name="test.report.index" location="${test.report}/index.html" /> 287 <echo>Open ${test.report.index} in browser to view the test report.</echo> 288 </target> 289 290 <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."> 291 <fail message="Test Failed" if="test.failed" /> 292 </target> 293 294 <target name="detect.testenv"> 295 <exec outputproperty="test.os.name" executable="lsb_release" failifexecutionfails="false" os="Linux"> 296 <arg line="-is" /> 297 </exec> 298 <exec outputproperty="test.os.version" executable="lsb_release" failifexecutionfails="false" os="Linux"> 299 <arg line="-rs" /> 300 </exec> 301 <property name="test.os.name" value="${os.name}" /> 302 <property name="test.os.version" value="${os.version}" /> 303 <property name="test.os.arch" value="${os.arch}" /> 304 <echo>${test.os.name}-${test.os.version}-${test.os.arch}</echo> 305 <property file="${openoffice.home}/program/versionrc" prefix="openoffice"/> 306 <property file="${openoffice.home}/program/version.ini" prefix="openoffice"/> 307 <property name="openoffice.build.name" value=""/> 308 </target> 309 310 311 <target name="report.test" unless="report.test.skip" description="Upload the testing result to report repository." depends="detect.testenv"> 312 <property name="report.to" value="${openoffice.build.name}/${test.name}/${test.os.name}-${test.os.version}-${test.os.arch}" /> 313 <echo>Uploading report to ${report.repos}/${report.to}</echo> 314 <property name="report.to.temp" location="${testspace}/.temp.ouput"/> 315 <delete dir="${report.to.temp}" deleteonexit="true"/> 316 <copy todir="${report.to.temp}/${report.to}"> 317 <fileset dir="${test.output}" /> 318 </copy> 319 <scp todir="${report.repos}" trust="true"> 320 <fileset dir="${report.to.temp}"/> 321 </scp> 322 <delete dir="${report.to.temp}" deleteonexit="true"/> 323 </target> 324 325 <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."> 326 <property name="test.mark.file" location="${testspace}/${test.name}.build"/> 327 <loadfile property="local.build" srcFile="${test.mark.file}" quiet="true" failonerror="false" /> 328 <fail message="The build has been tested! We don't want to test it twice."> 329 <condition> 330 <equals arg1="${openoffice.build}" arg2="${local.build}" trim="true" /> 331 </condition> 332 </fail> 333 <mkdir dir="${testspace}" /> 334 <echo file="${test.mark.file}">${openoffice.build}</echo> 335 </target> 336 337 <target name="routine.test" depends="detect.build,download.build,install.build,run.test,report.test" description="Periodically run testing."> 338 <fail message="Test Failed" if="test.failed" /> 339 </target> 340</project> 341