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