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