1 <?xml version="1.0" encoding="UTF-8"?>
   2 
   3 <!--
   4  Copyright (c) 2010, 2013, 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.
  10 
  11  This code is distributed in the hope that it will be useful, but WITHOUT
  12  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  version 2 for more details (a copy is included in the LICENSE file that
  15  accompanied this code).
  16 
  17  You should have received a copy of the GNU General Public License version
  18  2 along with this work; if not, write to the Free Software Foundation,
  19  Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20 
  21  Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  or visit www.oracle.com if you need additional information or have any
  23  questions.
  24 -->
  25 
  26 <project name="nashorn" default="test" basedir="..">
  27   <import file="build-nasgen.xml"/>
  28   <import file="code_coverage.xml"/>
  29 
  30   <target name="init-conditions">
  31     <!-- loading locally defined resources and properties. NB they owerwrite default ones defined later -->
  32     <property file="${user.home}/.nashorn.project.local.properties"/>
  33 
  34     <loadproperties srcFile="make/project.properties"/>
  35     <path id="dist.path">
  36          <pathelement location="${dist.dir}"/>
  37     </path>
  38     <path id="nashorn.ext.path">
  39       <pathelement location="${dist.dir}"/>
  40       <pathelement location="${java.ext.dirs}"/>
  41     </path>
  42     <property name="ext.class.path" value="-Djava.ext.dirs=&quot;${toString:nashorn.ext.path}&quot;"/>
  43     <condition property="svn.executable" value="/usr/local/bin/svn" else="svn">
  44       <available file="/usr/local/bin/svn"/>
  45     </condition>
  46     <condition property="hg.executable" value="/usr/local/bin/hg" else="hg">
  47       <available file="/usr/local/bin/hg"/>
  48     </condition>
  49     <condition property="git.executable" value="/usr/local/bin/git" else="git">
  50       <available file="/usr/local/bin/git"/>
  51     </condition>
  52     <!-- check if testng.jar is avaiable -->
  53     <available property="testng.available" file="${file.reference.testng.jar}"/>
  54     <!-- check if Jemmy ang testng.jar are avaiable -->
  55     <condition property="jemmy.jfx.testng.available" value="true">
  56       <and>
  57         <available file="${file.reference.jemmyfx.jar}"/>
  58         <available file="${file.reference.jemmycore.jar}"/>
  59         <available file="${file.reference.jemmyawtinput.jar}"/>
  60         <available file="${file.reference.jfxrt.jar}"/>
  61         <isset property="testng.available"/>
  62       </and>
  63     </condition>
  64 
  65     <!-- enable/disable make code coverage -->
  66     <condition property="cc.enabled">
  67         <istrue value="${make.code.coverage}" />
  68     </condition>
  69 
  70     <!-- exclude tests in exclude lists -->
  71     <condition property="exclude.list" value="./exclude/exclude_list_cc.txt" else="./exclude/exclude_list.txt">
  72       <istrue value="${make.code.coverage}" />
  73     </condition>
  74 
  75     <condition property="jfr.options" value="${run.test.jvmargs.jfr}" else="">
  76       <istrue value="${jfr}"/>
  77     </condition>
  78   </target>
  79 
  80   <!-- check minimum ant version required to be 1.8.4 -->
  81   <target name="check-ant-version">
  82     <property name="ant.version.required" value="1.8.4"/>
  83     <antversion property="ant.current.version" />
  84     <fail message="The current ant version, ${ant.current.version}, is too old. Please use 1.8.4 or above.">
  85         <condition>
  86             <not>
  87                 <antversion atleast="${ant.version.required}"/>
  88             </not>
  89         </condition>
  90     </fail>
  91   </target>
  92 
  93   <target name="check-java-version">
  94     <!-- look for a Class that is available only in jdk1.8 or above -->
  95     <!-- core/exposed API class is better than an implementation class -->
  96     <available property="jdk1.8+" classname="java.util.stream.Stream"/>
  97 
  98     <!-- need jdk1.8 or above -->
  99     <fail message="Unsupported Java version: ${ant.java.version}. Please use Java version 1.8 or greater." unless="jdk1.8+">
 100     </fail>
 101   </target>
 102   
 103   <target name="init" depends="check-ant-version, check-java-version, init-conditions, init-cc">
 104     <!-- extends jvm args -->
 105     <property name="run.test.jvmargs" value="${run.test.jvmargs.main} ${run.test.cc.jvmargs} ${jfr.options}"/>
 106     <property name="run.test.jvmargs.octane" value="${run.test.jvmargs.octane.main} ${run.test.cc.jvmargs} ${jfr.options}"/>
 107 
 108     <echo message="run.test.jvmargs=${run.test.jvmargs}"/>
 109     <echo message="run.test.jvmargs.octane=${run.test.jvmargs.octane}"/>
 110     <echo message="run.test.xms=${run.test.xms}"/>
 111     <echo message="run.test.xmx=${run.test.xmx}"/>
 112 
 113   </target>
 114 
 115   <target name="prepare" depends="init">
 116     <mkdir dir="${build.dir}"/>
 117     <mkdir dir="${build.classes.dir}"/>
 118     <mkdir dir="${build.classes.dir}/META-INF/services"/>
 119     <mkdir dir="${build.test.classes.dir}"/>
 120     <mkdir dir="${dist.dir}"/>
 121     <mkdir dir="${dist.javadoc.dir}"/>
 122   </target>
 123 
 124   <target name="clean" depends="init, clean-nasgen, init-cc-cleanup">
 125     <delete includeemptydirs="true">
 126       <fileset dir="${build.dir}" erroronmissingdir="false"/>
 127     </delete>
 128     <delete dir="${dist.dir}"/>
 129   </target>
 130 
 131   <target name="compile" depends="prepare" description="Compiles nashorn">
 132     <javac srcdir="${src.dir}"
 133            destdir="${build.classes.dir}"
 134            classpath="${javac.classpath}"
 135            source="${javac.source}"
 136            target="${javac.target}"
 137            debug="${javac.debug}"
 138            encoding="${javac.encoding}"
 139            includeantruntime="false" fork="true">
 140       <compilerarg value="-J-Djava.ext.dirs="/>
 141       <compilerarg value="-Xlint:all"/>
 142       <compilerarg value="-XDignore.symbol.file"/>
 143       <compilerarg value="-Xdiags:verbose"/>
 144     </javac>
 145     <copy todir="${build.classes.dir}/META-INF/services">
 146        <fileset dir="${meta.inf.dir}/services/"/>
 147     </copy>
 148      <copy todir="${build.classes.dir}/jdk/nashorn/api/scripting/resources">
 149        <fileset dir="${src.dir}/jdk/nashorn/api/scripting/resources/"/>
 150     </copy>
 151     <copy todir="${build.classes.dir}/jdk/nashorn/internal/runtime/resources">
 152        <fileset dir="${src.dir}/jdk/nashorn/internal/runtime/resources/"/>
 153     </copy>
 154     <copy todir="${build.classes.dir}/jdk/nashorn/tools/resources">
 155        <fileset dir="${src.dir}/jdk/nashorn/tools/resources/"/>
 156     </copy>
 157     <copy file="${src.dir}/jdk/internal/dynalink/support/messages.properties" todir="${build.classes.dir}/jdk/internal/dynalink/support"/>
 158     <copy file="${src.dir}/jdk/nashorn/internal/codegen/anchor.properties" todir="${build.classes.dir}/jdk/nashorn/internal/codegen"/>
 159 
 160     <echo message="full=${nashorn.fullversion}" file="${build.classes.dir}/jdk/nashorn/internal/runtime/resources/version.properties"/>
 161     <echo file="${build.classes.dir}/jdk/nashorn/internal/runtime/resources/version.properties" append="true">${line.separator}</echo>
 162     <echo message="release=${nashorn.version}" file="${build.classes.dir}/jdk/nashorn/internal/runtime/resources/version.properties" append="true"/>
 163   </target>
 164 
 165   <target name="jar" depends="compile, run-nasgen, generate-cc-template" description="Creates nashorn.jar" unless="compile.suppress.jar">
 166     <jar jarfile="${dist.jar}" manifest="${meta.inf.dir}/MANIFEST.MF" index="true" filesetmanifest="merge">
 167       <fileset dir="${build.classes.dir}"/>
 168       <manifest>
 169         <attribute name="Archiver-Version" value="n/a"/>
 170         <attribute name="Build-Jdk" value="${java.runtime.version}"/>
 171         <attribute name="Built-By" value="n/a"/>
 172         <attribute name="Created-By" value="Ant jar task"/>
 173         <section name="jdk/nashorn/">
 174           <attribute name="Implementation-Title" value="${nashorn.product.name}"/>
 175           <attribute name="Implementation-Version" value="${nashorn.version}"/>
 176         </section>
 177       </manifest>
 178     </jar>
 179   </target>
 180 
 181   <target name="use-promoted-nashorn" depends="init">
 182     <delete file="${dist.dir}/nashorn.jar"/>
 183     <copy file="${java.home}/lib/ext/nashorn.jar" todir="${dist.dir}"/>
 184     <property name="compile.suppress.jar" value="defined"/>
 185   </target>
 186 
 187   <target name="build-fxshell" depends="jar">
 188     <description>Builds the javafx shell.</description>
 189     <mkdir dir="${fxshell.classes.dir}"/>
 190     <javac srcdir="${fxshell.dir}"
 191            destdir="${fxshell.classes.dir}"
 192            classpath="${dist.jar}${path.separator}${javac.classpath}"
 193            debug="${javac.debug}"
 194            encoding="${javac.encoding}"
 195            includeantruntime="false">
 196     </javac>
 197     <jar jarfile="${fxshell.jar}" manifest="${meta.inf.dir}/MANIFEST.MF" index="true" filesetmanifest="merge">
 198       <fileset dir="${fxshell.classes.dir}"/>
 199       <manifest>
 200         <attribute name="Archiver-Version" value="n/a"/>
 201         <attribute name="Build-Jdk" value="${java.runtime.version}"/>
 202         <attribute name="Built-By" value="n/a"/>
 203         <attribute name="Created-By" value="Ant jar task"/>
 204         <section name="jdk/nashorn/">
 205           <attribute name="Implementation-Title" value="Oracle Nashorn FXShell"/>
 206           <attribute name="Implementation-Version" value="${nashorn.version}"/>
 207         </section>
 208       </manifest>
 209     </jar>
 210   </target>
 211 
 212   <target name="javadoc" depends="jar">
 213     <javadoc destdir="${dist.javadoc.dir}" use="yes" overview="src/overview.html" 
 214         extdirs="${nashorn.ext.path}" windowtitle="${nashorn.product.name} ${nashorn.version}"
 215         additionalparam="-quiet" failonerror="true">
 216       <classpath>
 217         <pathelement location="${build.classes.dir}"/>
 218       </classpath>
 219       <fileset dir="${src.dir}" includes="**/*.java"/>
 220       <fileset dir="${jdk.asm.src.dir}" includes="**/*.java"/>
 221       <link href="http://docs.oracle.com/javase/8/docs/api/"/>
 222       <!-- The following tags are used only in ASM sources - just ignore these -->
 223       <tag name="label" description="label tag in ASM sources" enabled="false"/>
 224       <tag name="linked" description="linked tag in ASM sources" enabled="false"/>
 225       <tag name="associates" description="associates tag in ASM sources" enabled="false"/>
 226     </javadoc>
 227   </target>
 228 
 229   <!-- generate javadoc only for nashorn extension api classes -->
 230   <target name="javadocapi" depends="jar">
 231     <javadoc destdir="${dist.javadoc.dir}" use="yes" extdirs="${nashorn.ext.path}" 
 232         windowtitle="${nashorn.product.name}" additionalparam="-quiet" failonerror="true">
 233       <classpath>
 234         <pathelement location="${build.classes.dir}"/>
 235       </classpath>
 236       <fileset dir="${src.dir}" includes="jdk/nashorn/api/**/*.java"/>
 237       <link href="http://docs.oracle.com/javase/8/docs/api/"/>
 238     </javadoc>
 239   </target>
 240 
 241 
 242   <!-- generate shell.html for shell tool documentation -->
 243   <target name="shelldoc" depends="jar">
 244     <java classname="${nashorn.shell.tool}" dir="${basedir}" output="${dist.dir}/shell.html" failonerror="true" fork="true">
 245       <jvmarg line="${ext.class.path}"/>
 246       <arg value="-scripting"/>
 247       <arg value="docs/genshelldoc.js"/>
 248     </java>
 249   </target>
 250 
 251   <!-- generate all docs -->
 252   <target name="docs" depends="javadoc, shelldoc"/>
 253 
 254   <!-- create .zip and .tar.gz for nashorn binaries and scripts. -->
 255   <target name="dist" depends="jar">
 256       <zip destfile="${build.zip}" basedir=".."
 257           excludes="nashorn/bin/*.sh" includes="nashorn/bin/** nashorn/dist/**"/>
 258       <tar destfile="${build.gzip}" basedir=".." compression="gzip"
 259           excludes="nashorn/bin/*.sh" includes="nashorn/bin/** nashorn/dist/**"/>
 260   </target>
 261 
 262   <target name="compile-test" depends="compile, run-nasgen" if="testng.available">
 263     <!-- testng task -->
 264     <taskdef name="testng" classname="org.testng.TestNGAntTask"
 265         classpath="${file.reference.testng.jar}"/>
 266 
 267     <javac srcdir="${test.src.dir}"
 268            destdir="${build.test.classes.dir}"
 269            classpath="${javac.test.classpath}"
 270            source="${javac.source}"
 271            target="${javac.target}"
 272            debug="${javac.debug}"
 273            encoding="${javac.encoding}"
 274            includeantruntime="false" fork="true">
 275         <compilerarg value="-J-Djava.ext.dirs="/>
 276         <compilerarg value="-Xlint:unchecked"/>
 277         <compilerarg value="-Xlint:deprecation"/>
 278         <compilerarg value="-Xdiags:verbose"/>
 279     </javac>
 280 
 281     <copy todir="${build.test.classes.dir}/META-INF/services">
 282        <fileset dir="${test.src.dir}/META-INF/services/"/>
 283     </copy>
 284 
 285     <copy todir="${build.test.classes.dir}/jdk/nashorn/internal/runtime/test/resources">
 286        <fileset dir="${test.src.dir}/jdk/nashorn/internal/runtime/test/resources"/>
 287     </copy>
 288 
 289     <copy todir="${build.test.classes.dir}/jdk/nashorn/api/scripting/test/resources">
 290        <fileset dir="${test.src.dir}/jdk/nashorn/api/scripting/test/resources"/>
 291     </copy>
 292 
 293     <!-- tests that check nashorn internals and internal API -->
 294     <jar jarfile="${nashorn.internal.tests.jar}">
 295       <fileset dir="${build.test.classes.dir}" excludes="**/api/**"/>
 296     </jar>
 297 
 298     <!-- tests that check nashorn script engine (jsr-223) API -->
 299     <jar jarfile="${nashorn.api.tests.jar}">
 300       <fileset dir="${build.test.classes.dir}" includes="**/api/**"/>
 301       <fileset dir="${build.test.classes.dir}" includes="**/META-INF/**"/>
 302       <fileset dir="${build.test.classes.dir}" includes="**/resources/*.js"/>
 303     </jar>
 304 
 305   </target>
 306 
 307   <target name="generate-policy-file" depends="prepare">
 308     <echo file="${build.dir}/nashorn.policy">
 309 
 310 grant codeBase "file:/${toString:dist.path}/nashorn.jar" {
 311     permission java.security.AllPermission;
 312 };
 313 
 314 grant codeBase "file:/${basedir}/${nashorn.internal.tests.jar}" {
 315     permission java.security.AllPermission;
 316 };
 317 
 318 grant codeBase "file:/${basedir}/${file.reference.testng.jar}" {
 319     permission java.security.AllPermission;
 320 };
 321 //// in case of absolute path:
 322 grant codeBase "file:/${nashorn.internal.tests.jar}" {
 323     permission java.security.AllPermission;
 324 };
 325 
 326 grant codeBase "file:/${file.reference.testng.jar}" {
 327     permission java.security.AllPermission;
 328 };
 329 
 330 grant codeBase "file:/${basedir}/test/script/trusted/*" {
 331     permission java.security.AllPermission;
 332 };
 333 
 334 grant codeBase "file:/${basedir}/test/script/maptests/*" {
 335     permission java.io.FilePermission "${basedir}/test/script/maptests/*","read";
 336     permission java.lang.RuntimePermission "nashorn.debugMode";
 337 };
 338 
 339 grant codeBase "file:/${basedir}/test/script/basic/*" {
 340     permission java.io.FilePermission "${basedir}/test/script/-", "read";
 341     permission java.io.FilePermission "$${user.dir}", "read";
 342     permission java.util.PropertyPermission "user.dir", "read";
 343     permission java.util.PropertyPermission "nashorn.test.*", "read";
 344 };
 345 
 346 grant codeBase "file:/${basedir}/test/script/basic/parser/*" {
 347     permission java.io.FilePermission "${basedir}/test/script/-", "read";
 348     permission java.io.FilePermission "$${user.dir}", "read";
 349     permission java.util.PropertyPermission "user.dir", "read";
 350     permission java.util.PropertyPermission "nashorn.test.*", "read";
 351 };
 352 
 353 grant codeBase "file:/${basedir}/test/script/basic/es6/*" {
 354     permission java.io.FilePermission "${basedir}/test/script/-", "read";
 355     permission java.io.FilePermission "$${user.dir}", "read";
 356     permission java.util.PropertyPermission "user.dir", "read";
 357     permission java.util.PropertyPermission "nashorn.test.*", "read";
 358 };
 359 
 360 grant codeBase "file:/${basedir}/test/script/basic/JDK-8010946-privileged.js" {
 361     permission java.util.PropertyPermission "java.security.policy", "read";
 362 };
 363 
 364 grant codeBase "file:/${basedir}/test/script/basic/classloader.js" {
 365     permission java.lang.RuntimePermission "nashorn.JavaReflection";
 366 };
 367 
 368 grant codeBase "file:/${basedir}/test/script/markdown.js" {
 369     permission java.io.FilePermission "${basedir}/test/script/external/showdown/-", "read";
 370 };
 371 
 372     </echo>
 373 
 374     <replace file="${build.dir}/nashorn.policy"><replacetoken>\</replacetoken><replacevalue>/</replacevalue></replace>    <!--hack for Windows - to make URLs with normal path separators -->
 375     <replace file="${build.dir}/nashorn.policy"><replacetoken>//</replacetoken><replacevalue>/</replacevalue></replace>   <!--hack for Unix - to avoid leading // in URLs -->
 376 
 377   </target>
 378 
 379   <target name="check-external-tests">
 380       <available file="${test.external.dir}/prototype" property="test-sys-prop.external.prototype"/>
 381       <available file="${test.external.dir}/sunspider" property="test-sys-prop.external.sunspider"/>
 382       <available file="${test.external.dir}/underscore" property="test-sys-prop.external.underscore"/>
 383       <available file="${test.external.dir}/octane" property="test-sys-prop.external.octane"/>
 384       <available file="${test.external.dir}/yui" property="test-sys-prop.external.yui"/>
 385       <available file="${test.external.dir}/jquery" property="test-sys-prop.external.jquery"/>
 386       <available file="${test.external.dir}/test262" property="test-sys-prop.external.test262"/>
 387       <available file="${test.external.dir}/showdown" property="test-sys-prop.external.markdown"/>
 388   </target>
 389 
 390   <target name="check-testng" unless="testng.available">
 391     <echo message="WARNING: TestNG not available, will not run tests. Please copy testng.jar under test/lib directory."/>
 392   </target>
 393 
 394   <!-- only to be invoked as dependency of "test" target -->
 395   <target name="-test-classes-all" depends="jar" unless="test.class">
 396       <fileset id="test.classes" dir="${build.test.classes.dir}">
 397           <include name="**/api/javaaccess/test/*Test.class"/>
 398           <include name="**/api/scripting/test/*Test.class"/>
 399           <include name="**/codegen/test/*Test.class"/>
 400           <include name="**/parser/test/*Test.class"/>
 401           <include name="**/runtime/test/*Test.class"/>
 402           <include name="**/runtime/regexp/test/*Test.class"/>
 403           <include name="**/runtime/regexp/joni/test/*Test.class"/>
 404           <include name="**/framework/*Test.class"/>
 405      </fileset>
 406   </target>
 407 
 408   <!-- only to be invoked as dependency of "test" target -->
 409   <target name="-test-classes-single" depends="jar" if="test.class">
 410      <fileset id="test.classes" dir="${build.test.classes.dir}">
 411          <include name="${test.class}*"/>
 412      </fileset>
 413   </target>
 414 
 415   <!-- only to be invoked as dependency of "test" target -->
 416   <target name="-test-nosecurity" unless="test.class">
 417     <fileset id="test.nosecurity.classes" dir="${build.test.classes.dir}">
 418       <include name="**/framework/ScriptTest.class"/>
 419     </fileset>
 420     <testng outputdir="${build.nosecurity.test.results.dir}/${testResultsSubDir}" classfilesetref="test.nosecurity.classes"
 421        verbose="${testng.verbose}" haltonfailure="true" useDefaultListeners="false" listeners="${testng.listeners}" workingDir="${basedir}">
 422       <jvmarg line="${ext.class.path}"/>
 423       <jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx} -Dbuild.dir=${build.dir}"/>
 424       <sysproperty key="nashorn.jar" value="${dist.dir}/nashorn.jar"/>
 425       <propertyset>
 426         <propertyref prefix="nashorn."/>
 427       </propertyset>
 428       <propertyset>
 429         <propertyref prefix="test-sys-prop-no-security."/>
 430         <mapper from="test-sys-prop-no-security.*" to="*" type="glob"/>
 431       </propertyset>
 432       <sysproperty key="optimistic.override" value="${optimistic}"/>
 433       <classpath>
 434           <pathelement path="${run.test.classpath}"/>
 435       </classpath>
 436     </testng>
 437   </target>
 438 
 439   <!-- only to be invoked as dependency of "test" target -->
 440   <target name="-test-security">
 441     <delete dir="${build.dir}/nashorn_code_cache"/>
 442     <property name="debug.test.jvmargs" value=""/>
 443     <testng outputdir="${build.test.results.dir}/${testResultsSubDir}" classfilesetref="test.classes"
 444             verbose="${testng.verbose}" haltonfailure="true" useDefaultListeners="false" listeners="${testng.listeners}" workingDir="${basedir}">
 445       <jvmarg line="${ext.class.path}"/>
 446       <jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx} ${run.test.jvmsecurityargs} -Dbuild.dir=${build.dir}"/>
 447       <jvmarg line="${debug.test.jvmargs}"/>
 448       <propertyset>
 449         <propertyref prefix="nashorn."/>
 450       </propertyset>
 451       <propertyset>
 452         <propertyref prefix="test-sys-prop."/>
 453         <mapper from="test-sys-prop.*" to="*" type="glob"/>
 454       </propertyset>
 455       <sysproperty key="optimistic.override" value="${optimistic}"/>
 456       <sysproperty key="test.js.excludes.file" value="${exclude.list}"/>
 457       <classpath>
 458           <pathelement path="${run.test.classpath}"/>
 459       </classpath>
 460     </testng>
 461   </target>
 462 
 463   <target name="test" depends="test-pessimistic, test-optimistic"/>
 464 
 465   <target name="test-optimistic" depends="jar, -test-classes-all,-test-classes-single, check-testng, check-external-tests, compile-test, generate-policy-file" if="testng.available">
 466     <echo message="Running test suite in OPTIMISTIC mode..."/>
 467     <antcall target="-test-nosecurity" inheritRefs="true">
 468       <param name="optimistic" value="true"/>
 469       <param name="testResultsSubDir" value="optimistic"/>
 470     </antcall>    
 471     <antcall target="-test-security" inheritRefs="true">
 472       <param name="optimistic" value="true"/>
 473       <param name="testResultsSubDir" value="optimistic"/>
 474     </antcall>
 475   </target>
 476 
 477   <target name="test-pessimistic" depends="jar, -test-classes-all,-test-classes-single, check-testng, check-external-tests, compile-test, generate-policy-file" if="testng.available">
 478     <echo message="Running test suite in PESSIMISTIC mode..."/>
 479     <antcall target="-test-nosecurity" inheritRefs="true">
 480       <param name="optimistic" value="false"/>
 481       <param name="testResultsSubDir" value="pessimistic"/>
 482     </antcall>    
 483     <antcall target="-test-security" inheritRefs="true">
 484       <param name="optimistic" value="false"/>
 485       <param name="testResultsSubDir" value="pessimistic"/>
 486     </antcall>
 487   </target>
 488 
 489   <target name="check-jemmy.jfx.testng" unless="jemmy.jfx.testng.available">
 490     <echo message="WARNING: Jemmy or JavaFX or TestNG not available, will not run tests. Please copy testng.jar, JemmyCore.jar, JemmyFX.jar, JemmyAWTInput.jar under test${file.separator}lib directory. And make sure you have jfxrt.jar in ${java.home}${file.separator}lib${file.separator}ext dir."/>
 491   </target>
 492 
 493   <target name="testjfx" depends="jar, check-jemmy.jfx.testng, compile-test" if="jemmy.jfx.testng.available">
 494     <fileset id="test.classes" dir="${build.test.classes.dir}">
 495        <include name="**/framework/*Test.class"/>
 496     </fileset>
 497 
 498     <copy file="${file.reference.jfxrt.jar}" todir="dist"/>
 499 
 500     <condition property="jfx.prism.order" value="-Dprism.order=j2d" else=" ">
 501         <not>
 502             <os family="mac"/>
 503         </not>
 504     </condition>
 505 
 506     <testng outputdir="${build.test.results.dir}" classfilesetref="test.classes"
 507        verbose="${testng.verbose}" haltonfailure="true" useDefaultListeners="false" listeners="${testng.listeners}" workingDir="${basedir}">
 508       <jvmarg line="${ext.class.path}"/>
 509       <jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx} -Dbuild.dir=${build.dir}"/>
 510       <propertyset>
 511         <propertyref prefix="testjfx-test-sys-prop."/>
 512         <mapper from="testjfx-test-sys-prop.*" to="*" type="glob"/>
 513       </propertyset>
 514       <sysproperty key="test.fork.jvm.options" value="${testjfx-test-sys-prop.test.fork.jvm.options} ${jfx.prism.order}"/>
 515       <classpath>
 516           <pathelement path="${testjfx.run.test.classpath}"/>
 517       </classpath>
 518     </testng>
 519   </target>
 520 
 521   <target name="testmarkdown" depends="jar, check-testng, check-external-tests, compile-test, generate-policy-file" if="testng.available">
 522     <fileset id="test.classes" dir="${build.test.classes.dir}">
 523        <include name="**/framework/*Test.class"/>
 524     </fileset>
 525 
 526     <testng outputdir="${build.test.results.dir}" classfilesetref="test.classes"
 527        verbose="${testng.verbose}" haltonfailure="true" useDefaultListeners="false" listeners="${testng.listeners}" workingDir="${basedir}">
 528       <jvmarg line="${ext.class.path}"/>
 529       <jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx} ${run.test.jvmsecurityargs} -Dbuild.dir=${build.dir}"/>
 530       <propertyset>
 531         <propertyref prefix="testmarkdown-test-sys-prop."/>
 532         <mapper from="testmarkdown-test-sys-prop.*" to="*" type="glob"/>
 533       </propertyset>
 534       <classpath>
 535           <pathelement path="${run.test.classpath}"/>
 536       </classpath>
 537     </testng>
 538   </target>
 539 
 540   <target name="test262" depends="jar, check-testng, check-external-tests, compile-test, generate-policy-file" if="testng.available">
 541     <fileset id="test.classes" dir="${build.test.classes.dir}">
 542        <include name="**/framework/*Test.class"/>
 543     </fileset>
 544 
 545     <testng outputdir="${build.test.results.dir}" classfilesetref="test.classes"
 546        verbose="${testng.verbose}" haltonfailure="true" useDefaultListeners="false" listeners="${testng.listeners}" workingDir="${basedir}">
 547       <jvmarg line="${ext.class.path}"/>
 548       <jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx} ${run.test.jvmsecurityargs} -Dbuild.dir=${build.dir}"/>
 549       <propertyset>
 550         <propertyref prefix="nashorn."/>
 551       </propertyset>
 552       <propertyset>
 553         <propertyref prefix="test262-test-sys-prop."/>
 554         <mapper from="test262-test-sys-prop.*" to="*" type="glob"/>
 555       </propertyset>
 556       <classpath>
 557           <pathelement path="${run.test.classpath}"/>
 558       </classpath>
 559     </testng>
 560   </target>
 561 
 562   <target name="test262parallel" depends="test262-parallel"/>
 563 
 564   <target name="test262-parallel" depends="jar, check-testng, check-external-tests, compile-test, generate-policy-file" if="testng.available">
 565     <!-- use just build.test.classes.dir to avoid referring to TestNG -->
 566     <java classname="${parallel.test.runner}" dir="${basedir}" fork="true">
 567       <jvmarg line="${ext.class.path}"/>
 568       <jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx} ${run.test.jvmsecurityargs} -Dbuild.dir=${build.dir}"/>
 569       <!-- avoid too many typeinfo cache files. Each script is run only once anyway -->
 570       <jvmarg line="-Dnashorn.typeInfo.disabled=true"/>
 571       <classpath>
 572           <pathelement path="${run.test.classpath}"/>
 573       </classpath>
 574       <syspropertyset>
 575           <propertyref prefix="test262-test-sys-prop."/>
 576           <mapper type="glob" from="test262-test-sys-prop.*" to="*"/>
 577       </syspropertyset>
 578     </java>
 579   </target>
 580 
 581   <target name="testparallel" depends="test-parallel"/>
 582 
 583   <target name="test-parallel" depends="jar, check-testng, check-external-tests, compile-test, generate-policy-file" if="testng.available">
 584       <!-- use just build.test.classes.dir to avoid referring to TestNG -->
 585       <java classname="${parallel.test.runner}" dir="${basedir}"
 586         failonerror="true"
 587         fork="true">
 588       <jvmarg line="${ext.class.path}"/>
 589       <jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx} ${run.test.jvmsecurityargs}"/>
 590       <classpath>
 591           <pathelement path="${run.test.classpath}"/>
 592       <pathelement path="${build.test.classes.dir}"/>
 593       </classpath>
 594       <syspropertyset>
 595           <propertyref prefix="test-sys-prop."/>
 596           <mapper type="glob" from="test-sys-prop.*" to="*"/>
 597       </syspropertyset>
 598       </java>
 599   </target>
 600 
 601   <target name="all" depends="test, docs"
 602       description="Build, test and generate docs for nashorn"/>
 603 
 604   <target name="run" depends="jar"
 605       description="Run the shell with a sample script">
 606     <java classname="${nashorn.shell.tool}" fork="true" dir="samples">
 607         <jvmarg line="${ext.class.path}"/>
 608         <jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx}"/>
 609         <arg value="-dump-on-error"/>
 610         <arg value="test.js"/>
 611     </java>
 612   </target>
 613 
 614   <target name="debug" depends="jar"
 615       description="Debug the shell with a sample script">
 616     <java classname="${nashorn.shell.tool}" fork="true" dir="samples">
 617         <jvmarg line="${ext.class.path}"/>
 618         <jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx}"/>
 619         <arg value="--print-code"/>
 620         <arg value="--verify-code"/>
 621         <arg value="--print-symbols"/>
 622         <jvmarg value="-Dnashorn.codegen.debug=true"/>
 623         <arg value="test.js"/>
 624     </java>
 625   </target>
 626 
 627   <!-- targets to get external script tests -->
 628 
 629   <!-- test262 test suite -->
 630   <target name="get-test262" depends="init" unless="${test-sys-prop.external.test262}">
 631     <!-- clone test262 git repo -->
 632     <exec executable="${git.executable}">
 633        <arg value="clone"/>
 634        <arg value="--branch"/>
 635        <arg value="es5-tests"/>
 636        <arg value="https://github.com/tc39/test262"/>
 637        <arg value="${test.external.dir}/test262"/>
 638     </exec>
 639   </target>
 640   <target name="update-test262" depends="init" if="${test-sys-prop.external.test262}">
 641     <!-- update test262 git repo -->
 642     <exec executable="${git.executable}" dir="${test.external.dir}/test262">
 643        <arg value="pull"/>
 644     </exec>
 645   </target>
 646 
 647   <!-- octane benchmark -->
 648   <target name="get-octane" depends="init" unless="${test-sys-prop.external.octane}">
 649     <!-- checkout octane benchmarks -->
 650     <exec executable="${svn.executable}">
 651        <arg value="--non-interactive"/>
 652        <arg value="--trust-server-cert"/>
 653        <arg value="checkout"/>
 654        <arg value="http://octane-benchmark.googlecode.com/svn/trunk/"/>
 655        <arg value="${test.external.dir}/octane"/>
 656     </exec>
 657   </target>
 658   <target name="update-octane" depends="init" if="${test-sys-prop.external.octane}">
 659     <!-- update octane benchmarks -->
 660     <exec executable="${svn.executable}" dir="${test.external.dir}/octane">
 661        <arg value="--non-interactive"/>
 662        <arg value="--trust-server-cert"/>
 663        <arg value="update"/>
 664     </exec>
 665   </target>
 666 
 667   <!-- sunspider benchmark -->
 668   <target name="get-sunspider" depends="init" unless="${test-sys-prop.external.sunspider}">
 669     <!-- checkout sunspider -->
 670     <exec executable="${svn.executable}">
 671        <arg value="--non-interactive"/>
 672        <arg value="--trust-server-cert"/>
 673        <arg value="checkout"/>
 674        <arg value="http://svn.webkit.org/repository/webkit/trunk/PerformanceTests/SunSpider"/>
 675        <arg value="${test.external.dir}/sunspider"/>
 676     </exec>
 677   </target>
 678   <target name="update-sunspider" depends="init" if="${test-sys-prop.external.sunspider}">
 679     <!-- update sunspider -->
 680     <exec executable="${svn.executable}" dir="${test.external.dir}/sunspider">
 681        <arg value="--non-interactive"/>
 682        <arg value="--trust-server-cert"/>
 683        <arg value="update"/>
 684     </exec>
 685   </target>
 686 
 687   <!-- get all external test scripts -->
 688   <target name="externals" depends="init, check-external-tests, get-test262, get-octane, get-sunspider">
 689     <!-- make external test dir -->
 690     <mkdir dir="${test.external.dir}"/>
 691 
 692     <!-- jquery -->
 693     <mkdir dir="${test.external.dir}/jquery"/>
 694     <get src="http://code.jquery.com/jquery-1.7.2.js" dest="${test.external.dir}/jquery" skipexisting="true" ignoreerrors="true"/>
 695     <get src="http://code.jquery.com/jquery-1.7.2.min.js" dest="${test.external.dir}/jquery" skipexisting="true" ignoreerrors="true"/>
 696 
 697     <!-- prototype -->
 698     <mkdir dir="${test.external.dir}/prototype"/>
 699     <get src="http://ajax.googleapis.com/ajax/libs/prototype/1.7.0/prototype.js" dest="${test.external.dir}/prototype" usetimestamp="true" skipexisting="true" ignoreerrors="true"/>
 700 
 701     <!-- underscorejs -->
 702     <mkdir dir="${test.external.dir}/underscore"/>
 703     <get src="http://underscorejs.org/underscore.js" dest="${test.external.dir}/underscore" skipexisting="true" ignoreerrors="true"/>
 704     <get src="http://underscorejs.org/underscore-min.js" dest="${test.external.dir}/underscore" skipexisting="true" ignoreerrors="true"/>
 705 
 706     <!-- yui -->
 707     <mkdir dir="${test.external.dir}/yui"/>
 708     <get src="http://yui.yahooapis.com/3.5.1/build/yui/yui.js" dest="${test.external.dir}/yui" skipexisting="true" ignoreerrors="true"/>
 709     <get src="http://yui.yahooapis.com/3.5.1/build/yui/yui-min.js" dest="${test.external.dir}/yui" skipexisting="true" ignoreerrors="true"/>
 710 
 711     <!-- showdown -->
 712     <mkdir dir="${test.external.dir}/showdown"/>
 713     <get src="https://raw.github.com/coreyti/showdown/master/src/showdown.js" dest="${test.external.dir}/showdown" skipexisting="true" ignoreerrors="true"/>
 714     <get src="https://raw.github.com/coreyti/showdown/master/src/extensions/table.js" dest="${test.external.dir}/showdown" skipexisting="true" ignoreerrors="true"/>
 715 
 716   </target>
 717 
 718   <!-- update external test suites that are pulled from source control systems -->
 719   <target name="update-externals" depends="init, check-external-tests, update-test262, update-octane, update-sunspider"/>
 720 
 721   <!-- run all perf tests -->
 722   <target name="perf" depends="externals, update-externals, sunspider, octane"/>
 723 
 724   <!-- run all tests -->
 725   <target name="exit-if-no-testng" depends="init, check-testng" unless="${testng.available}">
 726      <fail message="Exiting.."/>
 727   </target>
 728 
 729   <target name="alltests" depends="exit-if-no-testng, externals, update-externals, test, test262parallel, perf"/>
 730 
 731   <import file="build-benchmark.xml"/>
 732 
 733 </project>