Skip to content

Commit

Permalink
fix: PR review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
create2000 committed Oct 16, 2024
1 parent 2a589f2 commit 5e5a3e4
Showing 1 changed file with 23 additions and 11 deletions.
34 changes: 23 additions & 11 deletions lib_eio_windows/test/test_fs.ml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,16 @@ let test_append env () =
Path.save ~create:`Never ~append:true test_file "2nd-write";
Alcotest.(check string) "append" "1st-write-original2nd-write" (Path.load test_file)

let test_mkdir env () =
let cwd = Eio.Stdenv.cwd env in
try_mkdir (cwd / "subdir");
try_mkdir (cwd / "subdir\\nested");
let test_file = cwd / "subdir\\nested\\test-file" in
Path.save ~create:(`Exclusive 0o600) test_file "data";
Alcotest.(check string) "mkdir" "data" (Path.load test_file);
Unix.unlink "subdir\\nested\\test-file";
Unix.rmdir "subdir\\nested";
Unix.rmdir "subdir"

let test_symlink env () =
(*
Expand Down Expand Up @@ -218,17 +228,6 @@ let try_failing_unlink env () =
in
()

let test_mkdir env () =
let cwd = Eio.Stdenv.cwd env in
try_mkdir (cwd / "subdir");
try_mkdir (cwd / "subdir\\nested");
let test_file = cwd / "subdir\\nested\\test-file" in
Path.save ~create:(`Exclusive 0o600) test_file "data";
Alcotest.(check string) "mkdir" "data" (Path.load test_file);
Unix.unlink "subdir\\nested\\test-file";
Unix.rmdir "subdir\\nested";
Unix.rmdir "subdir"

let test_remove_dir env () =
let cwd = Eio.Stdenv.cwd env in
try_mkdir (cwd / "d1");
Expand All @@ -251,6 +250,19 @@ let test_remove_dir env () =
in
()

let test_mkdirs env () =
let cwd = Eio.Stdenv.cwd env in
let nested = cwd / "subdir1" / "subdir2" / "subdir3" in
try_mkdirs nested;
let one_more = Path.(nested / "subdir4") in
(try
try_mkdirs one_more
with Eio.Io (Eio.Fs.E (Already_exists _), _) -> ());
try_mkdirs ~exists_ok:true one_more;
try
try_mkdirs (cwd / ".." / "outside")
with Eio.Io (Eio.Fs.E (Permission_denied _), _) -> ()

let tests env = [
"create-write-read", `Quick, test_create_and_read env;
"cwd-abs-path", `Quick, test_cwd_no_access_abs env;
Expand Down

0 comments on commit 5e5a3e4

Please sign in to comment.