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