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.TESTSPACE" value="testspace" /> 30 <property name="env.JUNIT_HOME" value="external/junit" /> 31 <property name="junit.home" value="${env.JUNIT_HOME}" /> 32 <property name="testspace" value="${env.TESTSPACE}" /> 33 <property name="classes" value="${testspace}/class" /> 34 <property name="dist" value="${testspace}" /> 35 <property name="test.name" value="BVT" /> 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="upgrade"> 49 <property name="upgrade.script" location="${java.io.tmpdir}/aoo_test_upgrade.xml"/> 50 <property name="upgrade.to" location="."/> 51 <copy file="build.xml" tofile="${upgrade.script}"/> 52 <condition property="ant.executable" value="ant.bat"> 53 <os family="windows" /> 54 </condition> 55 <property name="ant.executable" value="ant"/> 56 <exec executable="${ant.executable}" spawn="true"> 57 <arg value="-Dupgrade.to=${upgrade.to}"/> 58 <arg value="-f"/> 59 <arg value="${upgrade.script}"/> 60 <arg value="upgrade.run"/> 61 </exec> 62 </target> 63 64 <target name="upgrade.run"> 65 <property name="testpack.url" value="http://9.123.117.85/testpack/trunk/aoo_test.zip"/> 66 <property name="testack.temp" location="${java.io.tmpdir}/aoo_test.zip"/> 67 <get src="${testpack.url}" dest="${testack.temp}"/> 68 <delete dir="${upgrade.to}" failonerror="false"/> 69 <mkdir dir="${upgrade.to}"/> 70 <unzip src="${testack.temp}" dest="${upgrade.to}"/> 71 </target> 72 73 <target name="testcommon.init"> 74 <mkdir dir="${classes}" /> 75 <copy includeemptydirs="false" todir="${classes}"> 76 <fileset dir="testcommon/source"> 77 <exclude name="**/*.java" /> 78 </fileset> 79 </copy> 80 </target> 81 82 <target name="testcommon.compile" depends="testcommon.init, prepare.junit"> 83 <javac destdir="${classes}" debug="on" source="1.6" encoding="utf-8" includeantruntime="false"> 84 <src path="testcommon/source"/> 85 <classpath> 86 <path refid="junit.classpath"/> 87 </classpath> 88 </javac> 89 </target> 90 91 <target name="testgui.init"> 92 <mkdir dir="${classes}" /> 93 <copy includeemptydirs="false" todir="${classes}"> 94 <fileset dir="testgui/source"> 95 <exclude name="**/*.java" /> 96 </fileset> 97 </copy> 98 </target> 99 100 <target name="testgui.compile" depends="testgui.init, prepare.junit"> 101 <javac destdir="${classes}" debug="on" source="1.6" encoding="utf-8" includeantruntime="false"> 102 <src path="testgui/source"/> 103 <classpath> 104 <pathelement location="${classes}" /> 105 <path refid="junit.classpath"/> 106 </classpath> 107 </javac> 108 </target> 109 110 <target name="testuno.init"> 111 <mkdir dir="${classes}" /> 112 <copy includeemptydirs="false" todir="${classes}"> 113 <fileset dir="testuno/source"> 114 <exclude name="**/*.java" /> 115 </fileset> 116 </copy> 117 </target> 118 119 <target name="testuno.compile" depends="testuno.init"> 120 <path id="uno.classpath"> 121 <fileset dir="${openoffice.home}" erroronmissingdir="false"> 122 <include name="**/juh.jar" /> 123 <include name="**/unoil.jar" /> 124 <include name="**/ridl.jar" /> 125 <include name="**/jurt.jar" /> 126 </fileset> 127 </path> 128 <javac destdir="${classes}" debug="on" source="1.6" encoding="utf-8" includeantruntime="false"> 129 <src path="testuno/source"/> 130 <classpath> 131 <pathelement location="${classes}" /> 132 <path refid="junit.classpath"/> 133 <path refid="uno.classpath"/> 134 </classpath> 135 </javac> 136 </target> 137 138 <target name="clean" description="Clean all output"> 139 <delete dir="${testspace}" /> 140 </target> 141 142 <target name="check.junit"> 143 <available file="junit.jar" property="junit.jar.exists"> 144 <filepath refid="junit.classpath" /> 145 </available> 146 </target> 147 148 <target name="prepare.junit" depends="check.junit" unless="junit.jar.exists"> 149 <property name="junit.jar.repos" value="http://repo1.maven.org/maven2/junit/junit/4.10/junit-4.10.jar" /> 150 <mkdir dir="${junit.home}" /> 151 <get src="${junit.jar.repos}" dest="${junit.home}/junit.jar" skipexisting="true" /> 152 </target> 153 154 <target name="compile" depends="testcommon.init, testcommon.compile, testgui.init, testgui.compile, testuno.init, testuno.compile" description="Compile source code"> 155 </target> 156 157 <target name="dist"> 158 <tstamp /> 159 <tstamp> 160 <format property="testpack.version" pattern="yyyyMMddhhmmss"/> 161 </tstamp> 162 <property name="dist.archive" value="aoo_test_${DSTAMP}.zip" /> 163 <echo file="${testpack.version}">${testpack.version}</echo> 164 <zip destfile="${dist}/${dist.archive}" basedir="." update="false" excludes="testspace/**,testassistant/**,testassistant.feature/**,**/bin/**"> 165 </zip> 166 <delete file="${testpack.version}"/> 167 </target> 168 169 <target name="check.build" description="Check the build context"> 170 <condition property="openoffice.pack.dir" value="${env.SRC_ROOT}/instsetoo_native/${env.INPATH}/OpenOffice/archive/install/en-US"> 171 <isset property="env.SRC_ROOT" /> 172 </condition> 173 <condition property="find.build.skip"> 174 <or> 175 <isset property="openoffice.pack.url" /> 176 <isset property="openoffice.pack.dir" /> 177 <isset property="openoffice.home" /> 178 </or> 179 </condition> 180 <condition property="download.build.skip"> 181 <or> 182 <isset property="openoffice.pack.dir" /> 183 <isset property="openoffice.home" /> 184 </or> 185 </condition> 186 <condition property="install.build.skip"> 187 <isset property="openoffice.home" /> 188 </condition> 189 </target> 190 191 <target name="find.build" unless="find.build.skip" description="Find the newest build on the remote server"> 192 <loadresource property="openoffice.build"> 193 <url url="${openoffice.build.url}" /> 194 <filterchain> 195 <deletecharacters chars=" \t\r\n" /> 196 </filterchain> 197 </loadresource> 198 199 <echo message="openoffice.pack.url=${openoffice.archive.url}" file="${testspace}/.temp.properties" /> 200 <property file="${testspace}/.temp.properties"/> 201 <property name="openoffice.build.name" value="${openoffice.build}" /> 202 <echo>#OpenOffice Build Name: ${openoffice.build.name}</echo> 203 <echo>#OpenOffice Package URL: ${openoffice.pack.url}</echo> 204 </target> 205 206 <target name="download" unless="${skip}"> 207 <delete dir="${dest}" /> 208 <mkdir dir="${dest}" /> 209 <get src="${src}" dest="${dest}" verbose="false" usetimestamp="true" skipexisting="true" /> 210 </target> 211 212 <target name="download.build" unless="download.build.skip" description="Download the specified build from the remote server"> 213 <property name="openoffice.pack.dir" value="${testspace}/download" /> 214 <property name="openoffice.pack.download.mark" value="${testspace}/download/url.txt"/> 215 <loadfile property="openoffice.pack.download.url" srcFile="${openoffice.pack.download.mark}" quiet="true" failonerror="false"/> 216 <condition property="download.build.skip" value="true" else="false"> 217 <equals arg1="${openoffice.pack.download.url}" arg2="${openoffice.pack.url}"/> 218 </condition> 219 220 <echo>#Build is Downloaded: ${download.build.skip}</echo> 221 <antcall target="download" inheritAll="false"> 222 <param name="skip" value="${download.build.skip}"/> 223 <param name="src" value="${openoffice.pack.url}"/> 224 <param name="dest" value="${openoffice.pack.dir}"/> 225 </antcall> 226 <!-- 227 <get src="${openoffice.pack.url}" dest="${openoffice.pack.dir}" verbose="false" usetimestamp="true" skipexisting="true" /> 228 --> 229 <echo message="${openoffice.pack.url}" file="${openoffice.pack.download.mark}" /> 230 <echo>#OpenOffice Package Dir: ${openoffice.pack.dir}</echo> 231 </target> 232 233 <target name="install.build" unless="install.build.skip" description="Install the build to the local"> 234 <property name="openoffice.install.dir" value="${testspace}/install/aoo" /> 235 <property name="openoffice.install.temp" value="${testspace}/install/temp" /> 236 <delete dir="${openoffice.install.temp}"/> 237 <mkdir dir="${openoffice.install.temp}" /> 238 <unzip dest="${openoffice.install.temp}"> 239 <fileset dir="${openoffice.pack.dir}"> 240 <include name="**/Apache_OpenOffice*.zip" /> 241 </fileset> 242 </unzip> 243 <pathconvert property="gz.files" pathsep=" " setonempty="false"> 244 <path> 245 <fileset dir="${openoffice.pack.dir}" includes="Apache_OpenOffice*.gz" /> 246 </path> 247 </pathconvert> 248 <exec dir="${openoffice.install.temp}" executable="tar" failifexecutionfails="false"> 249 <arg line="-zxpf ${gz.files}" /> 250 </exec> 251 <pathconvert property="openoffice.root.dir" pathsep=" " setonempty="false"> 252 <path> 253 <dirset dir="${openoffice.install.temp}"> 254 <include name="*"/> 255 </dirset> 256 </path> 257 </pathconvert> 258 <delete dir="${openoffice.install.dir}"/> 259 <move file="${openoffice.root.dir}" tofile="${openoffice.install.dir}"/> 260 <delete dir="${openoffice.install.temp}"/> 261 <pathconvert property="openoffice.bin" pathsep=" " setonempty="false"> 262 <path> 263 <fileset dir="${openoffice.install.dir}" includes="**/*/soffice.bin" followsymlinks="false" /> 264 </path> 265 </pathconvert> 266 <dirname property="openoffice.bin.parent" file="${openoffice.bin}" /> 267 <property name="openoffice.home" location="${openoffice.bin.parent}/../" /> 268 <fail unless="openoffice.home" /> 269 <echo>#Openoffice Home: ${openoffice.home}</echo> 270 </target> 271 272 <target name="run.test" depends="compile, detect.testenv" description="Run junit"> 273 <tstamp> 274 <format property="output.stamp" pattern="yyMMdd.hhmm" /> 275 </tstamp> 276 277 <move file="${test.output}" tofile="${test.output}.${output.stamp}" failonerror="false" /> 278 <mkdir dir="${test.result}" /> 279 <mkdir dir="${test.report}" /> 280 <mkdir dir="${test.output}/temp" /> 281 282 <junit fork="yes" forkmode="once" tempdir="${test.output}/temp" printsummary="yes" showoutput="false" errorProperty="test.failed" failureProperty="test.failed" dir="."> 283 <env key="DISPLAY" value="${env.DISPLAY}"/> 284 <sysproperty key="openoffice.home" value="${openoffice.home}" /> 285 <sysproperty key="testspace" value="${testspace}" /> 286 <syspropertyset> 287 <propertyref builtin="commandline" /> 288 </syspropertyset> 289 <batchtest todir="${test.result}"> 290 <fileset dir="${classes}" includes="${test.classes}" /> 291 </batchtest> 292 293 <formatter type="xml" /> 294 <classpath> 295 <pathelement location="${classes}" /> 296 <pathelement location="testgui/data" /> 297 <pathelement location="testuno/data" /> 298 <path refid="junit.classpath"/> 299 <path refid="uno.classpath"/> 300 </classpath> 301 </junit> 302 303 <junitreport todir="${test.report}"> 304 <fileset dir="${test.result}"> 305 <include name="TEST-*.xml" /> 306 </fileset> 307 <report format="frames" styledir="${junit.style.dir}" todir="${test.report}"> 308 <param name="TITLE" expression="${test.name}: ${openoffice.build.name}, ${test.os.name}-${test.os.version}-${test.os.arch}"/> 309 </report> 310 </junitreport> 311 <property name="test.report.index" location="${test.report}/index.html" /> 312 <echo>Open ${test.report.index} in browser to view the test report.</echo> 313 </target> 314 315 <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."> 316 <fail message="Test Failed" if="test.failed" /> 317 </target> 318 319 <target name="detect.testenv"> 320 <exec outputproperty="test.os.name" executable="lsb_release" failifexecutionfails="false" os="Linux"> 321 <arg line="-is" /> 322 </exec> 323 <exec outputproperty="test.os.version" executable="lsb_release" failifexecutionfails="false" os="Linux"> 324 <arg line="-rs" /> 325 </exec> 326 <property name="test.os.name" value="${os.name}" /> 327 <property name="test.os.version" value="${os.version}" /> 328 <property name="test.os.arch" value="${os.arch}" /> 329 <echo>${test.os.name}-${test.os.version}-${test.os.arch}</echo> 330 <property file="${openoffice.home}/program/versionrc" prefix="openoffice"/> 331 <property file="${openoffice.home}/program/version.ini" prefix="openoffice"/> 332 <property name="openoffice.build.name" value=""/> 333 </target> 334 335 336 <target name="report.test" unless="report.test.skip" description="Upload the testing result to report repository." depends="detect.testenv"> 337 <property name="report.to" value="${openoffice.build.name}-${test.name}/${test.os.name}-${test.os.version}-${test.os.arch}" /> 338 <echo>Uploading report to ${report.repos}/${report.to}</echo> 339 <property name="report.to.temp" location="${testspace}/.temp.ouput"/> 340 <delete dir="${report.to.temp}" deleteonexit="true"/> 341 <copy todir="${report.to.temp}/${report.to}"> 342 <fileset dir="${test.output}" /> 343 </copy> 344 <scp todir="${report.repos}" trust="true"> 345 <fileset dir="${report.to.temp}"/> 346 </scp> 347 <delete dir="${report.to.temp}" deleteonexit="true"/> 348 </target> 349 350 <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."> 351 <property name="test.mark.file" location="${testspace}/${test.name}.build"/> 352 <loadfile property="local.build" srcFile="${test.mark.file}" quiet="true" failonerror="false" /> 353 <fail message="The build has been tested! We don't want to test it twice."> 354 <condition> 355 <equals arg1="${openoffice.build}" arg2="${local.build}" trim="true" /> 356 </condition> 357 </fail> 358 <mkdir dir="${testspace}" /> 359 <echo file="${test.mark.file}">${openoffice.build}</echo> 360 </target> 361 362 <target name="routine.test" depends="detect.build,download.build,install.build,run.test,report.test" description="Periodically run testing."> 363 <fail message="Test Failed" if="test.failed" /> 364 </target> 365</project> 366