Bump version to 19.1.0-rc3
[llvm-project.git] / llvm / test / Bindings / OCaml / Utils / Testsuite.ml
blob7a8955a7a2fd842d448a2657d79b3d6c6b05fd31
1 (* Tiny unit test framework - really just to help find which line is busted *)
2 let exit_status = ref 0
4 let suite_name = ref ""
6 let group_name = ref ""
8 let case_num = ref 0
10 let print_checkpoints = false
12 let group name =
13 group_name := !suite_name ^ "/" ^ name;
14 case_num := 0;
15 if print_checkpoints then prerr_endline (" " ^ name ^ "...")
17 let insist ?(exit_on_fail = false) cond =
18 incr case_num;
19 if not cond then exit_status := 10;
20 ( match (print_checkpoints, cond) with
21 | false, true -> ()
22 | false, false ->
23 prerr_endline
24 ( "FAILED: " ^ !suite_name ^ "/" ^ !group_name ^ " #"
25 ^ string_of_int !case_num )
26 | true, true -> prerr_endline (" " ^ string_of_int !case_num)
27 | true, false -> prerr_endline (" " ^ string_of_int !case_num ^ " FAIL") );
28 if exit_on_fail && not cond then exit !exit_status else ()
30 let suite name f =
31 suite_name := name;
32 if print_checkpoints then prerr_endline (name ^ ":");
33 f ()