make/build.xml

Tue, 12 Jul 2016 14:52:17 -0700

author
asaha
date
Tue, 12 Jul 2016 14:52:17 -0700
changeset 1985
a9a890c3b576
parent 1742
fe6ef89d9c04
child 1823
e6bd60e65f33
permissions
-rw-r--r--

Added tag jdk8u121-b00 for changeset 1a484cc1d2ed

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

mercurial