Mon, 20 Oct 2014 18:40:42 +0530
8061257: nashorn ant build script should have a sanity target
Reviewed-by: lagergren, hannesw, attila
1 <?xml version="1.0" encoding="UTF-8"?>
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.
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.
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).
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.
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 -->
26 <project name="nashorn" default="test" basedir="..">
27 <import file="build-nasgen.xml"/>
28 <import file="code_coverage.xml"/>
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"/>
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="${toString:nashorn.ext.path}""/>
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>
65 <!-- enable/disable make code coverage -->
66 <condition property="cc.enabled">
67 <istrue value="${make.code.coverage}" />
68 </condition>
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>
75 <condition property="jfr.options" value="${run.test.jvmargs.jfr}" else="">
76 <istrue value="${jfr}"/>
77 </condition>
78 </target>
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>
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"/>
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>
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}"/>
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}"/>
113 </target>
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>
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>
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 </javac>
145 <copy todir="${build.classes.dir}/META-INF/services">
146 <fileset dir="${meta.inf.dir}/services/"/>
147 </copy>
148 <copy todir="${build.classes.dir}/jdk/nashorn/api/scripting/resources">
149 <fileset dir="${src.dir}/jdk/nashorn/api/scripting/resources/"/>
150 </copy>
151 <copy todir="${build.classes.dir}/jdk/nashorn/internal/runtime/resources">
152 <fileset dir="${src.dir}/jdk/nashorn/internal/runtime/resources/"/>
153 </copy>
154 <copy todir="${build.classes.dir}/jdk/nashorn/tools/resources">
155 <fileset dir="${src.dir}/jdk/nashorn/tools/resources/"/>
156 </copy>
157 <copy file="${src.dir}/jdk/internal/dynalink/support/messages.properties" todir="${build.classes.dir}/jdk/internal/dynalink/support"/>
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>
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>
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>
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>
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>
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>
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="${ext.class.path}"/>
245 <arg value="-scripting"/>
246 <arg value="docs/genshelldoc.js"/>
247 </java>
248 </target>
250 <!-- generate all docs -->
251 <target name="docs" depends="javadoc, shelldoc"/>
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>
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}"/>
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="-J-Djava.ext.dirs="/>
275 <compilerarg value="-Xlint:unchecked"/>
276 <compilerarg value="-Xlint:deprecation"/>
277 <compilerarg value="-Xdiags:verbose"/>
278 </javac>
280 <copy todir="${build.test.classes.dir}/META-INF/services">
281 <fileset dir="${test.src.dir}/META-INF/services/"/>
282 </copy>
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>
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>
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>
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>
304 </target>
306 <target name="generate-policy-file" depends="prepare">
307 <echo file="${build.dir}/nashorn.policy">
309 grant codeBase "file:/${toString:dist.path}/nashorn.jar" {
310 permission java.security.AllPermission;
311 };
313 grant codeBase "file:/${basedir}/${nashorn.internal.tests.jar}" {
314 permission java.security.AllPermission;
315 };
317 grant codeBase "file:/${basedir}/${file.reference.testng.jar}" {
318 permission java.security.AllPermission;
319 };
320 //// in case of absolute path:
321 grant codeBase "file:/${nashorn.internal.tests.jar}" {
322 permission java.security.AllPermission;
323 };
325 grant codeBase "file:/${file.reference.testng.jar}" {
326 permission java.security.AllPermission;
327 };
329 grant codeBase "file:/${basedir}/test/script/trusted/*" {
330 permission java.security.AllPermission;
331 };
333 grant codeBase "file:/${basedir}/test/script/maptests/*" {
334 permission java.io.FilePermission "${basedir}/test/script/maptests/*","read";
335 permission java.lang.RuntimePermission "nashorn.debugMode";
336 };
338 grant 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 };
345 grant 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 };
352 grant 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 };
359 grant codeBase "file:/${basedir}/test/script/basic/JDK-8010946-privileged.js" {
360 permission java.util.PropertyPermission "java.security.policy", "read";
361 };
363 grant codeBase "file:/${basedir}/test/script/basic/classloader.js" {
364 permission java.lang.RuntimePermission "nashorn.JavaReflection";
365 };
367 grant codeBase "file:/${basedir}/test/script/markdown.js" {
368 permission java.io.FilePermission "${basedir}/test/script/external/showdown/-", "read";
369 };
371 </echo>
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 -->
376 </target>
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>
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>
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>
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>
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="${ext.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>
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="${ext.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>
462 <target name="test" depends="test-pessimistic, test-optimistic"/>
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>
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>
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>
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>
497 <copy file="${file.reference.jfxrt.jar}" todir="dist"/>
499 <condition property="jfx.prism.order" value="-Dprism.order=j2d" else=" ">
500 <not>
501 <os family="mac"/>
502 </not>
503 </condition>
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>
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>
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>
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>
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>
561 <target name="test262parallel" depends="test262-parallel"/>
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="${ext.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>
580 <target name="testparallel" depends="test-parallel"/>
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="${ext.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>
600 <target name="all" depends="test, docs"
601 description="Build, test and generate docs for nashorn"/>
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="${ext.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>
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="${ext.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>
626 <!-- targets to get external script tests -->
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>
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>
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>
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}"/>
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"/>
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"/>
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"/>
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"/>
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"/>
715 </target>
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"/>
720 <!-- run all perf tests -->
721 <target name="perf" depends="externals, update-externals, sunspider, octane"/>
723 <!-- run all tests -->
724 <target name="exit-if-no-testng" depends="init, check-testng" unless="${testng.available}">
725 <fail message="Exiting.."/>
726 </target>
728 <target name="alltests" depends="exit-if-no-testng, externals, update-externals, test, test262parallel, perf"/>
730 <import file="build-benchmark.xml"/>
732 </project>