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