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