Skip to content

Commit

Permalink
alcotest: reraise exn
Browse files Browse the repository at this point in the history
  • Loading branch information
Khady committed Dec 25, 2024
1 parent 2bf5c17 commit d17151d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions alcotest/junit_alcotest.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module A = Alcotest

external reraise : exn -> 'a = "%reraise"

type exit = unit -> unit

let push l v = l := v :: !l
Expand Down Expand Up @@ -29,10 +31,10 @@ let wrap_test ?classname handle_result (name, s, test) =
~message:"test failed"
exn_msg
|> handle_result;
raise exn
reraise exn
| Alcotest_engine__Core.Skip as exn ->
Junit.Testcase.skipped ~name ~classname ~time:0. |> handle_result;
raise exn
reraise exn
| exn ->
let exn_msg = Printexc.to_string exn in
Junit.Testcase.error
Expand All @@ -43,7 +45,7 @@ let wrap_test ?classname handle_result (name, s, test) =
~message:"test crashed"
exn_msg
|> handle_result;
raise exn
reraise exn
in
name, s, test
;;
Expand All @@ -65,7 +67,7 @@ let run_and_report ?(and_exit = true) ?package ?timestamp ?argv name tests =
run ?argv name tests;
fun () -> if and_exit then exit 0 else ()
with
| A.Test_error -> fun () -> if and_exit then exit 1 else raise A.Test_error
| A.Test_error as exn -> fun () -> if and_exit then exit 1 else reraise exn
in
Junit.Testsuite.add_testcases !testcases testsuite, exit
;;

0 comments on commit d17151d

Please sign in to comment.