@@ -86,9 +86,9 @@ let thread name f =
86
86
let ctx = with_o1trace ~name ctx in
87
87
match Scheduler. within_context ctx f with
88
88
| Error () ->
89
- (* Scheduler.within_context will send the actual error to the parent monitor asynchronously.
90
- * At this point, the thread has crashed, so we just return a Deferred that will never resolve *)
91
- Deferred. create ( Fn. const () )
89
+ failwithf
90
+ " timing task `%s` failed, exception reported to parent monitor " name
91
+ ( )
92
92
| Ok x ->
93
93
x )
94
94
@@ -102,12 +102,11 @@ let sync_thread name f =
102
102
let start_time = Time_ns. now () in
103
103
let ctx = Scheduler. current_execution_context () in
104
104
let ctx = with_o1trace ~name ctx in
105
- match
106
- Scheduler.Private. with_execution_context (Scheduler.Private. t () ) ctx
107
- ~f: (fun () -> Result. try_with f)
108
- with
109
- | Error exn ->
110
- Exn. reraise exn " exception caught by O1trace.sync_thread"
105
+ match Scheduler. within_context ctx f with
106
+ | Error () ->
107
+ failwithf
108
+ " sync timing task `%s` failed, exception reported to parent monitor"
109
+ name ()
111
110
| Ok result ->
112
111
let elapsed_time = Time_ns. abs_diff (Time_ns. now () ) start_time in
113
112
on_job_exit' fiber elapsed_time ;
@@ -126,12 +125,6 @@ let () =
126
125
127
126
let % test_module " thread tests" =
128
127
( module struct
129
- exception Test_exn
130
-
131
- let is_test_exn exn =
132
- (* there isn't a great way to compare the exn to the one that was thrown due to how async mangles the exn, so we do this instead *)
133
- String. is_substring (Exn. to_string exn ) ~substring: " (Test_exn)"
134
-
135
128
let child_of n =
136
129
match
137
130
let prev_sync_fiber = ! current_sync_fiber in
@@ -221,31 +214,5 @@ let%test_module "thread tests" =
221
214
Deferred. unit ) ) ) ;
222
215
Deferred. unit ) ) )
223
216
224
- let % test_unit " exceptions are handled properly when raised in first cycle \
225
- of a thread" =
226
- test (fun stop ->
227
- match % map
228
- Monitor. try_with (fun () ->
229
- thread " test" (fun () -> raise Test_exn ) )
230
- with
231
- | Ok _ ->
232
- failwith " expected a failure"
233
- | Error exn ->
234
- assert (is_test_exn exn ) ;
235
- stop () )
236
-
237
- let % test_unit " exceptions are handled properly when raised in first cycle \
238
- of a sync_thread" =
239
- test (fun stop ->
240
- match % map
241
- Monitor. try_with (fun () ->
242
- sync_thread " test" (fun () -> raise Test_exn ) )
243
- with
244
- | Ok _ ->
245
- failwith " expected a failure"
246
- | Error exn ->
247
- assert (is_test_exn exn ) ;
248
- stop () )
249
-
250
217
(* TODO: recursion tests *)
251
218
end )
0 commit comments