From 0f65d34132538947b801f7cd4e74233e9465ebb5 Mon Sep 17 00:00:00 2001 From: Anthony Onah Date: Sun, 3 Nov 2024 15:49:45 +0100 Subject: [PATCH 1/6] skipping test --- lib_eio_linux/tests/test.ml | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib_eio_linux/tests/test.ml b/lib_eio_linux/tests/test.ml index 238f909a..9b2efb4e 100644 --- a/lib_eio_linux/tests/test.ml +++ b/lib_eio_linux/tests/test.ml @@ -1,3 +1,7 @@ +exception Skip_test of string +let skip _stdenv = + raise (Skip_test "io_uring not available in Docker") + open Eio.Std module Trace = Eio.Private.Trace @@ -19,7 +23,7 @@ let read_one_byte ~sw r = ) let test_poll_add () = - Eio_linux.run @@ fun _stdenv -> + Eio_linux.run ~fallback:skip (fun _stdenv -> Switch.run @@ fun sw -> let r, w = Eio_unix.pipe sw in let thread = read_one_byte ~sw r in @@ -32,10 +36,10 @@ let test_poll_add () = assert (sent = 1); let result = Promise.await_exn thread in Alcotest.(check string) "Received data" "!" result - +) let test_poll_add_busy () = - Eio_linux.run ~queue_depth:2 @@ fun _stdenv -> - Switch.run @@ fun sw -> + Eio_linux.run ~queue_depth:2 ~fallback:skip (fun _stdenv -> + Switch.run @@ fun sw -> let r, w = Eio_unix.pipe sw in let a = read_one_byte ~sw r in let b = read_one_byte ~sw r in @@ -50,7 +54,7 @@ let test_poll_add_busy () = Alcotest.(check string) "Received data" "!" a; let b = Promise.await_exn b in Alcotest.(check string) "Received data" "!" b - +) (* Write a string to a pipe and read it out again. *) let test_copy () = Eio_linux.run ~queue_depth:3 @@ fun _stdenv -> @@ -259,4 +263,4 @@ let () = test_case "signal_race" `Quick test_signal_race; test_case "alloc-fixed-or-wait" `Quick test_alloc_fixed_or_wait; ]; - ] + ] \ No newline at end of file From d55819f018734e8a3764400d8bed2f87a52ba706 Mon Sep 17 00:00:00 2001 From: Patrick Ferris Date: Sun, 6 Oct 2024 11:28:52 +0100 Subject: [PATCH 2/6] Add advice about using AI for code generation --- HACKING.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/HACKING.md b/HACKING.md index 906d8772..13aa6799 100644 --- a/HACKING.md +++ b/HACKING.md @@ -135,4 +135,15 @@ Try to avoid making unnecessary changes; this makes review harder and clutters u `ocamlformat` may be useful to get badly messed up code to a baseline unformatted state, from which human formatting can be added where needed. +## AI-generated Code + +Contributing to Eio should not be done _solely_ using "AI tools" such as ChatGPT. This is for a few reasons: + +1. **It obfuscates how you think**. Purely AI-generated code tells us little about how you think and the problems you might be having. This makes it harder to provide good feedback on PRs and issues. +2. **It is often more work to review**. Particularly for the OCaml ecosystem and libraries like Eio, it seems that these tools are not very good and generate a lot of believable code that is in actual fact completely wrong. PR comments and the code submitted with them can say completely different things. +3. **It is a grey area for licensing**. Models like ChatGPT have been trained on lots of code with different licenses and has been known to simply copy code as an answer to a prompt. We would like to avoid this headache as best we can. + +Use AI tools, if you wish, to help you understand OCaml and Eio. Do not offload all of the work of a PR or a comment to these tools. + [dscheck]: https://github.com/ocaml-multicore/dscheck + From f245e67063d011351f5a8f210d73f01094c12efc Mon Sep 17 00:00:00 2001 From: Patrick Ferris Date: Thu, 17 Oct 2024 19:43:32 +0100 Subject: [PATCH 3/6] Make fork_action.h a public_header --- lib_eio/unix/dune | 1 + 1 file changed, 1 insertion(+) diff --git a/lib_eio/unix/dune b/lib_eio/unix/dune index d067e815..e8afa88d 100644 --- a/lib_eio/unix/dune +++ b/lib_eio/unix/dune @@ -1,6 +1,7 @@ (library (name eio_unix) (public_name eio.unix) + (public_headers include/fork_action.h) (foreign_stubs (language c) (include_dirs include) From 4254b41520e3b21a320c0e4e13407c07cba1aa7a Mon Sep 17 00:00:00 2001 From: Onah_Anthony <124398763+create2000@users.noreply.github.com> Date: Mon, 21 Oct 2024 15:42:36 +0100 Subject: [PATCH 4/6] Check if windows has_symlink for tests (#771) Symlinking is privileged operation on Windows, so we check if the running user can make symlinks before running tests that require them. --- lib_eio_windows/test/test_fs.ml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib_eio_windows/test/test_fs.ml b/lib_eio_windows/test/test_fs.ml index 75435927..9140d64d 100755 --- a/lib_eio_windows/test/test_fs.ml +++ b/lib_eio_windows/test/test_fs.ml @@ -158,6 +158,9 @@ let test_symlink env () = Unix.mkdir "another" 0o700; print_endline @@ Unix.realpath "to-subdir" |} *) + if not (Unix.has_symlink ()) then + Printf.printf "Skipping test_symlink on systems that don't support symlinks.\n" + else let cwd = Eio.Stdenv.cwd env in try_mkdir (cwd / "sandbox"); Unix.symlink ~to_dir:true ".." "sandbox\\to-root"; @@ -277,4 +280,5 @@ let tests env = [ "unlink", `Quick, test_unlink env; "failing-unlink", `Quick, try_failing_unlink env; "rmdir", `Quick, test_remove_dir env; + "mkdirs", `Quick, test_mkdirs env; ] \ No newline at end of file From 121fa0588a06233db15af2bd700ce77bc0860c83 Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Sat, 16 Nov 2024 10:12:59 +0000 Subject: [PATCH 5/6] Preserve backtraces in fork_daemon and fork_promise_exn If the fiber fails, record the backtrace when failing the switch. `fork` itself already did this, but `fork_daemon` and `fork_promise_exn` didn't. --- lib_eio/core/fiber.ml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib_eio/core/fiber.ml b/lib_eio/core/fiber.ml index 3113e8cc..dbf6cfd4 100644 --- a/lib_eio/core/fiber.ml +++ b/lib_eio/core/fiber.ml @@ -39,7 +39,8 @@ let fork_daemon ~sw f = (* The daemon was cancelled because all non-daemon fibers are finished. *) () | exception ex -> - Switch.fail sw ex; (* The [with_daemon] ensures this will succeed *) + let bt = Printexc.get_raw_backtrace () in + Switch.fail ~bt sw ex; (* The [with_daemon] ensures this will succeed *) ) (* else the fiber should report the error to [sw], but [sw] is failed anyway *) let fork_promise ~sw f = @@ -65,7 +66,8 @@ let fork_promise_exn ~sw f = match Switch.with_op sw f with | x -> Promise.resolve r x | exception ex -> - Switch.fail sw ex (* The [with_op] ensures this will succeed *) + let bt = Printexc.get_raw_backtrace () in + Switch.fail ~bt sw ex (* The [with_op] ensures this will succeed *) ); p From 5637e21f4ba5484c708cbf4a8f7b6c06ed16f768 Mon Sep 17 00:00:00 2001 From: Anthony Onah Date: Tue, 19 Nov 2024 22:03:12 +0100 Subject: [PATCH 6/6] Add Skipping feature --- lib_eio_linux/tests/test.ml | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/lib_eio_linux/tests/test.ml b/lib_eio_linux/tests/test.ml index 9b2efb4e..387c0b27 100644 --- a/lib_eio_linux/tests/test.ml +++ b/lib_eio_linux/tests/test.ml @@ -4,6 +4,16 @@ let skip _stdenv = open Eio.Std +let skip_io_uring msg = + Eio.traceln "Skipping test: %s" msg; + Alcotest.skip () + + let handle_fallback = function + | `Msg msg -> + Eio.traceln "Fallback triggered with message: %s" msg; + skip_io_uring msg + + module Trace = Eio.Private.Trace let () = @@ -23,7 +33,7 @@ let read_one_byte ~sw r = ) let test_poll_add () = - Eio_linux.run ~fallback:skip (fun _stdenv -> + Eio_linux.run @@ fun _stdenv -> Switch.run @@ fun sw -> let r, w = Eio_unix.pipe sw in let thread = read_one_byte ~sw r in @@ -38,8 +48,8 @@ let test_poll_add () = Alcotest.(check string) "Received data" "!" result ) let test_poll_add_busy () = - Eio_linux.run ~queue_depth:2 ~fallback:skip (fun _stdenv -> - Switch.run @@ fun sw -> + Eio_linux.run ~queue_depth:2 @@ fun _stdenv -> + Switch.run @@ fun sw -> let r, w = Eio_unix.pipe sw in let a = read_one_byte ~sw r in let b = read_one_byte ~sw r in