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     <condition property="java.executable" value="java.exe" else="java">
  32         <os family="windows" />
  33     </condition>
  34     
  35     <macrodef name="run-javatest">
  36         <attribute name="testmode"/>
  37         <sequential>
  38             <echo message="Executing tools/FxTestRunner/run_javatest_macro.xml" />
  39             <echo message="testmode = @{testmode}" />
  40             <echo message="Javatest Basedir = ${fxtest.basedir}" />
  41             <echo message="external.output = ${external.output}" />
  42             
  43             <fail message="fxtest.basedir not set" unless="fxtest.basedir" />
  44             <property name="workdir" value="${fxtest.basedir}/workdir_@{testmode}"/>
  45             <property name="reportdir" value="${fxtest.basedir}/reportdir_@{testmode}"/>
  46             <!-- default values -->
  47             <property name="javatest.runmode" value="desktop"/>
  48             <property name="javatest.pipelineGroup" value="Hardware(Default)"/>
  49             <!-- find utils -->
  50             <property name="javatest.jar" value="${jclient.root.dir}/../../tools/lib/javatest.jar"/>
  51             <property name="HtmlTestRunner.jar" value="${jclient.root.dir}/../../tools/HtmlTestRunner/dist/HtmlTestRunner.jar"/>
  52 
  53             <!-- JTI MAGIC -->
  54             
  55             <!-- step 0: jti file's names -->
  56             <property name="fxsqe.jti.base" value="${jclient.root.dir}/../../tools/FxTestRunner/javatest_base/@{testmode}.jti.base" />
  57             <property name="fxsqe.jti.suite-specific" value="${basedir}/javatest_files/@{testmode}.jti" />
  58             <property name="jti" value="${fxtest.basedir}/@{testmode}.jti"/>
  59 
  60             <!-- step 1: load properties (non-override rule) in next order: -Dfxsqe.name, fxsqe.jti.suite-specific -->
  61             <property file="${fxsqe.jti.base}" prefix="javatest"/>
  62 
  63             <!-- step 2: load filters (override works) in next order: fxsqe.jit.base, fxsqe.jti.suite-specific -->
  64             <filter filtersfile="${fxsqe.jti.base}" />
  65             <filter filtersfile="${fxsqe.jti.suite-specific}" />
  66 
  67             <!-- step 3: apply run-specific values to filters. Unset values are preloaded in step 1. -->
  68             <filter token="runmode" value="${javatest.runmode}"/>
  69             <filter token="pipelineGroup" value="${javatest.pipelineGroup}"/>
  70             <filter token="browserPath" value="${javatest.browserPath}"/>
  71             <filter token="javawsPath" value="${javatest.javawsPath}"/>
  72             <filter token="vmOptions" value="${javatest.vmOptions}"/>
  73             <filter token="dryrun" value="${javatest.dryrun}"/>
  74             
  75             <condition property="__addExportsEnabled" value="No" else="Yes">
  76                 <isset property="noAddExports" />      
  77             </condition>            
  78             <filter token="addExportsEnabled" value="${__addExportsEnabled}"/>
  79 
  80             <!-- step 4: set the rest of filters-->
  81 
  82             <condition property="javafx.home" value="${javafx.rt}">
  83             <not>
  84                 <isset property="javafx.home"/>
  85             </not>
  86             </condition>
  87             <pathconvert targetos="unix" property="javafx.home.converted">
  88                 <path location="${javafx.home}"/>
  89             </pathconvert>
  90             <pathconvert targetos="unix" property="javafx.home.remote.converted">
  91                 <path location="${javafx.home.remote}"/>
  92             </pathconvert>
  93             <pathconvert targetos="unix" property="javaPath.converted">
  94                 <path location="${javafx.home}/bin/${java.executable}"/>
  95             </pathconvert>
  96             
  97             <condition property="fvalue.javafx.home" value="${javafx.home.remote.converted}" else="${javafx.home.converted}">
  98                 <isset property="javafx.home.remote"/>
  99             </condition>
 100             <condition property="fvalue.remote" value="Yes" else="No">
 101                 <isset property="javafx.home.remote"/>
 102             </condition>
 103             <condition property="fvalue.javaPath" value="javaPath=java" else="javaPath=${javaPath.converted}">
 104                 <isset property="javafx.home.remote"/>
 105             </condition>
 106 
 107             <filter token="javafx.home" value="${fvalue.javafx.home}"/>
 108             <filter token="remote" value="${fvalue.remote}"/>
 109             <filter token="javaPath=" value="${fvalue.javaPath}"/>
 110 
 111             <pathconvert targetos="unix" property="TESTSUITE.converted">
 112                 <path location="${basedir}/${test.sources}"/>
 113             </pathconvert>
 114             <filter token="TESTSUITE" value="${TESTSUITE.converted}"/>
 115             
 116             <pathconvert targetos="unix" property="workdir.converted">
 117                 <path location="${workdir}"/>
 118             </pathconvert>
 119             <filter token="WORKDIR" value="${workdir.converted}"/>
 120             
 121             <pathconvert targetos="unix" property="fxtest.basedir.converted">
 122                 <path location="${fxtest.basedir}"/>
 123             </pathconvert>           
 124             <filter token="external.output" value="${fxtest.basedir.converted}"/>
 125 
 126             <!-- step 5: copy template with applied filters -->
 127             <copy overwrite="true" filtering="true" file="${jclient.root.dir}/../../tools/FxTestRunner/javatest_base/@{testmode}.jti.template" tofile="${jti}"/>
 128 
 129             <!-- step 5: add Vera's tricks -->
 130             <antcall target="trickcase1"/>
 131             <antcall target="trickcase2"/>
 132             <!-- END OF JTI MAGIC -->    
 133                 
 134             <!-- classpath -->
 135             <property name="client.test.root" value="${basedir}/${test.sources}"/>
 136             <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"/>
 137             <echo message="classpath=${javatest.classpath}"/>
 138 
 139             <!-- agent / utility mode stuff -->
 140             <condition property="javatest.opt" value="-batch" else="">
 141                 <equals arg1="${javatest.mode.batch}" arg2="true" />
 142             </condition>
 143             <condition property="javatest.agent.pool" value="-startAgentPool" else="">
 144                 <isset property="javafx.home.remote"/>
 145             </condition>
 146 
 147             <!-- run javatest -->
 148        
 149             <mkdir dir="${workdir}"/>
 150             <!-- update defaults --> 
 151 
 152             <condition property="javatest.debug.jvmargs" value="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5858" else="">
 153                 <isset property="javatest.debug"/>
 154             </condition>
 155 
 156             <property name="javatest.java" value="java"/>   
 157 
 158             <java classpath="${javatest.classpath}"
 159                   classname="com.sun.javatest.tool.Main" fork="true" failonerror="false" jvm="${javatest.java}">
 160                 <jvmarg line="${javatest.debug.jvmargs}"/>
 161                 <jvmarg line="-XX:+IgnoreUnrecognizedVMOptions"/>
 162                 <jvmarg line="--add-exports javafx.graphics/com.sun.javafx.util=ALL-UNNAMED"/>
 163                 <jvmarg line="-Dsun.reflect.debugModuleAccessChecks=true -XX:+TraceAccessControlErrors"/>
 164                 <sysproperty key="client.test.root" value="${client.test.root}"/>
 165                 <sysproperty key="javatest.security.noSecurityManager" value="true"/>
 166                 <sysproperty key="client.exclude.nodesc" value="${exclude.nodesc}"/>
 167                 <sysproperty key="client.exclude.desc" value="${exclude.desc}"/>
 168                 <sysproperty key="javatest.FXProcessCommand.verbose" value="${javatest.FXProcessCommand.verbose}"/>
 169                 <arg line="-config"/>
 170                 <arg line="${jti}"/>
 171                 <arg line="-workdir"/>
 172                 <arg line="${workdir}"/>
 173                 <arg line="-testsuite"/>
 174                 <arg line="${basedir}/${test.sources}"/>
 175                 <arg line="${javatest.opt}"/>
 176                 <arg line="${javatest.agent.pool}"/>
 177             </java>
 178 
 179             <delete includeEmptyDirs="true" failonerror="false">
 180                 <fileset dir="${reportdir}"/>
 181             </delete>
 182             <mkdir dir="${reportdir}"/>
 183             <echo message="Writing TXT report"/>
 184             <java classpath="${javatest.classpath}"
 185                   classname="com.sun.javatest.tool.Main" fork="true" failonerror="false" jvm="${javatest.java}">
 186                 <jvmarg line="-XX:+IgnoreUnrecognizedVMOptions"/>
 187                 <jvmarg line="--add-exports javafx.graphics/com.sun.javafx.util=ALL-UNNAMED"/>
 188                 <jvmarg line="-Dsun.reflect.debugModuleAccessChecks=true -XX:+TraceAccessControlErrors"/>
 189                 <sysproperty key="client.test.root" value="${client.test.root}"/>
 190                 <sysproperty key="javatest.security.noSecurityManager" value="true"/>
 191                 <sysproperty key="client.exclude.nodesc" value="${exclude.nodesc}"/>
 192                 <sysproperty key="client.exclude.desc" value="${exclude.desc}"/>
 193                 <arg line="-config"/>
 194                 <arg line="${jti}"/>
 195                 <arg line="-workdir"/>
 196                 <arg line="${workdir}"/>
 197                 <arg line="-testsuite"/>
 198                 <arg line="${basedir}/${test.sources}"/>
 199                 <arg line="${javatest.opt}"/>
 200                 <arg line="-writeReport -type txt -filter allTests ${reportdir}"/>
 201             </java>
 202             <echo message="Writing HTML report"/>
 203             <java classpath="${javatest.classpath}"
 204                   classname="com.sun.javatest.tool.Main" fork="true" failonerror="false" jvm="${javatest.java}">
 205                 <jvmarg line="-XX:+IgnoreUnrecognizedVMOptions"/>
 206                 <jvmarg line="--add-exports javafx.graphics/com.sun.javafx.util=ALL-UNNAMED"/>
 207                 <jvmarg line="-Dsun.reflect.debugModuleAccessChecks=true -XX:+TraceAccessControlErrors"/>
 208                 <sysproperty key="client.test.root" value="${client.test.root}"/>
 209                 <sysproperty key="javatest.security.noSecurityManager" value="true"/>
 210                 <sysproperty key="client.exclude.nodesc" value="${exclude.nodesc}"/>
 211                 <sysproperty key="client.exclude.desc" value="${exclude.desc}"/>
 212                 <arg line="-config"/>
 213                 <arg line="${jti}"/>
 214                 <arg line="-workdir"/>
 215                 <arg line="${workdir}"/>
 216                 <arg line="-testsuite"/>
 217                 <arg line="${basedir}/${test.sources}"/>
 218                 <arg line="${javatest.opt}"/>
 219                 <arg line="-writeReport -type html -filter allTests ${reportdir}/html"/>
 220             </java>
 221 
 222         </sequential>
 223     </macrodef>
 224 
 225     <target name="trickcase1" if="singletest.path">
 226             <echo message="Run single test with name ${singletest.path}" />
 227                 <replace file="${jti}" token="tests.needTests=No" value="tests.needTests=Yes"/>
 228                 <replace file="${jti}" token="tests.tests=" value="tests.tests=${singletest.path}"/>
 229         </target>
 230     <target name="trickcase2" unless="singletest.path" if="testlist.path">
 231          <echo message="Run tests from file ${testlist.path}" />
 232                 <replace file="${jti}" token="tests.needTests=No" value="tests.needTests=Yes"/>
 233                 <replace file="${jti}" token="tests.treeOrFile=tree" value="tests.treeOrFile=file"/>
 234                 <echo file="${jti}" append="Yes">
tests.testFile=${testlist.path}
</echo>
 235         </target>
 236 
 237 </project>