Skip to content

Commit a68ed39

Browse files
committed
Add duration to <COMPLETEDIN::>
1 parent 8a50600 commit a68ed39

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

workspace/test.ml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,15 @@ let cw_print_success () = print_endline "\n<PASSED::>Test passed"
77
let cw_print_failure err = print_endline ("\n<FAILED::>" ^ _esc_lf err)
88

99
let cw_print_error err = print_endline ("\n<ERROR::>" ^ _esc_lf err)
10-
10+
11+
let cw_print_it label = print_endline ("\n<IT::>" ^ label)
12+
13+
let cw_print_describe label = print_endline ("\n<DESCRIBE::>" ^ label)
14+
15+
let cw_print_completed t =
16+
Printf.sprintf "\n<COMPLETEDIN::>%.2f" (t *. 1000.0)
17+
|> print_endline
18+
1119
let cw_print_result = function
1220
| RSuccess _ -> cw_print_success ()
1321
| RFailure (_, err) -> cw_print_failure err
@@ -19,18 +27,20 @@ let cw_print_test_event = function
1927
| EStart _ | EEnd _ -> ()
2028

2129
let dispatch_test_case label test_case =
22-
print_endline ("\n<IT::>" ^ label);
30+
cw_print_it label;
31+
let start = Unix.gettimeofday () in
2332
perform_test cw_print_test_event test_case |> ignore;
24-
print_endline "\n<COMPLETEDIN::>"
33+
cw_print_completed (Unix.gettimeofday () -. start)
2534

2635
let rec dispatch_labeled_test label test =
2736
match test with
2837
| TestLabel (nested_label, nested_test) -> dispatch_labeled_test nested_label nested_test
2938
| TestCase _ -> dispatch_test_case label test
3039
| TestList tests -> begin
31-
print_endline ("\n<DESCRIBE::>" ^ label);
40+
cw_print_describe label;
41+
let start = Unix.gettimeofday () in
3242
run_tests tests;
33-
print_endline "\n<COMPLETEDIN::>";
43+
cw_print_completed (Unix.gettimeofday () -. start)
3444
end
3545

3646
and run_test = function

0 commit comments

Comments
 (0)