File tree Expand file tree Collapse file tree 3 files changed +35
-30
lines changed Expand file tree Collapse file tree 3 files changed +35
-30
lines changed Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -95,6 +95,11 @@ let try_symlink ~link_to path =
9595 | s -> traceln "symlink %a -> %S" Path.pp path link_to
9696 | exception ex -> traceln "@[<h>%a@]" Eio.Exn.pp ex
9797
98+ let try_chmod ~perm path =
99+ match Eio.Path.chmod ~perm path with
100+ | () -> Eio.traceln "chmod %o -> %a" perm Path.pp path
101+ | exception ex -> Eio.traceln "@[<h>%a@]" Eio.Exn.pp ex
102+
98103```
99104
100105# Basic test cases
@@ -1012,3 +1017,33 @@ Exception: Failure "Simulated error".
10121017+"/" / "" = "/"
10131018- : unit = ()
10141019```
1020+ # Testing `` chmod ``
1021+
1022+ ``` ocaml
1023+ let chmod_test_directory () =
1024+ run ~clear:["test-dir"] @@ fun env ->
1025+ let cwd = Eio.Stdenv.cwd env in
1026+ let dir_path = cwd / "test-dir" in
1027+
1028+ try_mkdir dir_path;
1029+
1030+ try_chmod ~perm:0o700 dir_path;
1031+ let dir_stat = Unix.stat "test-dir" in
1032+ Printf.printf "Directory permissions after chmod 0o700: %o\n" dir_stat.st_perm;
1033+ assert (dir_stat.st_perm = 0o700);
1034+
1035+ try_chmod ~perm:0o755 dir_path;
1036+ let dir_stat = Unix.stat "test-dir" in
1037+ Printf.printf "Directory permissions after chmod 0o755: %o\n" dir_stat.st_perm;
1038+ assert (dir_stat.st_perm = 0o755);
1039+
1040+ Unix.rmdir "test-dir";
1041+ ()
1042+
1043+ let () =
1044+ Printf.printf "Running chmod tests...\n";
1045+ chmod_test_file ();
1046+ chmod_test_directory ();
1047+ Printf.printf "chmod tests completed successfully.\n"
1048+
1049+ ```
You can’t perform that action at this time.
0 commit comments