Skip to content

Commit

Permalink
Avoid raw Fiber.spawn in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
polytypic committed Jul 16, 2024
1 parent bed8290 commit f171b50
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion test/dune
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
(test
(name test_schedulers)
(modules test_schedulers)
(libraries picos test_scheduler alcotest))
(libraries picos picos.structured test_scheduler alcotest))

;;

Expand Down
12 changes: 4 additions & 8 deletions test/test_schedulers.ml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
open Picos
open Picos_structured

let exit_exn_bt = Exn_bt.get_callstack 0 Exit

Expand All @@ -10,15 +11,10 @@ let test_current () =
Test_scheduler.run ~max_domains:2 @@ fun () ->
let fiber_parent = Fiber.current () in
let fiber_child = ref fiber_parent in
let computation = Computation.create () in
Fiber.spawn ~forbid:false computation
[
(fun () ->
Computation.cancel computation exit_exn_bt;
fiber_child := Fiber.current ());
];
Bundle.join_after @@ fun bundle ->
Bundle.fork bundle (fun () -> fiber_child := Fiber.current ());
while fiber_parent == !fiber_child do
Fiber.yield ()
Control.yield ()
done

let test_cancel_after_basic () =
Expand Down

0 comments on commit f171b50

Please sign in to comment.