This is an automated email from the ASF dual-hosted git repository.

jaikiran pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ant.git

commit 54350f7e967f965169a07f65ec925b621cef231d
Author: Jaikiran Pai <[email protected]>
AuthorDate: Tue Jul 1 18:45:20 2025 +0530

    antunit-tests - mark files as writable before attempting to delete in our 
antunit tests' tearDown()
    
    Some of these antunit tests used to create read-only files and then 
tearDown() would delete the files and the directories containing them.
    Starting Java 25, after https://bugs.openjdk.org/browse/JDK-8355954 bug 
fix, read-only files on Windows cannot be deleted.
    The tearDown() method in these tests has now been updated to reset the 
permission on these test generated files to writable before deleting them.
---
 src/tests/antunit/antunit-base.xml | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/src/tests/antunit/antunit-base.xml 
b/src/tests/antunit/antunit-base.xml
index 48226b8f6..ec7ec745d 100644
--- a/src/tests/antunit/antunit-base.xml
+++ b/src/tests/antunit/antunit-base.xml
@@ -35,7 +35,23 @@
     <equals arg1="${build.sysclasspath}" arg2="only"/>
   </condition>
 
-  <target name="tearDown">
+  <condition property="windows_os">
+    <os family="windows"/>
+  </condition>
+  <target name="markFilesWritable" if="windows_os">
+    <!--
+      some tests create read-only files in input/output directory.
+      Windows doesn't allow deleting read-only files, so we reset
+      the permissions on those files to writable before tearDown
+      can delete the input/output directory.
+    -->
+    <setpermissions mode="666" nonPosixMode="tryDosOrFail">
+      <fileset dir="${input}" erroronmissingdir="false"/>
+      <fileset dir="${output}" erroronmissingdir="false"/>
+    </setpermissions>
+  </target>
+
+  <target name="tearDown" depends="markFilesWritable">
     <delete dir="${input}"/>
     <delete dir="${output}"/>
     <delete dir="${resources}"/>

Reply via email to