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