1 <?xml version="1.0" encoding="UTF-8"?>
   2 <!-- 
   3 /*
   4  * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
   5  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   6  *
   7  * This code is free software; you can redistribute it and/or modify it
   8  * under the terms of the GNU General Public License version 2 only, as
   9  * published by the Free Software Foundation. Oracle designates this
  10  * particular file as subject to the "Classpath" exception as provided
  11  * by Oracle in the LICENSE file that accompanied this code.
  12  *
  13  * This code is distributed in the hope that it will be useful, but WITHOUT
  14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  15  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  16  * version 2 for more details (a copy is included in the LICENSE file that
  17  * accompanied this code).
  18  *
  19  * You should have received a copy of the GNU General Public License version
  20  * 2 along with this work; if not, write to the Free Software Foundation,
  21  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  22  *
  23  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  24  * or visit www.oracle.com if you need additional information or have any
  25  */
  26 -->
  27 <project name="javatest_utility_macro" default="default" basedir="." xmlns:fx="javafx:com.sun.javafx.tools.ant">
  28     <dirname property="jclient.root.dir" file="${ant.file.fxprobe}"/>
  29     <import file="nbproject/build-impl.xml"/>
  30 
  31     <macrodef name="run-javatest">
  32         <attribute name="testmode"/>
  33         <sequential>
  34             <echo message="testmode = @{testmode}" />
  35             <echo message="Javatest Basedir = ${fxtest.basedir}" />
  36             <echo message="external.output = ${external.output}" />
  37             
  38             <fail message="fxtest.basedir not set" unless="fxtest.basedir" />
  39             <property name="workdir" value="${fxtest.basedir}/workdir_@{testmode}"/>
  40             <property name="reportdir" value="${fxtest.basedir}/reportdir_@{testmode}"/>
  41             <!-- default values -->
  42             <property name="javatest.runmode" value="desktop"/>
  43             <property name="javatest.pipelineGroup" value="Hardware(Default)"/>
  44             <!-- find utils -->
  45             <property name="javatest.jar" value="${jclient.root.dir}/../../tools/lib/javatest.jar"/>
  46             <property name="HtmlTestRunner.jar" value="${jclient.root.dir}/../../tools/HtmlTestRunner/dist/HtmlTestRunner.jar"/>
  47 
  48             <!-- JTI MAGIC -->
  49             
  50             <!-- step 0: jti file's names -->
  51             <property name="fxsqe.jti.base" value="${jclient.root.dir}/../../tools/FxTestRunner/javatest_base/@{testmode}.jti.base" />
  52             <property name="fxsqe.jti.suite-specific" value="${basedir}/javatest_files/@{testmode}.jti" />
  53             <property name="jti" value="${fxtest.basedir}/@{testmode}.jti"/>
  54 
  55             <!-- step 1: load properties (non-override rule) in next order: -Dfxsqe.name, fxsqe.jti.suite-specific -->
  56             <property file="${fxsqe.jti.base}" prefix="javatest"/>
  57 
  58             <!-- step 2: load filters (override works) in next order: fxsqe.jit.base, fxsqe.jti.suite-specific -->
  59             <filter filtersfile="${fxsqe.jti.base}" />
  60             <filter filtersfile="${fxsqe.jti.suite-specific}" />
  61 
  62             <!-- step 3: apply run-specific values to filters. Unset values are preloaded in step 1. -->
  63             <filter token="runmode" value="${javatest.runmode}"/>
  64             <filter token="pipelineGroup" value="${javatest.pipelineGroup}"/>
  65             <filter token="browserPath" value="${javatest.browserPath}"/>
  66             <filter token="javawsPath" value="${javatest.javawsPath}"/>
  67             <filter token="vmOptions" value="${javatest.vmOptions}"/>
  68             <filter token="dryrun" value="${javatest.dryrun}"/>
  69 
  70             <!-- step 4: set the rest of filters-->
  71 
  72             <condition property="javafx.home" value="${javafx.rt}">
  73             <not>
  74                 <isset property="javafx.home"/>
  75             </not>
  76             </condition>
  77             <pathconvert targetos="unix" property="javafx.home.converted">
  78                 <path location="${javafx.home}"/>
  79             </pathconvert>
  80             <echo message="debug: javafx.home = ${javafx.home}"/>
  81             <echo message="debug: javafx.home.converted = ${javafx.home.converted}"/>
  82 
  83 
  84             <condition property="fvalue.javafx.home" value="${javafx.home.remote}" else="${javafx.home.converted}">
  85                 <isset property="javafx.home.remote"/>
  86             </condition>
  87             <condition property="fvalue.remote" value="Yes" else="No">
  88                 <isset property="javafx.home.remote"/>
  89             </condition>
  90             <condition property="fvalue.javaPath" value="javaPath=java" else="">
  91                 <isset property="javafx.home.remote"/>
  92             </condition>
  93 
  94             <filter token="javafx.home" value="${fvalue.javafx.home}"/>
  95             <filter token="remote" value="${fvalue.remote}"/>
  96             <filter token="javaPath=" value="${fvalue.javaPath}"/>
  97 
  98             <filter token="TESTSUITE" value="${basedir}/${test.sources}"/>
  99             <filter token="WORKDIR" value="${workdir}"/>
 100             <filter token="external.output" value="${fxtest.basedir}"/>
 101 
 102             <!-- step 5: copy template with applied filters -->
 103             <copy overwrite="true" filtering="true" file="${jclient.root.dir}/../../tools/FxTestRunner/javatest_base/@{testmode}.jti.template" tofile="${jti}"/>
 104 
 105             <!-- step 5: add Vera's tricks -->
 106             <antcall target="trickcase1"/>
 107             <antcall target="trickcase2"/>
 108             <!-- END OF JTI MAGIC -->    
 109                 
 110             <!-- classpath -->
 111             <property name="client.test.root" value="${basedir}/${test.sources}"/>
 112             <property name="javatest.classpath" value="${jclient.root.dir}/../../tools/FxTestRunner/dist/FxTestRunner.jar:${javatest.jar}:${HtmlTestRunner.jar}:${build.test.classes.dir}:${javac.test.classpath}:${jclient.root.dir}/../../tools/lib/jetty-all.jar:${jclient.root.dir}/../../tools/SharedTestUtilsOpen/dist/SharedTestUtilsOpen.jar:${jclient.root.dir}/../../tools/lib/servlet-api.jar"/>
 113             <echo message="classpath=${javatest.classpath}"/>
 114 
 115             <!-- agent / utility mode stuff -->
 116             <condition property="javatest.opt" value="-batch" else="">
 117                 <equals arg1="${javatest.mode.batch}" arg2="true" />
 118             </condition>
 119             <condition property="javatest.agent.pool" value="-startAgentPool" else="">
 120                 <isset property="javafx.home.remote"/>
 121             </condition>
 122 
 123             <!-- run javatest -->
 124        
 125             <mkdir dir="${workdir}"/>
 126             <!-- update defaults --> 
 127 
 128             <condition property="javatest.debug.jvmargs" value="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5858" else="">
 129                 <isset property="javatest.debug"/>
 130             </condition>
 131 
 132             <property name="javatest.java" value="java"/>        
 133 
 134             <java classpath="${javatest.classpath}"
 135                   classname="com.sun.javatest.tool.Main" fork="true" failonerror="false" jvm="${javatest.java}">
 136                 <jvmarg line="${javatest.debug.jvmargs}"/>
 137                 <sysproperty key="client.test.root" value="${client.test.root}"/>
 138                 <sysproperty key="javatest.security.noSecurityManager" value="true"/>
 139                 <sysproperty key="client.exclude.nodesc" value="${exclude.nodesc}"/>
 140                 <sysproperty key="client.exclude.desc" value="${exclude.desc}"/>
 141                 <sysproperty key="javatest.FXProcessCommand.verbose" value="${javatest.FXProcessCommand.verbose}"/>
 142                 <arg line="-config"/>
 143                 <arg line="${jti}"/>
 144                 <arg line="-workdir"/>
 145                 <arg line="${workdir}"/>
 146                 <arg line="-testsuite"/>
 147                 <arg line="${basedir}/${test.sources}"/>
 148                 <arg line="${javatest.opt}"/>
 149                 <arg line="${javatest.agent.pool}"/>
 150             </java>
 151 
 152             <delete includeEmptyDirs="true" failonerror="false">
 153                 <fileset dir="${reportdir}"/>
 154             </delete>
 155             <mkdir dir="${reportdir}"/>
 156             <echo message="Writing TXT report"/>
 157             <java classpath="${javatest.classpath}"
 158                   classname="com.sun.javatest.tool.Main" fork="true" failonerror="false" jvm="${javatest.java}">
 159                 <sysproperty key="client.test.root" value="${client.test.root}"/>
 160                 <sysproperty key="javatest.security.noSecurityManager" value="true"/>
 161                 <sysproperty key="client.exclude.nodesc" value="${exclude.nodesc}"/>
 162                 <sysproperty key="client.exclude.desc" value="${exclude.desc}"/>
 163                 <arg line="-config"/>
 164                 <arg line="${jti}"/>
 165                 <arg line="-workdir"/>
 166                 <arg line="${workdir}"/>
 167                 <arg line="-testsuite"/>
 168                 <arg line="${basedir}/${test.sources}"/>
 169                 <arg line="${javatest.opt}"/>
 170                 <arg line="-writeReport -type txt -filter allTests ${reportdir}"/>
 171             </java>
 172             <echo message="Writing HTML report"/>
 173             <java classpath="${javatest.classpath}"
 174                   classname="com.sun.javatest.tool.Main" fork="true" failonerror="false" jvm="${javatest.java}">
 175                 <sysproperty key="client.test.root" value="${client.test.root}"/>
 176                 <sysproperty key="javatest.security.noSecurityManager" value="true"/>
 177                 <sysproperty key="client.exclude.nodesc" value="${exclude.nodesc}"/>
 178                 <sysproperty key="client.exclude.desc" value="${exclude.desc}"/>
 179                 <arg line="-config"/>
 180                 <arg line="${jti}"/>
 181                 <arg line="-workdir"/>
 182                 <arg line="${workdir}"/>
 183                 <arg line="-testsuite"/>
 184                 <arg line="${basedir}/${test.sources}"/>
 185                 <arg line="${javatest.opt}"/>
 186                 <arg line="-writeReport -type html -filter allTests ${reportdir}/html"/>
 187             </java>
 188 
 189         </sequential>
 190     </macrodef>
 191 
 192         <target name="trickcase1" if="singletest.path">
 193                 <echo message="Run single test with name ${singletest.path}" />
 194                 <replace file="${jti}" token="tests.needTests=No" value="tests.needTests=Yes"/>
 195                 <replace file="${jti}" token="tests.tests=" value="tests.tests=${singletest.path}"/>
 196         </target>
 197         <target name="trickcase2" unless="singletest.path" if="testlist.path">
 198                 <echo message="Run tests from file ${testlist.path}" />
 199                 <replace file="${jti}" token="tests.needTests=No" value="tests.needTests=Yes"/>
 200                 <replace file="${jti}" token="tests.treeOrFile=tree" value="tests.treeOrFile=file"/>
 201                 <echo file="${jti}" append="Yes">
tests.testFile=${testlist.path}
</echo>
 202         </target>
 203 
 204 </project>