This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ant.git
The following commit(s) were added to refs/heads/master by this push:
new b428d18e5 user the more robust setup of script-test for all script
antunit tests
b428d18e5 is described below
commit b428d18e5b42e8a4d06668f833a6f994602bc969
Author: Stefan Bodewig <[email protected]>
AuthorDate: Wed May 13 22:29:17 2026 +0200
user the more robust setup of script-test for all script antunit tests
---
src/tests/antunit/script-prereq-check.xml | 44 ++++++++++++++++++++
.../taskdefs/optional/script/script-test.xml | 29 +++++--------
.../taskdefs/optional/script/scriptdef-test.xml | 27 +------------
.../types/optional/scriptcondition-test.xml | 47 +++++++++-------------
4 files changed, 72 insertions(+), 75 deletions(-)
diff --git a/src/tests/antunit/script-prereq-check.xml
b/src/tests/antunit/script-prereq-check.xml
new file mode 100644
index 000000000..6521b309c
--- /dev/null
+++ b/src/tests/antunit/script-prereq-check.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ https://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project name="script-prereq-check">
+ <condition property="prereqs-ok">
+ <and>
+ <!-- Starting Java 15, there's no "javascript" script engine (not even
nashorn) bundled in JRE -->
+ <javaversion atmost="14"/>
+ <or>
+ <and>
+ <available classname="org.apache.bsf.BSFManager" />
+ <available
classname="org.apache.bsf.engines.javascript.JavaScriptEngine" />
+ </and>
+ <available classname="javax.script.ScriptEngineManager" />
+ </or>
+ </and>
+ </condition>
+
+ <!-- auto doesn't verify the language is supported and selects BSF
+ even if the JavaScriptEngine is not there -->
+ <condition property="script.manager" value="javax">
+ <and>
+ <not>
+ <available
classname="org.apache.bsf.engines.javascript.JavaScriptEngine" />
+ </not>
+ <isset property="prereqs-ok"/>
+ </and>
+ </condition>
+ <property name="script.manager" value="auto" />
+</project>
diff --git a/src/tests/antunit/taskdefs/optional/script/script-test.xml
b/src/tests/antunit/taskdefs/optional/script/script-test.xml
index a003c2f08..43d751b42 100644
--- a/src/tests/antunit/taskdefs/optional/script/script-test.xml
+++ b/src/tests/antunit/taskdefs/optional/script/script-test.xml
@@ -17,51 +17,40 @@
-->
<project default="antunit" xmlns:au="antlib:org.apache.ant.antunit">
<import file="../../../antunit-base.xml" />
+ <import file="../../../script-prereq-check.xml" />
- <target name="setUp">
- <condition property="expect-js">
- <not>
- <and>
- <isset property="jenkins" />
- <javaversion atleast="15" />
- </and>
- </not>
- </condition>
- <echo>$${expect-js}=${expect-js}</echo>
- </target>
-
- <target name="test-available-property-default" depends="setUp"
if="expect-js">
+ <target name="test-available-property-default" if="prereqs-ok">
<property name="foo" value="FOO" />
- <script language="javascript">
+ <script language="javascript" manager="${script.manager}">
project.setProperty('bar', foo);
</script>
<au:assertEquals expected="${foo}" actual="${bar}" />
</target>
- <target name="test-available-property-setbeans-false" depends="setUp"
if="expect-js">
+ <target name="test-available-property-setbeans-false" if="prereqs-ok">
<property name="baz" value="BAZ" />
<au:expectfailure>
- <script language="javascript" setbeans="false">
+ <script language="javascript" setbeans="false"
manager="${script.manager}">
project.log(nosuch);
var b = (baz == project.getProperty('baz'));
</script>
</au:expectfailure>
</target>
- <target name="test-available-local-property" depends="setUp" if="expect-js">
+ <target name="test-available-local-property" if="prereqs-ok">
<local name="localproperty" />
<property name="localproperty" value="iamlocal" />
- <script language="javascript">
+ <script language="javascript" manager="${script.manager}">
if (localproperty != project.getProperty('localproperty')) throw new
org.apache.tools.ant.BuildException();
</script>
</target>
- <target name="test-shaded-local-property" depends="setUp" if="expect-js">
+ <target name="test-shaded-local-property" if="prereqs-ok">
<property name="shademe" value="FOO" />
<sequential>
<local name="shademe" />
<property name="shademe" value="BAR" />
- <script language="javascript">
+ <script language="javascript" manager="${script.manager}">
if (shademe != project.getProperty('shademe')) throw new
org.apache.tools.ant.BuildException();
</script>
</sequential>
diff --git a/src/tests/antunit/taskdefs/optional/script/scriptdef-test.xml
b/src/tests/antunit/taskdefs/optional/script/scriptdef-test.xml
index 62ddda608..740f08321 100644
--- a/src/tests/antunit/taskdefs/optional/script/scriptdef-test.xml
+++ b/src/tests/antunit/taskdefs/optional/script/scriptdef-test.xml
@@ -18,6 +18,7 @@
<project default="antunit" xmlns:au="antlib:org.apache.ant.antunit">
<import file="../../../antunit-base.xml" />
+ <import file="../../../script-prereq-check.xml" />
<description>
In which we test interesting aspects of scripting.
@@ -25,32 +26,6 @@
additions on Java6+.
</description>
- <condition property="prereqs-ok">
- <and>
- <!-- Starting Java 15, there's no "javascript" script engine (not even
nashorn) bundled in JRE -->
- <javaversion atmost="14"/>
- <or>
- <and>
- <available classname="org.apache.bsf.BSFManager" />
- <available
classname="org.apache.bsf.engines.javascript.JavaScriptEngine" />
- </and>
- <available classname="javax.script.ScriptEngineManager" />
- </or>
- </and>
- </condition>
-
- <!-- auto doesn't verify the language is supported and selects BSF
- even if the JavaScriptEngine is not there -->
- <condition property="script.manager" value="javax">
- <and>
- <not>
- <available
classname="org.apache.bsf.engines.javascript.JavaScriptEngine" />
- </not>
- <isset property="prereqs-ok"/>
- </and>
- </condition>
- <property name="script.manager" value="auto" />
-
<string id="script.code">
self.log("Ant version =${ant.version}");
project.setNewProperty("property","live");
diff --git a/src/tests/antunit/types/optional/scriptcondition-test.xml
b/src/tests/antunit/types/optional/scriptcondition-test.xml
index d136b0d73..678cfaf6b 100644
--- a/src/tests/antunit/types/optional/scriptcondition-test.xml
+++ b/src/tests/antunit/types/optional/scriptcondition-test.xml
@@ -17,80 +17,69 @@
-->
<project default="antunit" xmlns:au="antlib:org.apache.ant.antunit">
<import file="../../antunit-base.xml" />
+ <import file="../../script-prereq-check.xml" />
- <target name="setUp">
- <condition property="expect-js">
- <not>
- <and>
- <isset property="jenkins" />
- <javaversion atleast="15" />
- </and>
- </not>
- </condition>
- <echo>$${expect-js}=${expect-js}</echo>
- </target>
-
- <target name="test-default-behavior" depends="setUp" if="expect-js">
+ <target name="test-default-behavior" if="prereqs-ok">
<au:assertFalse>
<scriptcondition language="javascript" />
</au:assertFalse>
</target>
- <target name="test-set-value-true" depends="setUp" if="expect-js">
+ <target name="test-set-value-true" if="prereqs-ok">
<au:assertTrue>
- <scriptcondition language="javascript">
+ <scriptcondition language="javascript" manager="${script.manager}">
self.setValue(true);
</scriptcondition>
</au:assertTrue>
</target>
- <target name="test-set-value-false" depends="setUp" if="expect-js">
+ <target name="test-set-value-false" if="prereqs-ok">
<au:assertFalse>
- <scriptcondition language="javascript">
+ <scriptcondition language="javascript" manager="${script.manager}">
self.setValue(false);
</scriptcondition>
</au:assertFalse>
</target>
- <target name="test-default-value-true" depends="setUp" if="expect-js">
+ <target name="test-default-value-true" if="prereqs-ok">
<au:assertTrue>
- <scriptcondition language="javascript" value="true" />
+ <scriptcondition language="javascript" value="true"
manager="${script.manager}"/>
</au:assertTrue>
</target>
- <target name="test-default-value-false" depends="setUp" if="expect-js">
+ <target name="test-default-value-false" if="prereqs-ok">
<au:assertFalse>
- <scriptcondition language="javascript" value="false" />
+ <scriptcondition language="javascript" value="false"
manager="${script.manager}"/>
</au:assertFalse>
</target>
- <target name="test-default-value-override-true" depends="setUp"
if="expect-js">
+ <target name="test-default-value-override-true" if="prereqs-ok">
<au:assertTrue>
- <scriptcondition language="javascript" value="false">
+ <scriptcondition language="javascript" value="false"
manager="${script.manager}">
self.setValue(true);
</scriptcondition>
</au:assertTrue>
</target>
- <target name="test-default-value-override-false" depends="setUp"
if="expect-js">
+ <target name="test-default-value-override-false" if="prereqs-ok">
<au:assertFalse>
- <scriptcondition language="javascript" value="true">
+ <scriptcondition language="javascript" value="true"
manager="${script.manager}">
self.setValue(false);
</scriptcondition>
</au:assertFalse>
</target>
- <target name="test-return-value-true" depends="setUp" if="expect-js">
+ <target name="test-return-value-true" if="prereqs-ok">
<au:assertTrue>
- <scriptcondition language="javascript" manager="javax">
+ <scriptcondition language="javascript" manager="${script.manager}">
true
</scriptcondition>
</au:assertTrue>
</target>
- <target name="test-return-value-false" depends="setUp" if="expect-js">
+ <target name="test-return-value-false" if="prereqs-ok">
<au:assertFalse>
- <scriptcondition language="javascript" manager="javax" value="true">
+ <scriptcondition language="javascript" manager="${script.manager}"
value="true">
false
</scriptcondition>
</au:assertFalse>