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="${nashorn.module.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="${nashorn.module.src.dir}" includes="**/*.java"/> 229 <fileset dir="${nashorn.shell.module.src.dir}" includes="**/*.java"/> 230 <fileset dir="${jdk.asm.src.dir}" includes="**/*.java"/> 231 <link href="http://docs.oracle.com/javase/8/docs/api/"/> 232 <!-- The following tags are used only in ASM sources - just ignore these --> 233 <tag name="label" description="label tag in ASM sources" enabled="false"/> 234 <tag name="linked" description="linked tag in ASM sources" enabled="false"/> 235 <tag name="associates" description="associates tag in ASM sources" enabled="false"/> 236 </javadoc> 237 </target> 238 239 <!-- generate javadoc for Nashorn classes --> 240 <target name="javadocnh" depends="jar"> 241 <javadoc destdir="${dist.javadoc.dir}" use="yes" overview="${nashorn.module.src.dir}/overview.html" 242 extdirs="${nashorn.ext.path}" windowtitle="${nashorn.product.name} ${nashorn.version}" 243 additionalparam="-quiet" failonerror="true" useexternalfile="true"> 244 <classpath> 245 <pathelement location="${build.classes.dir}"/> 246 </classpath> 247 <fileset dir="${nashorn.module.src.dir}" includes="**/*.java"/> 248 <fileset dir="${nashorn.shell.module.src.dir}" includes="**/*.java"/> 249 <link href="http://docs.oracle.com/javase/8/docs/api/"/> 250 </javadoc> 251 </target> 252 253 <!-- generate javadoc only for nashorn extension api classes --> 254 <target name="javadocapi" depends="jar"> 255 <javadoc destdir="${dist.javadoc.dir}" use="yes" overview="${nashorn.module.src.dir}/overview.html" 256 extdirs="${nashorn.ext.path}" windowtitle="${nashorn.product.name} ${nashorn.version}" 257 additionalparam="-quiet" failonerror="true" useexternalfile="true"> 258 <classpath> 259 <pathelement location="${build.classes.dir}"/> 260 </classpath> 261 <fileset dir="${nashorn.module.src.dir}" includes="jdk/nashorn/api/**/*.java"/> 262 <link href="http://docs.oracle.com/javase/8/docs/api/"/> 263 </javadoc> 264 </target> 265 266 267 <!-- generate shell.html for shell tool documentation --> 268 <target name="shelldoc" depends="jar"> 269 <java classname="${nashorn.shell.tool}" dir="${basedir}" output="${dist.dir}/shell.html" failonerror="true" fork="true"> 270 <jvmarg line="${boot.class.path}"/> 271 <arg value="-scripting"/> 272 <arg value="docs/genshelldoc.js"/> 273 </java> 274 </target> 275 276 <!-- generate all docs --> 277 <target name="docs" depends="javadoc, shelldoc"/> 278 279 <!-- create .zip and .tar.gz for nashorn binaries and scripts. --> 280 <target name="dist" depends="jar"> 281 <zip destfile="${build.zip}" basedir=".." 282 excludes="nashorn/bin/*.sh" includes="nashorn/bin/** nashorn/dist/**"/> 283 <tar destfile="${build.gzip}" basedir=".." compression="gzip" 284 excludes="nashorn/bin/*.sh" includes="nashorn/bin/** nashorn/dist/**"/> 285 </target> 286 287 <target name="compile-test" depends="compile, run-nasgen" if="testng.available"> 288 <!-- testng task --> 289 <taskdef name="testng" classname="org.testng.TestNGAntTask" 290 classpath="${file.reference.testng.jar}"/> 291 292 <javac srcdir="${test.src.dir}" 293 destdir="${build.test.classes.dir}" 294 classpath="${javac.test.classpath}" 295 source="${javac.source}" 296 target="${javac.target}" 297 debug="${javac.debug}" 298 encoding="${javac.encoding}" 299 includeantruntime="false" fork="true"> 300 <compilerarg value="${boot.class.path}"/> 301 <compilerarg value="-Xlint:unchecked"/> 302 <compilerarg value="-Xlint:deprecation"/> 303 <compilerarg value="-Xdiags:verbose"/> 304 </javac> 305 306 <copy todir="${build.test.classes.dir}/META-INF/services"> 307 <fileset dir="${test.src.dir}/META-INF/services/"/> 308 </copy> 309 310 <copy todir="${build.test.classes.dir}/jdk/nashorn/internal/runtime/test/resources"> 311 <fileset dir="${test.src.dir}/jdk/nashorn/internal/runtime/test/resources"/> 312 </copy> 313 314 <copy todir="${build.test.classes.dir}/jdk/nashorn/internal/runtime/doubleconv/test/resources"> 315 <fileset dir="${test.src.dir}/jdk/nashorn/internal/runtime/doubleconv/test/resources"/> 316 </copy> 317 318 <copy todir="${build.test.classes.dir}/jdk/nashorn/api/scripting/test/resources"> 319 <fileset dir="${test.src.dir}/jdk/nashorn/api/scripting/test/resources"/> 320 </copy> 321 322 <!-- tests that check nashorn internals and internal API --> 323 <jar jarfile="${nashorn.internal.tests.jar}"> 324 <fileset dir="${build.test.classes.dir}" excludes="**/api/**"/> 325 </jar> 326 327 <!-- tests that check nashorn script engine (jsr-223) API --> 328 <jar jarfile="${nashorn.api.tests.jar}"> 329 <fileset dir="${build.test.classes.dir}" includes="**/api/**"/> 330 <fileset dir="${build.test.classes.dir}" includes="**/META-INF/**"/> 331 <fileset dir="${build.test.classes.dir}" includes="**/resources/*.js"/> 332 </jar> 333 334 </target> 335 336 <target name="generate-policy-file" depends="prepare"> 337 <echo file="${build.dir}/nashorn.policy"> 338 339 grant codeBase "file:/${toString:dist.path}/nashorn.jar" { 340 permission java.security.AllPermission; 341 }; 342 343 grant codeBase "file:/${basedir}/${nashorn.internal.tests.jar}" { 344 permission java.security.AllPermission; 345 }; 346 347 grant codeBase "file:/${basedir}/${nashorn.api.tests.jar}" { 348 permission java.util.PropertyPermission "parserapitest.*", "read"; 349 permission java.util.PropertyPermission "test.*", "read"; 350 permission java.util.PropertyPermission "test262.*", "read"; 351 permission java.io.FilePermission "${basedir}/test/-","read"; 352 permission java.io.FilePermission "$${user.dir}", "read"; 353 permission java.util.PropertyPermission "user.dir", "read"; 354 }; 355 356 grant codeBase "file:/${basedir}/${file.reference.testng.jar}" { 357 permission java.security.AllPermission; 358 }; 359 //// in case of absolute path: 360 grant codeBase "file:/${nashorn.internal.tests.jar}" { 361 permission java.security.AllPermission; 362 }; 363 364 grant codeBase "file:/${file.reference.testng.jar}" { 365 permission java.security.AllPermission; 366 }; 367 368 grant codeBase "file:/${basedir}/test/script/trusted/*" { 369 permission java.security.AllPermission; 370 }; 371 372 grant codeBase "file:/${basedir}/test/script/maptests/*" { 373 permission java.io.FilePermission "${basedir}/test/script/maptests/*","read"; 374 permission java.lang.RuntimePermission "nashorn.debugMode"; 375 }; 376 377 grant codeBase "file:/${basedir}/test/script/basic/*" { 378 permission java.io.FilePermission "${basedir}/test/script/-", "read"; 379 permission java.io.FilePermission "$${user.dir}", "read"; 380 permission java.util.PropertyPermission "user.dir", "read"; 381 permission java.util.PropertyPermission "nashorn.test.*", "read"; 382 }; 383 384 grant codeBase "file:/${basedir}/test/script/basic/parser/*" { 385 permission java.io.FilePermission "${basedir}/test/script/-", "read"; 386 permission java.io.FilePermission "$${user.dir}", "read"; 387 permission java.util.PropertyPermission "user.dir", "read"; 388 permission java.util.PropertyPermission "nashorn.test.*", "read"; 389 }; 390 391 grant codeBase "file:/${basedir}/test/script/basic/es6/*" { 392 permission java.io.FilePermission "${basedir}/test/script/-", "read"; 393 permission java.io.FilePermission "$${user.dir}", "read"; 394 permission java.util.PropertyPermission "user.dir", "read"; 395 permission java.util.PropertyPermission "nashorn.test.*", "read"; 396 }; 397 398 grant codeBase "file:/${basedir}/test/script/basic/JDK-8010946-privileged.js" { 399 permission java.util.PropertyPermission "java.security.policy", "read"; 400 }; 401 402 grant codeBase "file:/${basedir}/test/script/basic/classloader.js" { 403 permission java.lang.RuntimePermission "nashorn.JavaReflection"; 404 }; 405 406 grant codeBase "file:/${basedir}/test/script/markdown.js" { 407 permission java.io.FilePermission "${basedir}/test/script/external/showdown/-", "read"; 408 }; 409 410 </echo> 411 412 <replace file="${build.dir}/nashorn.policy"><replacetoken>\</replacetoken><replacevalue>/</replacevalue></replace> <!--hack for Windows - to make URLs with normal path separators --> 413 <replace file="${build.dir}/nashorn.policy"><replacetoken>//</replacetoken><replacevalue>/</replacevalue></replace> <!--hack for Unix - to avoid leading // in URLs --> 414 415 </target> 416 417 <target name="check-external-tests"> 418 <available file="${test.external.dir}/prototype" property="test-sys-prop.external.prototype"/> 419 <available file="${test.external.dir}/sunspider" property="test-sys-prop.external.sunspider"/> 420 <available file="${test.external.dir}/underscore" property="test-sys-prop.external.underscore"/> 421 <available file="${test.external.dir}/octane" property="test-sys-prop.external.octane"/> 422 <available file="${test.external.dir}/yui" property="test-sys-prop.external.yui"/> 423 <available file="${test.external.dir}/jquery" property="test-sys-prop.external.jquery"/> 424 <available file="${test.external.dir}/test262" property="test-sys-prop.external.test262"/> 425 <available file="${test.external.dir}/showdown" property="test-sys-prop.external.markdown"/> 426 </target> 427 428 <target name="check-testng" unless="testng.available"> 429 <echo message="WARNING: TestNG not available, will not run tests. Please copy testng.jar under ${test.lib} directory."/> 430 </target> 431 432 <!-- only to be invoked as dependency of "test" target --> 433 <target name="-test-classes-all" depends="jar" unless="test.class"> 434 <fileset id="test.classes" dir="${build.test.classes.dir}"> 435 <include name="**/api/javaaccess/test/*Test.class"/> 436 <include name="**/api/scripting/test/*Test.class"/> 437 <include name="**/api/tree/test/*Test.class"/> 438 <include name="**/codegen/test/*Test.class"/> 439 <include name="**/parser/test/*Test.class"/> 440 <include name="**/runtime/test/*Test.class"/> 441 <include name="**/runtime/regexp/test/*Test.class"/> 442 <include name="**/runtime/regexp/joni/test/*Test.class"/> 443 <include name="**/runtime/doubleconv/test/*Test.class"/> 444 <include name="**/framework/*Test.class"/> 445 </fileset> 446 </target> 447 448 <!-- only to be invoked as dependency of "test" target --> 449 <target name="-test-classes-single" depends="jar" if="test.class"> 450 <fileset id="test.classes" dir="${build.test.classes.dir}"> 451 <include name="${test.class}*"/> 452 </fileset> 453 </target> 454 455 <!-- only to be invoked as dependency of "test" target --> 456 <target name="-test-nosecurity" unless="test.class"> 457 <fileset id="test.nosecurity.classes" dir="${build.test.classes.dir}"> 458 <include name="**/framework/ScriptTest.class"/> 459 </fileset> 460 <testng outputdir="${build.nosecurity.test.results.dir}/${testResultsSubDir}" classfilesetref="test.nosecurity.classes" 461 verbose="${testng.verbose}" haltonfailure="true" useDefaultListeners="false" listeners="${testng.listeners}" workingDir="${basedir}"> 462 <jvmarg line="${boot.class.path}"/> 463 <jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx} -Dbuild.dir=${build.dir}"/> 464 <sysproperty key="nashorn.jar" value="${dist.dir}/nashorn.jar"/> 465 <propertyset> 466 <propertyref prefix="nashorn."/> 467 </propertyset> 468 <propertyset> 469 <propertyref prefix="test-sys-prop-no-security."/> 470 <mapper from="test-sys-prop-no-security.*" to="*" type="glob"/> 471 </propertyset> 472 <sysproperty key="optimistic.override" value="${optimistic}"/> 473 <classpath> 474 <pathelement path="${run.test.classpath}"/> 475 </classpath> 476 </testng> 477 </target> 478 479 <!-- only to be invoked as dependency of "test" target --> 480 <target name="-test-security"> 481 <delete dir="${build.dir}/nashorn_code_cache"/> 482 <property name="debug.test.jvmargs" value=""/> 483 <testng outputdir="${build.test.results.dir}/${testResultsSubDir}" classfilesetref="test.classes" 484 verbose="${testng.verbose}" haltonfailure="true" useDefaultListeners="false" listeners="${testng.listeners}" workingDir="${basedir}"> 485 <jvmarg line="${boot.class.path}"/> 486 <jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx} ${run.test.jvmsecurityargs} -Dbuild.dir=${build.dir}"/> 487 <jvmarg line="${debug.test.jvmargs}"/> 488 <propertyset> 489 <propertyref prefix="nashorn."/> 490 </propertyset> 491 <propertyset> 492 <propertyref prefix="test-sys-prop."/> 493 <mapper from="test-sys-prop.*" to="*" type="glob"/> 494 </propertyset> 495 <sysproperty key="optimistic.override" value="${optimistic}"/> 496 <sysproperty key="test.js.excludes.file" value="${exclude.list}"/> 497 <classpath> 498 <pathelement path="${run.test.classpath}"/> 499 </classpath> 500 </testng> 501 </target> 502 503 <target name="test" depends="prepare, javadocnh, test-pessimistic, test-optimistic"/> 504 505 <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"> 506 <echo message="Running test suite in OPTIMISTIC mode..."/> 507 <antcall target="-test-nosecurity" inheritRefs="true"> 508 <param name="optimistic" value="true"/> 509 <param name="testResultsSubDir" value="optimistic"/> 510 </antcall> 511 <antcall target="-test-security" inheritRefs="true"> 512 <param name="optimistic" value="true"/> 513 <param name="testResultsSubDir" value="optimistic"/> 514 </antcall> 515 </target> 516 517 <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"> 518 <echo message="Running test suite in PESSIMISTIC mode..."/> 519 <antcall target="-test-nosecurity" inheritRefs="true"> 520 <param name="optimistic" value="false"/> 521 <param name="testResultsSubDir" value="pessimistic"/> 522 </antcall> 523 <antcall target="-test-security" inheritRefs="true"> 524 <param name="optimistic" value="false"/> 525 <param name="testResultsSubDir" value="pessimistic"/> 526 </antcall> 527 </target> 528 529 <target name="check-jemmy.jfx.testng" unless="jemmy.jfx.testng.available"> 530 <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."/> 531 </target> 532 533 <target name="testjfx" depends="jar, check-jemmy.jfx.testng, compile-test" if="jemmy.jfx.testng.available"> 534 <fileset id="test.classes" dir="${build.test.classes.dir}"> 535 <include name="**/framework/*Test.class"/> 536 </fileset> 537 538 <copy file="${file.reference.jfxrt.jar}" todir="dist"/> 539 540 <condition property="jfx.prism.order" value="-Dprism.order=j2d" else=" "> 541 <not> 542 <os family="mac"/> 543 </not> 544 </condition> 545 546 <testng outputdir="${build.test.results.dir}" classfilesetref="test.classes" 547 verbose="${testng.verbose}" haltonfailure="true" useDefaultListeners="false" listeners="${testng.listeners}" workingDir="${basedir}"> 548 <jvmarg line="${boot.class.path}"/> 549 <jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx} -Dbuild.dir=${build.dir}"/> 550 <propertyset> 551 <propertyref prefix="testjfx-test-sys-prop."/> 552 <mapper from="testjfx-test-sys-prop.*" to="*" type="glob"/> 553 </propertyset> 554 <sysproperty key="test.fork.jvm.options" value="${testjfx-test-sys-prop.test.fork.jvm.options} ${jfx.prism.order}"/> 555 <classpath> 556 <pathelement path="${testjfx.run.test.classpath}"/> 557 </classpath> 558 </testng> 559 </target> 560 561 <target name="testmarkdown" depends="jar, check-testng, check-external-tests, compile-test, generate-policy-file" if="testng.available"> 562 <fileset id="test.classes" dir="${build.test.classes.dir}"> 563 <include name="**/framework/*Test.class"/> 564 </fileset> 565 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="${boot.class.path}"/> 569 <jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx} ${run.test.jvmsecurityargs} -Dbuild.dir=${build.dir}"/> 570 <propertyset> 571 <propertyref prefix="testmarkdown-test-sys-prop."/> 572 <mapper from="testmarkdown-test-sys-prop.*" to="*" type="glob"/> 573 </propertyset> 574 <classpath> 575 <pathelement path="${run.test.classpath}"/> 576 </classpath> 577 </testng> 578 </target> 579 580 <target name="test262" depends="jar, check-testng, check-external-tests, compile-test, generate-policy-file" if="testng.available"> 581 <fileset id="test.classes" dir="${build.test.classes.dir}"> 582 <include name="**/framework/*Test.class"/> 583 </fileset> 584 585 <testng outputdir="${build.test.results.dir}" classfilesetref="test.classes" 586 verbose="${testng.verbose}" haltonfailure="true" useDefaultListeners="false" listeners="${testng.listeners}" workingDir="${basedir}"> 587 <jvmarg line="${boot.class.path}"/> 588 <jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx} ${run.test.jvmsecurityargs} -Dbuild.dir=${build.dir}"/> 589 <propertyset> 590 <propertyref prefix="nashorn."/> 591 </propertyset> 592 <propertyset> 593 <propertyref prefix="test262-test-sys-prop."/> 594 <mapper from="test262-test-sys-prop.*" to="*" type="glob"/> 595 </propertyset> 596 <classpath> 597 <pathelement path="${run.test.classpath}"/> 598 </classpath> 599 </testng> 600 </target> 601 602 <target name="test262parallel" depends="test262-parallel"/> 603 604 <target name="test262-parallel" depends="jar, check-testng, check-external-tests, compile-test, generate-policy-file" if="testng.available"> 605 <!-- use just build.test.classes.dir to avoid referring to TestNG --> 606 <java classname="${parallel.test.runner}" dir="${basedir}" fork="true"> 607 <jvmarg line="${boot.class.path}"/> 608 <jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx} ${run.test.jvmsecurityargs} -Dbuild.dir=${build.dir}"/> 609 <!-- avoid too many typeinfo cache files. Each script is run only once anyway --> 610 <jvmarg line="-Dnashorn.typeInfo.disabled=true"/> 611 <classpath> 612 <pathelement path="${run.test.classpath}"/> 613 </classpath> 614 <syspropertyset> 615 <propertyref prefix="test262-test-sys-prop."/> 616 <mapper type="glob" from="test262-test-sys-prop.*" to="*"/> 617 </syspropertyset> 618 </java> 619 </target> 620 621 <target name="testparallel" depends="test-parallel"/> 622 623 <target name="test-parallel" depends="jar, check-testng, check-external-tests, compile-test, generate-policy-file" if="testng.available"> 624 <!-- use just build.test.classes.dir to avoid referring to TestNG --> 625 <java classname="${parallel.test.runner}" dir="${basedir}" 626 failonerror="true" 627 fork="true"> 628 <jvmarg line="${boot.class.path}"/> 629 <jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx} ${run.test.jvmsecurityargs}"/> 630 <classpath> 631 <pathelement path="${run.test.classpath}"/> 632 <pathelement path="${build.test.classes.dir}"/> 633 </classpath> 634 <syspropertyset> 635 <propertyref prefix="test-sys-prop."/> 636 <mapper type="glob" from="test-sys-prop.*" to="*"/> 637 </syspropertyset> 638 </java> 639 </target> 640 641 <target name="all" depends="test, docs" 642 description="Build, test and generate docs for nashorn"/> 643 644 <target name="run" depends="jar" 645 description="Run the shell with a sample script"> 646 <java classname="${nashorn.shell.tool}" fork="true" dir="samples"> 647 <jvmarg line="${boot.class.path}"/> 648 <jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx}"/> 649 <arg value="-dump-on-error"/> 650 <arg value="test.js"/> 651 </java> 652 </target> 653 654 <target name="debug" depends="jar" 655 description="Debug the shell with a sample script"> 656 <java classname="${nashorn.shell.tool}" fork="true" dir="samples"> 657 <jvmarg line="${boot.class.path}"/> 658 <jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx}"/> 659 <arg value="--print-code"/> 660 <arg value="--verify-code"/> 661 <arg value="--print-symbols"/> 662 <jvmarg value="-Dnashorn.codegen.debug=true"/> 663 <arg value="test.js"/> 664 </java> 665 </target> 666 667 <!-- targets to get external script tests --> 668 669 <!-- test262 test suite --> 670 <target name="get-test262" depends="init" unless="${test-sys-prop.external.test262}"> 671 <!-- clone test262 git repo --> 672 <exec executable="${git.executable}"> 673 <arg value="clone"/> 674 <arg value="--branch"/> 675 <arg value="es5-tests"/> 676 <arg value="https://github.com/tc39/test262"/> 677 <arg value="${test.external.dir}/test262"/> 678 </exec> 679 </target> 680 <target name="update-test262" depends="init" if="${test-sys-prop.external.test262}"> 681 <!-- update test262 git repo --> 682 <exec executable="${git.executable}" dir="${test.external.dir}/test262"> 683 <arg value="pull"/> 684 </exec> 685 </target> 686 687 <!-- octane benchmark --> 688 <target name="get-octane" depends="init" unless="${test-sys-prop.external.octane}"> 689 <!-- checkout octane benchmarks --> 690 <exec executable="${svn.executable}"> 691 <arg value="--non-interactive"/> 692 <arg value="--trust-server-cert"/> 693 <arg value="checkout"/> 694 <arg value="http://octane-benchmark.googlecode.com/svn/trunk/"/> 695 <arg value="${test.external.dir}/octane"/> 696 </exec> 697 </target> 698 <target name="update-octane" depends="init" if="${test-sys-prop.external.octane}"> 699 <!-- update octane benchmarks --> 700 <exec executable="${svn.executable}" dir="${test.external.dir}/octane"> 701 <arg value="--non-interactive"/> 702 <arg value="--trust-server-cert"/> 703 <arg value="update"/> 704 </exec> 705 </target> 706 707 <!-- sunspider benchmark --> 708 <target name="get-sunspider" depends="init" unless="${test-sys-prop.external.sunspider}"> 709 <!-- checkout sunspider --> 710 <exec executable="${svn.executable}"> 711 <arg value="--non-interactive"/> 712 <arg value="--trust-server-cert"/> 713 <arg value="checkout"/> 714 <arg value="http://svn.webkit.org/repository/webkit/trunk/PerformanceTests/SunSpider"/> 715 <arg value="${test.external.dir}/sunspider"/> 716 </exec> 717 </target> 718 <target name="update-sunspider" depends="init" if="${test-sys-prop.external.sunspider}"> 719 <!-- update sunspider --> 720 <exec executable="${svn.executable}" dir="${test.external.dir}/sunspider"> 721 <arg value="--non-interactive"/> 722 <arg value="--trust-server-cert"/> 723 <arg value="update"/> 724 </exec> 725 </target> 726 727 <!-- get all external test scripts --> 728 <target name="externals" depends="init, check-external-tests, get-test262, get-octane, get-sunspider"> 729 <!-- make external test dir --> 730 <mkdir dir="${test.external.dir}"/> 731 732 <!-- jquery --> 733 <mkdir dir="${test.external.dir}/jquery"/> 734 <get src="http://code.jquery.com/jquery-1.7.2.js" dest="${test.external.dir}/jquery" skipexisting="true" ignoreerrors="true"/> 735 <get src="http://code.jquery.com/jquery-1.7.2.min.js" dest="${test.external.dir}/jquery" skipexisting="true" ignoreerrors="true"/> 736 737 <!-- prototype --> 738 <mkdir dir="${test.external.dir}/prototype"/> 739 <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"/> 740 741 <!-- underscorejs --> 742 <mkdir dir="${test.external.dir}/underscore"/> 743 <get src="http://underscorejs.org/underscore.js" dest="${test.external.dir}/underscore" skipexisting="true" ignoreerrors="true"/> 744 <get src="http://underscorejs.org/underscore-min.js" dest="${test.external.dir}/underscore" skipexisting="true" ignoreerrors="true"/> 745 746 <!-- yui --> 747 <mkdir dir="${test.external.dir}/yui"/> 748 <get src="http://yui.yahooapis.com/3.5.1/build/yui/yui.js" dest="${test.external.dir}/yui" skipexisting="true" ignoreerrors="true"/> 749 <get src="http://yui.yahooapis.com/3.5.1/build/yui/yui-min.js" dest="${test.external.dir}/yui" skipexisting="true" ignoreerrors="true"/> 750 751 <!-- showdown --> 752 <mkdir dir="${test.external.dir}/showdown"/> 753 <get src="https://raw.githubusercontent.com/showdownjs/showdown/0.5.4/src/showdown.js" dest="${test.external.dir}/showdown" skipexisting="true" ignoreerrors="true"/> 754 <get src="https://raw.githubusercontent.com/showdownjs/showdown/0.5.4/src/extensions/table.js" dest="${test.external.dir}/showdown" skipexisting="true" ignoreerrors="true"/> 755 756 </target> 757 758 <!-- update external test suites that are pulled from source control systems --> 759 <target name="update-externals" depends="init, check-external-tests, update-test262, update-octane, update-sunspider"/> 760 761 <!-- run all perf tests --> 762 <target name="perf" depends="externals, update-externals, sunspider, octane"/> 763 764 <!-- download and install testng.jar --> 765 <target name="get-testng" unless="testng.already.present"> 766 <get src="http://testng.org/testng-6.8.zip" dest="${test.lib}" skipexisting="true" ignoreerrors="true"/> 767 <unzip src="${test.lib}${file.separator}testng-6.8.zip" dest="${test.lib}"> 768 <patternset> 769 <include name="testng-6.8/testng-6.8.jar"/> 770 </patternset> 771 </unzip> 772 <move file="${test.lib}${file.separator}testng-6.8${file.separator}testng-6.8.jar" tofile="${test.lib}${file.separator}testng.jar"/> 773 <delete dir="${test.lib}${file.separator}testng-6.8"/> 774 </target> 775 776 <!-- run all tests --> 777 <target name="alltests" depends="externals, update-externals, test, test262parallel, testmarkdown, perf"/> 778 779 <import file="build-benchmark.xml"/> 780 781 </project>