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