This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-io.git
commit eea124865a1fc6920fe26f2c587e2da6e09d2edb Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Sun Mar 24 10:31:07 2024 -0400 Passes on macOS, fails on Linux and Windows with AccessDeniedException. - Better comment - Bullet-proof old test for re-runs --- src/test/java/org/apache/commons/io/FileUtilsTest.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/test/java/org/apache/commons/io/FileUtilsTest.java b/src/test/java/org/apache/commons/io/FileUtilsTest.java index ccad1b10d..6c6e5cc9b 100644 --- a/src/test/java/org/apache/commons/io/FileUtilsTest.java +++ b/src/test/java/org/apache/commons/io/FileUtilsTest.java @@ -93,6 +93,8 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.condition.EnabledIf; +import org.junit.jupiter.api.condition.EnabledOnOs; +import org.junit.jupiter.api.condition.OS; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; @@ -1663,7 +1665,11 @@ public class FileUtilsTest extends AbstractTempDirTest { assertFalse(testDirectory.exists(), "TestDirectory must not exist"); } + /** + * TODO Passes on macOS, fails on Linux and Windows with AccessDeniedException. + */ @Test + @EnabledOnOs(value = OS.MAC) public void testForceDeleteReadOnlyDirectory() throws Exception { try (TempDirectory destDir = TempDirectory.create("dir-"); TempFile destination = TempFile.create(destDir, "test-", ".txt")) { @@ -1686,6 +1692,7 @@ public class FileUtilsTest extends AbstractTempDirTest { assertTrue(dir.canRead()); assertFalse(dir.canWrite()); assertTrue(dir.exists(), "File doesn't exist to delete"); + // TODO Passes on macOS, fails on Linux and Windows with AccessDeniedException. FileUtils.forceDelete(dir); assertFalse(destination.exists(), "Check deletion"); assertFalse(dir.exists(), "Check deletion"); @@ -1723,7 +1730,7 @@ public class FileUtilsTest extends AbstractTempDirTest { assertTrue(file.setWritable(false)); assertFalse(file.canWrite()); assertTrue(file.canRead()); - // sanity check that File.delete() deletes read-only files. + // sanity check that File.delete() deletes unwritable files. assertTrue(file.delete()); } try (TempFile destination = TempFile.create("test-", ".txt")) { @@ -1832,6 +1839,7 @@ public class FileUtilsTest extends AbstractTempDirTest { @Test public void testIO276() throws Exception { final File dir = new File("target", "IO276"); + Files.deleteIfExists(dir.toPath()); assertTrue(dir.mkdirs(), dir + " should not be present"); final File file = new File(dir, "IO276.txt"); assertTrue(file.createNewFile(), file + " should not be present");