Skip to content

Commit e266af5

Browse files
remove test-only primitive
1 parent ba710d1 commit e266af5

File tree

4 files changed

+6
-52
lines changed

4 files changed

+6
-52
lines changed

src/unix/lwt_unix.cppo.ml

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -247,22 +247,7 @@ let self_result job =
247247
with exn when Lwt.Exception_filter.run exn ->
248248
Result.Error exn
249249

250-
let in_retention_test = ref false
251-
252-
let retained o =
253-
let retained = ref true in
254-
Gc.finalise (fun _ ->
255-
if !in_retention_test then
256-
retained := false)
257-
o;
258-
in_retention_test := true;
259-
retained
260-
261250
let run_job ?async_method job =
262-
if !in_retention_test then begin
263-
Gc.full_major ();
264-
in_retention_test := false
265-
end;
266251
let async_method = choose_async_method async_method in
267252
if async_method = Async_none then
268253
try

src/unix/lwt_unix.cppo.mli

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1581,9 +1581,6 @@ val somaxconn : unit -> int
15811581
[@@ocaml.deprecated " This is an internal function."]
15821582
(** @deprecated This is for internal use only. *)
15831583

1584-
val retained : 'a -> bool ref
1585-
(** @deprecated Used for testing. *)
1586-
15871584
val read_bigarray :
15881585
string -> file_descr -> IO_vectors._bigarray -> int -> int -> int Lwt.t
15891586
[@@ocaml.deprecated " This is an internal function."]

test/unix/test_lwt_bytes.ml

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -597,23 +597,6 @@ let suite = suite "lwt_bytes" [
597597
Lwt.return check
598598
end;
599599

600-
test "read: buffer retention" ~sequential:true begin fun () ->
601-
let buffer = Lwt_bytes.create 3 in
602-
603-
let read_fd, write_fd = Lwt_unix.pipe ~cloexec:true () in
604-
Lwt_unix.set_blocking read_fd true;
605-
606-
Lwt_unix.write_string write_fd "foo" 0 3 >>= fun _ ->
607-
608-
let retained = Lwt_unix.retained buffer in
609-
Lwt_bytes.read read_fd buffer 0 3 >>= fun _ ->
610-
611-
Lwt_unix.close write_fd >>= fun () ->
612-
Lwt_unix.close read_fd >|= fun () ->
613-
614-
!retained
615-
end;
616-
617600
test "bytes write" begin fun () ->
618601
let test_file = "bytes_io_data_write" in
619602
Lwt_unix.openfile test_file [O_RDWR;O_TRUNC; O_CREAT] 0o666
@@ -634,21 +617,6 @@ let suite = suite "lwt_bytes" [
634617
Lwt.return check
635618
end;
636619

637-
test "write: buffer retention" ~sequential:true begin fun () ->
638-
let buffer = Lwt_bytes.create 3 in
639-
640-
let read_fd, write_fd = Lwt_unix.pipe ~cloexec:true () in
641-
Lwt_unix.set_blocking write_fd true;
642-
643-
let retained = Lwt_unix.retained buffer in
644-
Lwt_bytes.write write_fd buffer 0 3 >>= fun _ ->
645-
646-
Lwt_unix.close write_fd >>= fun () ->
647-
Lwt_unix.close read_fd >|= fun () ->
648-
649-
!retained
650-
end;
651-
652620
test "bytes recv" ~only_if:(fun () -> not Sys.win32) begin fun () ->
653621
let buf = gen_buf 6 in
654622
let server_logic socket =

test/unix/test_lwt_unix.ml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -453,12 +453,14 @@ let readv_tests =
453453

454454
Lwt_unix.write_string write_fd "foo" 0 3 >>= fun _ ->
455455

456-
let retained = Lwt_unix.retained io_vectors in
456+
let retained = ref true in
457+
Gc.finalise (fun _ -> retained := false) io_vectors;
457458
Lwt_unix.readv read_fd io_vectors >>= fun _ ->
458459

459460
Lwt_unix.close write_fd >>= fun () ->
460461
Lwt_unix.close read_fd >|= fun () ->
461462

463+
Gc.full_major ();
462464
!retained
463465
end;
464466

@@ -621,12 +623,14 @@ let writev_tests =
621623
let read_fd, write_fd = Lwt_unix.pipe ~cloexec:true () in
622624
Lwt_unix.set_blocking write_fd true;
623625

624-
let retained = Lwt_unix.retained io_vectors in
626+
let retained = ref true in
627+
Gc.finalise (fun _ -> retained := false) io_vectors;
625628
Lwt_unix.writev write_fd io_vectors >>= fun _ ->
626629

627630
Lwt_unix.close write_fd >>= fun () ->
628631
Lwt_unix.close read_fd >|= fun () ->
629632

633+
Gc.full_major ();
630634
!retained
631635
end;
632636

0 commit comments

Comments
 (0)