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