Skip to content

Commit

Permalink
Skip certain tests on Windows due to incomplete POSIX compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
ascopes committed Nov 12, 2023
1 parent 0271602 commit 8241a01
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.nio.file.attribute.PosixFilePermission;
import java.util.EnumSet;
import java.util.HashSet;
import org.opentest4j.TestAbortedException;
import org.junit.jupiter.api.io.CleanupMode;
import org.junit.jupiter.api.io.TempDir;

Expand Down Expand Up @@ -93,6 +94,8 @@ public void givenFileIsExecutable(Path path) {
perms.add(PosixFilePermission.GROUP_EXECUTE);
perms.add(PosixFilePermission.OTHERS_EXECUTE);
Files.setPosixFilePermissions(path, perms);
} catch (UnsupportedOperationException ex) {
throw new TestAbortedException("Your OS does not support setting file permissions", ex);
} catch (IOException ex) {
throw new UncheckedIOException(ex);
}
Expand All @@ -105,6 +108,8 @@ public void givenFileIsNotExecutable(Path path) {
perms.remove(PosixFilePermission.GROUP_EXECUTE);
perms.remove(PosixFilePermission.OTHERS_EXECUTE);
Files.setPosixFilePermissions(path, perms);
} catch (UnsupportedOperationException ex) {
throw new TestAbortedException("Your OS does not support setting file permissions", ex);
} catch (IOException ex) {
throw new UncheckedIOException(ex);
}
Expand All @@ -113,6 +118,8 @@ public void givenFileIsNotExecutable(Path path) {
public void givenFileOrDirectoryIsInaccessible(Path path) {
try {
Files.setPosixFilePermissions(path, EnumSet.noneOf(PosixFilePermission.class));
} catch (UnsupportedOperationException ex) {
throw new TestAbortedException("Your OS does not support setting file permissions", ex);
} catch (IOException ex) {
throw new UncheckedIOException(ex);
}
Expand Down

0 comments on commit 8241a01

Please sign in to comment.