Sun, 02 Jul 2017 22:55:59 -0700
Merge
1 <?xml version="1.0" encoding="UTF-8"?>
3 <!--
4 Copyright (c) 2010, 2015, 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 and dependencies are available, and download them if they aren't -->
53 <antcall target="get-testng"/>
54 <condition property="testng.available" value="true">
55 <and>
56 <available file="${file.reference.testng.jar}"/>
57 <available file="${file.reference.jcommander.jar}"/>
58 <available file="${file.reference.bsh.jar}"/>
59 <available file="${file.reference.snakeyaml.jar}"/>
60 </and>
61 </condition>
62 <!-- check if Jemmy ang TestNG are avaiable -->
63 <condition property="jemmy.jfx.testng.available" value="true">
64 <and>
65 <available file="${file.reference.jemmyfx.jar}"/>
66 <available file="${file.reference.jemmycore.jar}"/>
67 <available file="${file.reference.jemmyawtinput.jar}"/>
68 <available file="${file.reference.jfxrt.jar}"/>
69 <isset property="testng.available"/>
70 </and>
71 </condition>
73 <!-- enable/disable make code coverage -->
74 <condition property="cc.enabled">
75 <istrue value="${make.code.coverage}" />
76 </condition>
78 <!-- exclude tests in exclude lists -->
79 <condition property="exclude.list" value="./exclude/exclude_list_cc.txt" else="./exclude/exclude_list.txt">
80 <istrue value="${make.code.coverage}" />
81 </condition>
83 <condition property="jfr.options" value="${run.test.jvmargs.jfr}" else="">
84 <istrue value="${jfr}"/>
85 </condition>
87 <condition property="test-sys-prop-no-security.os.not.windows">
88 <not>
89 <os family="windows"/>
90 </not>
91 </condition>
92 </target>
94 <!-- check minimum ant version required to be 1.8.4 -->
95 <target name="check-ant-version">
96 <property name="ant.version.required" value="1.8.4"/>
97 <antversion property="ant.current.version" />
98 <fail message="The current ant version, ${ant.current.version}, is too old. Please use 1.8.4 or above.">
99 <condition>
100 <not>
101 <antversion atleast="${ant.version.required}"/>
102 </not>
103 </condition>
104 </fail>
105 </target>
107 <target name="check-java-version">
108 <!-- look for a Class that is available only in jdk1.8 or above -->
109 <!-- core/exposed API class is better than an implementation class -->
110 <available property="jdk1.8+" classname="java.util.stream.Stream"/>
112 <!-- need jdk1.8 or above -->
113 <fail message="Unsupported Java version: ${ant.java.version}. Please use Java version 1.8 or greater." unless="jdk1.8+">
114 </fail>
115 </target>
117 <target name="init" depends="check-ant-version, check-java-version, init-conditions, init-cc">
118 <!-- extends jvm args -->
119 <property name="run.test.jvmargs" value="${run.test.jvmargs.main} ${run.test.cc.jvmargs} ${jfr.options}"/>
120 <property name="run.test.jvmargs.octane" value="${run.test.jvmargs.octane.main} ${run.test.cc.jvmargs} ${jfr.options}"/>
122 <echo message="run.test.jvmargs=${run.test.jvmargs}"/>
123 <echo message="run.test.jvmargs.octane=${run.test.jvmargs.octane}"/>
124 <echo message="run.test.xms=${run.test.xms}"/>
125 <echo message="run.test.xmx=${run.test.xmx}"/>
127 </target>
129 <target name="prepare" depends="init">
130 <mkdir dir="${build.dir}"/>
131 <mkdir dir="${build.classes.dir}"/>
132 <mkdir dir="${build.classes.dir}/META-INF/services"/>
133 <mkdir dir="${build.test.classes.dir}"/>
134 <mkdir dir="${dist.dir}"/>
135 <mkdir dir="${dist.javadoc.dir}"/>
136 </target>
138 <target name="clean" depends="init, clean-nasgen, init-cc-cleanup">
139 <delete includeemptydirs="true">
140 <fileset dir="${build.dir}" erroronmissingdir="false"/>
141 </delete>
142 <delete dir="${dist.dir}"/>
143 </target>
145 <target name="compile" depends="prepare" description="Compiles nashorn">
146 <javac srcdir="${src.dir}"
147 destdir="${build.classes.dir}"
148 classpath="${javac.classpath}"
149 source="${javac.source}"
150 target="${javac.target}"
151 debug="${javac.debug}"
152 encoding="${javac.encoding}"
153 includeantruntime="false" fork="true">
154 <compilerarg value="-J-Djava.ext.dirs="/>
155 <compilerarg value="-Xlint:all"/>
156 <compilerarg value="-XDignore.symbol.file"/>
157 <compilerarg value="-Xdiags:verbose"/>
158 </javac>
159 <copy todir="${build.classes.dir}/META-INF/services">
160 <fileset dir="${meta.inf.dir}/services/"/>
161 </copy>
162 <copy todir="${build.classes.dir}/jdk/nashorn/api/scripting/resources">
163 <fileset dir="${src.dir}/jdk/nashorn/api/scripting/resources/"/>
164 </copy>
165 <copy todir="${build.classes.dir}/jdk/nashorn/internal/runtime/resources">
166 <fileset dir="${src.dir}/jdk/nashorn/internal/runtime/resources/"/>
167 </copy>
168 <copy todir="${build.classes.dir}/jdk/nashorn/tools/resources">
169 <fileset dir="${src.dir}/jdk/nashorn/tools/resources/"/>
170 </copy>
171 <copy file="${src.dir}/jdk/internal/dynalink/support/messages.properties" todir="${build.classes.dir}/jdk/internal/dynalink/support"/>
172 <copy file="${src.dir}/jdk/nashorn/internal/codegen/anchor.properties" todir="${build.classes.dir}/jdk/nashorn/internal/codegen"/>
174 <echo message="full=${nashorn.fullversion}" file="${build.classes.dir}/jdk/nashorn/internal/runtime/resources/version.properties"/>
175 <echo file="${build.classes.dir}/jdk/nashorn/internal/runtime/resources/version.properties" append="true">${line.separator}</echo>
176 <echo message="release=${nashorn.version}" file="${build.classes.dir}/jdk/nashorn/internal/runtime/resources/version.properties" append="true"/>
177 </target>
179 <target name="jar" depends="compile, run-nasgen, generate-cc-template" description="Creates nashorn.jar" unless="compile.suppress.jar">
180 <jar jarfile="${dist.jar}" manifest="${meta.inf.dir}/MANIFEST.MF" index="true" filesetmanifest="merge">
181 <fileset dir="${build.classes.dir}"/>
182 <manifest>
183 <attribute name="Archiver-Version" value="n/a"/>
184 <attribute name="Build-Jdk" value="${java.runtime.version}"/>
185 <attribute name="Built-By" value="n/a"/>
186 <attribute name="Created-By" value="Ant jar task"/>
187 <section name="jdk/nashorn/">
188 <attribute name="Implementation-Title" value="${nashorn.product.name}"/>
189 <attribute name="Implementation-Version" value="${nashorn.version}"/>
190 </section>
191 </manifest>
192 </jar>
193 </target>
195 <target name="use-promoted-nashorn" depends="init">
196 <delete file="${dist.dir}/nashorn.jar"/>
197 <copy file="${java.home}/lib/ext/nashorn.jar" todir="${dist.dir}"/>
198 <property name="compile.suppress.jar" value="defined"/>
199 </target>
201 <target name="build-fxshell" depends="jar">
202 <description>Builds the javafx shell.</description>
203 <mkdir dir="${fxshell.classes.dir}"/>
204 <javac srcdir="${fxshell.dir}"
205 destdir="${fxshell.classes.dir}"
206 classpath="${dist.jar}${path.separator}${javac.classpath}"
207 debug="${javac.debug}"
208 encoding="${javac.encoding}"
209 includeantruntime="false">
210 </javac>
211 <jar jarfile="${fxshell.jar}" manifest="${meta.inf.dir}/MANIFEST.MF" index="true" filesetmanifest="merge">
212 <fileset dir="${fxshell.classes.dir}"/>
213 <manifest>
214 <attribute name="Archiver-Version" value="n/a"/>
215 <attribute name="Build-Jdk" value="${java.runtime.version}"/>
216 <attribute name="Built-By" value="n/a"/>
217 <attribute name="Created-By" value="Ant jar task"/>
218 <section name="jdk/nashorn/">
219 <attribute name="Implementation-Title" value="Oracle Nashorn FXShell"/>
220 <attribute name="Implementation-Version" value="${nashorn.version}"/>
221 </section>
222 </manifest>
223 </jar>
224 </target>
226 <!-- generate javadoc for all Nashorn and ASM classes -->
227 <target name="javadoc" depends="jar">
228 <javadoc destdir="${dist.javadoc.dir}" use="yes" overview="${src.dir}/overview.html"
229 extdirs="${nashorn.ext.path}" windowtitle="${nashorn.product.name} ${nashorn.version}"
230 additionalparam="-quiet" failonerror="true" useexternalfile="true">
231 <arg value="${javadoc.option}"/>
232 <classpath>
233 <pathelement location="${build.classes.dir}"/>
234 </classpath>
235 <fileset dir="${src.dir}" includes="**/*.java"/>
236 <fileset dir="${jdk.asm.src.dir}" includes="**/*.java"/>
237 <link href="http://docs.oracle.com/javase/8/docs/api/"/>
238 <!-- The following tags are used only in ASM sources - just ignore these -->
239 <tag name="label" description="label tag in ASM sources" enabled="false"/>
240 <tag name="linked" description="linked tag in ASM sources" enabled="false"/>
241 <tag name="associates" description="associates tag in ASM sources" enabled="false"/>
242 </javadoc>
243 </target>
245 <!-- generate javadoc for Nashorn classes -->
246 <target name="javadocnh" depends="jar">
247 <javadoc destdir="${dist.javadoc.dir}" use="yes" overview="${src.dir}/overview.html"
248 extdirs="${nashorn.ext.path}" windowtitle="${nashorn.product.name} ${nashorn.version}"
249 additionalparam="-quiet" failonerror="true" useexternalfile="true">
250 <arg value="${javadoc.option}"/>
251 <classpath>
252 <pathelement location="${build.classes.dir}"/>
253 </classpath>
254 <fileset dir="${src.dir}" includes="**/*.java"/>
255 <link href="http://docs.oracle.com/javase/8/docs/api/"/>
256 </javadoc>
257 </target>
259 <!-- generate javadoc only for nashorn extension api classes -->
260 <target name="javadocapi" depends="jar">
261 <javadoc destdir="${dist.javadoc.dir}" use="yes" extdirs="${nashorn.ext.path}"
262 windowtitle="${nashorn.product.name}" additionalparam="-quiet" failonerror="true" useexternalfile="true">
263 <arg value="${javadoc.option}"/>
264 <classpath>
265 <pathelement location="${build.classes.dir}"/>
266 </classpath>
267 <fileset dir="${src.dir}" includes="jdk/nashorn/api/**/*.java"/>
268 <link href="http://docs.oracle.com/javase/8/docs/api/"/>
269 </javadoc>
270 </target>
272 <!-- generate shell.html for shell tool documentation -->
273 <target name="shelldoc" depends="jar">
274 <java classname="${nashorn.shell.tool}" dir="${basedir}" output="${dist.dir}/shell.html" failonerror="true" fork="true">
275 <jvmarg line="${ext.class.path}"/>
276 <arg value="-scripting"/>
277 <arg value="docs/genshelldoc.js"/>
278 </java>
279 </target>
281 <!-- generate all docs -->
282 <target name="docs" depends="javadoc, shelldoc"/>
284 <!-- create .zip and .tar.gz for nashorn binaries and scripts. -->
285 <target name="dist" depends="jar">
286 <zip destfile="${build.zip}" basedir=".."
287 excludes="nashorn/bin/*.sh" includes="nashorn/bin/** nashorn/dist/**"/>
288 <tar destfile="${build.gzip}" basedir=".." compression="gzip"
289 excludes="nashorn/bin/*.sh" includes="nashorn/bin/** nashorn/dist/**"/>
290 </target>
292 <target name="compile-test" depends="compile, run-nasgen" if="testng.available">
293 <!-- testng task -->
294 <taskdef name="testng" classname="org.testng.TestNGAntTask"
295 classpath="${testng.ant.classpath}"/>
297 <javac srcdir="${test.src.dir}"
298 destdir="${build.test.classes.dir}"
299 classpath="${javac.test.classpath}"
300 source="${test.javac.source}"
301 target="${test.javac.target}"
302 debug="${javac.debug}"
303 encoding="${javac.encoding}"
304 includeantruntime="false" fork="true">
305 <compilerarg value="-J-Djava.ext.dirs="/>
306 <compilerarg value="-Xlint:unchecked"/>
307 <compilerarg value="-Xlint:deprecation"/>
308 <compilerarg value="-Xdiags:verbose"/>
309 </javac>
311 <copy todir="${build.test.classes.dir}/META-INF/services">
312 <fileset dir="${test.src.dir}/META-INF/services/"/>
313 </copy>
315 <copy todir="${build.test.classes.dir}/jdk/nashorn/internal/runtime/test/resources">
316 <fileset dir="${test.src.dir}/jdk/nashorn/internal/runtime/test/resources"/>
317 </copy>
319 <copy todir="${build.test.classes.dir}/jdk/nashorn/api/scripting/test/resources">
320 <fileset dir="${test.src.dir}/jdk/nashorn/api/scripting/test/resources"/>
321 </copy>
323 <!-- tests that check nashorn internals and internal API -->
324 <jar jarfile="${nashorn.internal.tests.jar}">
325 <fileset dir="${build.test.classes.dir}" excludes="**/api/**"/>
326 </jar>
328 <!-- tests that check nashorn script engine (jsr-223) API -->
329 <jar jarfile="${nashorn.api.tests.jar}">
330 <fileset dir="${build.test.classes.dir}" includes="**/api/**"/>
331 <fileset dir="${build.test.classes.dir}" includes="**/META-INF/**"/>
332 <fileset dir="${build.test.classes.dir}" includes="**/resources/*.js"/>
333 </jar>
335 </target>
337 <target name="generate-policy-file" depends="prepare">
338 <echo file="${build.dir}/nashorn.policy">
340 grant codeBase "file:/${toString:dist.path}/nashorn.jar" {
341 permission java.security.AllPermission;
342 };
344 grant codeBase "file:/${basedir}/${nashorn.internal.tests.jar}" {
345 permission java.security.AllPermission;
346 };
348 grant codeBase "file:/${basedir}/${file.reference.testng.jar}" {
349 permission java.security.AllPermission;
350 };
351 grant codeBase "file:/${basedir}/${file.reference.jcommander.jar}" {
352 permission java.security.AllPermission;
353 };
354 grant codeBase "file:/${basedir}/${file.reference.bsh.jar}" {
355 permission java.security.AllPermission;
356 };
357 grant codeBase "file:/${basedir}/${file.reference.snakeyaml.jar}" {
358 permission java.security.AllPermission;
359 };
360 //// in case of absolute path:
361 grant codeBase "file:/${nashorn.internal.tests.jar}" {
362 permission java.security.AllPermission;
363 };
365 grant codeBase "file:/${file.reference.testng.jar}" {
366 permission java.security.AllPermission;
367 };
368 grant codeBase "file:/${file.reference.jcommander.jar}" {
369 permission java.security.AllPermission;
370 };
371 grant codeBase "file:/${file.reference.bsh.jar}" {
372 permission java.security.AllPermission;
373 };
374 grant codeBase "file:/${file.reference.snakeyaml.jar}" {
375 permission java.security.AllPermission;
376 };
379 grant codeBase "file:/${basedir}/test/script/trusted/*" {
380 permission java.security.AllPermission;
381 };
383 grant codeBase "file:/${basedir}/test/script/maptests/*" {
384 permission java.io.FilePermission "${basedir}/test/script/maptests/*","read";
385 permission java.lang.RuntimePermission "nashorn.debugMode";
386 };
388 grant codeBase "file:/${basedir}/test/script/basic/*" {
389 permission java.io.FilePermission "${basedir}/test/script/-", "read";
390 permission java.io.FilePermission "$${user.dir}", "read";
391 permission java.util.PropertyPermission "user.dir", "read";
392 permission java.util.PropertyPermission "nashorn.test.*", "read";
393 };
395 grant codeBase "file:/${basedir}/test/script/basic/apply_to_call/*" {
396 permission java.io.FilePermission "${basedir}/test/script/-", "read";
397 permission java.io.FilePermission "$${user.dir}", "read";
398 permission java.util.PropertyPermission "user.dir", "read";
399 permission java.util.PropertyPermission "nashorn.test.*", "read";
400 };
402 grant codeBase "file:/${basedir}/test/script/basic/parser/*" {
403 permission java.io.FilePermission "${basedir}/test/script/-", "read";
404 permission java.io.FilePermission "$${user.dir}", "read";
405 permission java.util.PropertyPermission "user.dir", "read";
406 permission java.util.PropertyPermission "nashorn.test.*", "read";
407 };
409 grant codeBase "file:/${basedir}/test/script/basic/es6/*" {
410 permission java.io.FilePermission "${basedir}/test/script/-", "read";
411 permission java.io.FilePermission "$${user.dir}", "read";
412 permission java.util.PropertyPermission "user.dir", "read";
413 permission java.util.PropertyPermission "nashorn.test.*", "read";
414 };
416 grant codeBase "file:/${basedir}/test/script/basic/JDK-8010946-privileged.js" {
417 permission java.util.PropertyPermission "java.security.policy", "read";
418 };
420 grant codeBase "file:/${basedir}/test/script/basic/classloader.js" {
421 permission java.lang.RuntimePermission "nashorn.JavaReflection";
422 };
424 grant codeBase "file:/${basedir}/test/script/markdown.js" {
425 permission java.io.FilePermission "${basedir}/test/script/external/showdown/-", "read";
426 };
428 grant codeBase "file:/${basedir}/test/script/basic/JDK-8158467.js" {
429 permission java.lang.RuntimePermission "nashorn.setConfig";
430 };
432 </echo>
434 <replace file="${build.dir}/nashorn.policy"><replacetoken>\</replacetoken><replacevalue>/</replacevalue></replace> <!--hack for Windows - to make URLs with normal path separators -->
435 <replace file="${build.dir}/nashorn.policy"><replacetoken>//</replacetoken><replacevalue>/</replacevalue></replace> <!--hack for Unix - to avoid leading // in URLs -->
437 </target>
439 <target name="check-external-tests">
440 <available file="${test.external.dir}/prototype" property="test-sys-prop.external.prototype"/>
441 <available file="${test.external.dir}/sunspider" property="test-sys-prop.external.sunspider"/>
442 <available file="${test.external.dir}/underscore" property="test-sys-prop.external.underscore"/>
443 <available file="${test.external.dir}/octane" property="test-sys-prop.external.octane"/>
444 <available file="${test.external.dir}/yui" property="test-sys-prop.external.yui"/>
445 <available file="${test.external.dir}/jquery" property="test-sys-prop.external.jquery"/>
446 <available file="${test.external.dir}/test262" property="test-sys-prop.external.test262"/>
447 <available file="${test.external.dir}/showdown" property="test-sys-prop.external.markdown"/>
448 </target>
450 <target name="check-testng" unless="testng.available">
451 <echo message="WARNING: TestNG not available, will not run tests. Please copy TestNG and dependency JARs to the ${test.lib} directory."/>
452 </target>
454 <!-- only to be invoked as dependency of "test" target -->
455 <target name="-test-classes-all" depends="jar" unless="test.class">
456 <fileset id="test.classes" dir="${build.test.classes.dir}">
457 <include name="**/api/javaaccess/test/*Test.class"/>
458 <include name="**/api/scripting/test/*Test.class"/>
459 <include name="**/codegen/test/*Test.class"/>
460 <include name="**/parser/test/*Test.class"/>
461 <include name="**/runtime/test/*Test.class"/>
462 <include name="**/runtime/regexp/test/*Test.class"/>
463 <include name="**/runtime/regexp/joni/test/*Test.class"/>
464 <include name="**/framework/*Test.class"/>
465 </fileset>
466 </target>
468 <!-- only to be invoked as dependency of "test" target -->
469 <target name="-test-classes-single" depends="jar" if="test.class">
470 <fileset id="test.classes" dir="${build.test.classes.dir}">
471 <include name="${test.class}*"/>
472 </fileset>
473 </target>
475 <!-- only to be invoked as dependency of "test" target -->
476 <target name="-test-nosecurity" unless="test.class">
477 <fileset id="test.nosecurity.classes" dir="${build.test.classes.dir}">
478 <include name="**/framework/ScriptTest.class"/>
479 </fileset>
480 <testng outputdir="${build.nosecurity.test.results.dir}/${testResultsSubDir}" classfilesetref="test.nosecurity.classes"
481 verbose="${testng.verbose}" haltonfailure="true" useDefaultListeners="false" listeners="${testng.listeners}" workingDir="${basedir}">
482 <jvmarg line="${ext.class.path}"/>
483 <jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx} -Dbuild.dir=${build.dir}"/>
484 <sysproperty key="nashorn.jar" value="${dist.dir}/nashorn.jar"/>
485 <propertyset>
486 <propertyref prefix="nashorn."/>
487 </propertyset>
488 <propertyset>
489 <propertyref prefix="test-sys-prop-no-security."/>
490 <mapper from="test-sys-prop-no-security.*" to="*" type="glob"/>
491 </propertyset>
492 <sysproperty key="optimistic.override" value="${optimistic}"/>
493 <classpath>
494 <pathelement path="${run.test.classpath}"/>
495 </classpath>
496 </testng>
497 </target>
499 <!-- only to be invoked as dependency of "test" target -->
500 <target name="-test-security">
501 <delete dir="${build.dir}/nashorn_code_cache"/>
502 <property name="debug.test.jvmargs" value=""/>
503 <testng outputdir="${build.test.results.dir}/${testResultsSubDir}" classfilesetref="test.classes"
504 verbose="${testng.verbose}" haltonfailure="true" useDefaultListeners="false" listeners="${testng.listeners}" workingDir="${basedir}">
505 <jvmarg line="${ext.class.path}"/>
506 <jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx} ${run.test.jvmsecurityargs} -Dbuild.dir=${build.dir}"/>
507 <jvmarg line="${debug.test.jvmargs}"/>
508 <propertyset>
509 <propertyref prefix="nashorn."/>
510 </propertyset>
511 <propertyset>
512 <propertyref prefix="test-sys-prop."/>
513 <mapper from="test-sys-prop.*" to="*" type="glob"/>
514 </propertyset>
515 <sysproperty key="optimistic.override" value="${optimistic}"/>
516 <sysproperty key="test.js.excludes.file" value="${exclude.list}"/>
517 <classpath>
518 <pathelement path="${run.test.classpath}"/>
519 </classpath>
520 </testng>
521 </target>
523 <target name="test" depends="prepare, javadocnh, test-pessimistic, test-optimistic"/>
525 <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">
526 <echo message="Running test suite in OPTIMISTIC mode..."/>
527 <antcall target="-test-nosecurity" inheritRefs="true">
528 <param name="optimistic" value="true"/>
529 <param name="testResultsSubDir" value="optimistic"/>
530 </antcall>
531 <antcall target="-test-security" inheritRefs="true">
532 <param name="optimistic" value="true"/>
533 <param name="testResultsSubDir" value="optimistic"/>
534 </antcall>
535 </target>
537 <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">
538 <echo message="Running test suite in PESSIMISTIC mode..."/>
539 <antcall target="-test-nosecurity" inheritRefs="true">
540 <param name="optimistic" value="false"/>
541 <param name="testResultsSubDir" value="pessimistic"/>
542 </antcall>
543 <antcall target="-test-security" inheritRefs="true">
544 <param name="optimistic" value="false"/>
545 <param name="testResultsSubDir" value="pessimistic"/>
546 </antcall>
547 </target>
549 <target name="check-jemmy.jfx.testng" unless="jemmy.jfx.testng.available">
550 <echo message="WARNING: Jemmy or JavaFX or TestNG not available, will not run tests. Please copy TestNG and dependency JARs, JemmyCore.jar, JemmyFX.jar, JemmyAWTInput.jar to the test${file.separator}lib directory. And make sure you have jfxrt.jar in ${java.home}${file.separator}lib${file.separator}ext dir."/>
551 </target>
553 <target name="testjfx" depends="jar, get-testng, check-jemmy.jfx.testng, compile-test" if="jemmy.jfx.testng.available">
554 <fileset id="test.classes" dir="${build.test.classes.dir}">
555 <include name="**/framework/*Test.class"/>
556 </fileset>
558 <copy file="${file.reference.jfxrt.jar}" todir="dist"/>
560 <condition property="jfx.prism.order" value="-Dprism.order=j2d" else=" ">
561 <not>
562 <os family="mac"/>
563 </not>
564 </condition>
566 <testng outputdir="${build.test.results.dir}" classfilesetref="test.classes"
567 verbose="${testng.verbose}" haltonfailure="true" useDefaultListeners="false" listeners="${testng.listeners}" workingDir="${basedir}">
568 <jvmarg line="${ext.class.path}"/>
569 <jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx} -Dbuild.dir=${build.dir}"/>
570 <propertyset>
571 <propertyref prefix="testjfx-test-sys-prop."/>
572 <mapper from="testjfx-test-sys-prop.*" to="*" type="glob"/>
573 </propertyset>
574 <sysproperty key="test.fork.jvm.options" value="${testjfx-test-sys-prop.test.fork.jvm.options} ${jfx.prism.order}"/>
575 <classpath>
576 <pathelement path="${testjfx.run.test.classpath}"/>
577 </classpath>
578 </testng>
579 </target>
581 <target name="testmarkdown" depends="jar, get-testng, check-testng, check-external-tests, compile-test, generate-policy-file" if="testng.available">
582 <fileset id="test.classes" dir="${build.test.classes.dir}">
583 <include name="**/framework/*Test.class"/>
584 </fileset>
586 <testng outputdir="${build.test.results.dir}" classfilesetref="test.classes"
587 verbose="${testng.verbose}" haltonfailure="true" useDefaultListeners="false" listeners="${testng.listeners}" workingDir="${basedir}">
588 <jvmarg line="${ext.class.path}"/>
589 <jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx} ${run.test.jvmsecurityargs} -Dbuild.dir=${build.dir}"/>
590 <propertyset>
591 <propertyref prefix="testmarkdown-test-sys-prop."/>
592 <mapper from="testmarkdown-test-sys-prop.*" to="*" type="glob"/>
593 </propertyset>
594 <classpath>
595 <pathelement path="${run.test.classpath}"/>
596 </classpath>
597 </testng>
598 </target>
600 <target name="test262" depends="jar, get-testng, check-testng, check-external-tests, compile-test, generate-policy-file" if="testng.available">
601 <fileset id="test.classes" dir="${build.test.classes.dir}">
602 <include name="**/framework/*Test.class"/>
603 </fileset>
605 <testng outputdir="${build.test.results.dir}" classfilesetref="test.classes"
606 verbose="${testng.verbose}" haltonfailure="true" useDefaultListeners="false" listeners="${testng.listeners}" workingDir="${basedir}">
607 <jvmarg line="${ext.class.path}"/>
608 <jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx} ${run.test.jvmsecurityargs} -Dbuild.dir=${build.dir}"/>
609 <propertyset>
610 <propertyref prefix="nashorn."/>
611 </propertyset>
612 <propertyset>
613 <propertyref prefix="test262-test-sys-prop."/>
614 <mapper from="test262-test-sys-prop.*" to="*" type="glob"/>
615 </propertyset>
616 <classpath>
617 <pathelement path="${run.test.classpath}"/>
618 </classpath>
619 </testng>
620 </target>
622 <target name="test262parallel" depends="test262-parallel"/>
624 <target name="test262-parallel" depends="jar, get-testng, check-testng, check-external-tests, compile-test, generate-policy-file" if="testng.available">
625 <!-- use just build.test.classes.dir to avoid referring to TestNG -->
626 <java classname="${parallel.test.runner}" dir="${basedir}" fork="true">
627 <jvmarg line="${ext.class.path}"/>
628 <jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx} ${run.test.jvmsecurityargs} -Dbuild.dir=${build.dir}"/>
629 <!-- avoid too many typeinfo cache files. Each script is run only once anyway -->
630 <jvmarg line="-Dnashorn.typeInfo.disabled=true"/>
631 <classpath>
632 <pathelement path="${run.test.classpath}"/>
633 </classpath>
634 <syspropertyset>
635 <propertyref prefix="test262-test-sys-prop."/>
636 <mapper type="glob" from="test262-test-sys-prop.*" to="*"/>
637 </syspropertyset>
638 </java>
639 </target>
641 <target name="testparallel" depends="test-parallel"/>
643 <target name="test-parallel" depends="jar, get-testng, check-testng, check-external-tests, compile-test, generate-policy-file" if="testng.available">
644 <!-- use just build.test.classes.dir to avoid referring to TestNG -->
645 <java classname="${parallel.test.runner}" dir="${basedir}"
646 failonerror="true"
647 fork="true">
648 <jvmarg line="${ext.class.path}"/>
649 <jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx} ${run.test.jvmsecurityargs}"/>
650 <classpath>
651 <pathelement path="${run.test.classpath}"/>
652 <pathelement path="${build.test.classes.dir}"/>
653 </classpath>
654 <syspropertyset>
655 <propertyref prefix="test-sys-prop."/>
656 <mapper type="glob" from="test-sys-prop.*" to="*"/>
657 </syspropertyset>
658 </java>
659 </target>
661 <target name="all" depends="test, docs"
662 description="Build, test and generate docs for nashorn"/>
664 <target name="run" depends="jar"
665 description="Run the shell with a sample script">
666 <java classname="${nashorn.shell.tool}" fork="true" dir="samples">
667 <jvmarg line="${ext.class.path}"/>
668 <jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx}"/>
669 <arg value="-dump-on-error"/>
670 <arg value="test.js"/>
671 </java>
672 </target>
674 <target name="debug" depends="jar"
675 description="Debug the shell with a sample script">
676 <java classname="${nashorn.shell.tool}" fork="true" dir="samples">
677 <jvmarg line="${ext.class.path}"/>
678 <jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx}"/>
679 <arg value="--print-code"/>
680 <arg value="--verify-code"/>
681 <arg value="--print-symbols"/>
682 <jvmarg value="-Dnashorn.codegen.debug=true"/>
683 <arg value="test.js"/>
684 </java>
685 </target>
687 <!-- targets to get external script tests -->
689 <!-- test262 test suite -->
690 <target name="get-test262" depends="init" unless="${test-sys-prop.external.test262}">
691 <!-- clone test262 git repo -->
692 <exec executable="${git.executable}">
693 <arg value="clone"/>
694 <arg value="--branch"/>
695 <arg value="es5-tests"/>
696 <arg value="https://github.com/tc39/test262"/>
697 <arg value="${test.external.dir}/test262"/>
698 </exec>
699 </target>
700 <target name="update-test262" depends="init" if="${test-sys-prop.external.test262}">
701 <!-- update test262 git repo -->
702 <exec executable="${git.executable}" dir="${test.external.dir}/test262">
703 <arg value="pull"/>
704 </exec>
705 </target>
707 <!-- octane benchmark -->
708 <target name="get-octane" depends="init" unless="${test-sys-prop.external.octane}">
709 <!-- checkout octane benchmarks -->
710 <exec executable="${svn.executable}">
711 <arg value="--non-interactive"/>
712 <arg value="--trust-server-cert"/>
713 <arg value="checkout"/>
714 <arg value="http://octane-benchmark.googlecode.com/svn/trunk/"/>
715 <arg value="${test.external.dir}/octane"/>
716 </exec>
717 </target>
718 <target name="update-octane" depends="init" if="${test-sys-prop.external.octane}">
719 <!-- update octane benchmarks -->
720 <exec executable="${svn.executable}" dir="${test.external.dir}/octane">
721 <arg value="--non-interactive"/>
722 <arg value="--trust-server-cert"/>
723 <arg value="update"/>
724 </exec>
725 </target>
727 <!-- sunspider benchmark -->
728 <target name="get-sunspider" depends="init" unless="${test-sys-prop.external.sunspider}">
729 <!-- checkout sunspider -->
730 <exec executable="${svn.executable}">
731 <arg value="--non-interactive"/>
732 <arg value="--trust-server-cert"/>
733 <arg value="checkout"/>
734 <arg value="http://svn.webkit.org/repository/webkit/trunk/PerformanceTests/SunSpider"/>
735 <arg value="${test.external.dir}/sunspider"/>
736 </exec>
737 </target>
738 <target name="update-sunspider" depends="init" if="${test-sys-prop.external.sunspider}">
739 <!-- update sunspider -->
740 <exec executable="${svn.executable}" dir="${test.external.dir}/sunspider">
741 <arg value="--non-interactive"/>
742 <arg value="--trust-server-cert"/>
743 <arg value="update"/>
744 </exec>
745 </target>
747 <!-- get all external test scripts -->
748 <target name="externals" depends="init, check-external-tests, get-test262, get-octane, get-sunspider, get-testng">
749 <!-- make external test dir -->
750 <mkdir dir="${test.external.dir}"/>
752 <!-- jquery -->
753 <mkdir dir="${test.external.dir}/jquery"/>
754 <get src="http://code.jquery.com/jquery-1.7.2.js" dest="${test.external.dir}/jquery" skipexisting="true" ignoreerrors="true"/>
755 <get src="http://code.jquery.com/jquery-1.7.2.min.js" dest="${test.external.dir}/jquery" skipexisting="true" ignoreerrors="true"/>
757 <!-- prototype -->
758 <mkdir dir="${test.external.dir}/prototype"/>
759 <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"/>
761 <!-- underscorejs -->
762 <mkdir dir="${test.external.dir}/underscore"/>
763 <get src="http://underscorejs.org/underscore.js" dest="${test.external.dir}/underscore" skipexisting="true" ignoreerrors="true"/>
764 <get src="http://underscorejs.org/underscore-min.js" dest="${test.external.dir}/underscore" skipexisting="true" ignoreerrors="true"/>
766 <!-- yui -->
767 <mkdir dir="${test.external.dir}/yui"/>
768 <get src="http://yui.yahooapis.com/3.5.1/build/yui/yui.js" dest="${test.external.dir}/yui" skipexisting="true" ignoreerrors="true"/>
769 <get src="http://yui.yahooapis.com/3.5.1/build/yui/yui-min.js" dest="${test.external.dir}/yui" skipexisting="true" ignoreerrors="true"/>
771 <!-- showdown -->
772 <mkdir dir="${test.external.dir}/showdown"/>
773 <get src="https://raw.githubusercontent.com/showdownjs/showdown/0.5.4/src/showdown.js" dest="${test.external.dir}/showdown" skipexisting="true" ignoreerrors="true"/>
774 <get src="https://raw.githubusercontent.com/showdownjs/showdown/0.5.4/src/extensions/table.js" dest="${test.external.dir}/showdown" skipexisting="true" ignoreerrors="true"/>
776 </target>
778 <!-- update external test suites that are pulled from source control systems -->
779 <target name="update-externals" depends="init, check-external-tests, update-test262, update-octane, update-sunspider"/>
781 <!-- run all perf tests -->
782 <target name="perf" depends="externals, update-externals, sunspider, octane"/>
784 <!-- download and install testng.jar -->
785 <target name="get-testng">
786 <get dest="${test.lib}" skipexisting="true">
787 <url url="http://central.maven.org/maven2/org/testng/testng/6.8/testng-6.8.jar"/>
788 <url url="http://central.maven.org/maven2/com/beust/jcommander/1.27/jcommander-1.27.jar"/>
789 <url url="http://central.maven.org/maven2/org/beanshell/bsh/2.0b4/bsh-2.0b4.jar"/>
790 <url url="http://central.maven.org/maven2/org/yaml/snakeyaml/1.6/snakeyaml-1.6.jar"/>
791 </get>
792 </target>
794 <!-- run all tests -->
795 <target name="alltests" depends="get-testng, externals, update-externals, test, test262parallel, testmarkdown, perf"/>
797 <import file="build-benchmark.xml"/>
799 </project>