Skip to content

Commit

Permalink
Merge pull request #5 from monadius/nested-groups
Browse files Browse the repository at this point in the history
  • Loading branch information
kazk authored Feb 16, 2022
2 parents ee5388a + 6fa3956 commit 8054aad
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions workspace/test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,15 @@ let cw_print_success () = print_endline "\n<PASSED::>Test passed"
let cw_print_failure err = print_endline ("\n<FAILED::>" ^ _esc_lf err)

let cw_print_error err = print_endline ("\n<ERROR::>" ^ _esc_lf err)


let cw_print_it label = print_endline ("\n<IT::>" ^ label)

let cw_print_describe label = print_endline ("\n<DESCRIBE::>" ^ label)

let cw_print_completed t =
Printf.sprintf "\n<COMPLETEDIN::>%.2f" (t *. 1000.0)
|> print_endline

let cw_print_result = function
| RSuccess _ -> cw_print_success ()
| RFailure (_, err) -> cw_print_failure err
Expand All @@ -19,20 +27,27 @@ let cw_print_test_event = function
| EStart _ | EEnd _ -> ()

let dispatch_test_case label test_case =
print_endline ("\n<IT::>" ^ label);
cw_print_it label;
let start = Unix.gettimeofday () in
perform_test cw_print_test_event test_case |> ignore;
print_endline "\n<COMPLETEDIN::>"
cw_print_completed (Unix.gettimeofday () -. start)

let rec dispatch_labeled_test label test =
match test with
| TestLabel (nested_label, nested_test) -> dispatch_labeled_test nested_label nested_test
| TestLabel (nested_label, nested_test) -> begin
cw_print_describe label;
let start = Unix.gettimeofday () in
dispatch_labeled_test nested_label nested_test;
cw_print_completed (Unix.gettimeofday () -. start)
end
| TestCase _ -> dispatch_test_case label test
| TestList tests -> begin
print_endline ("\n<DESCRIBE::>" ^ label);
cw_print_describe label;
let start = Unix.gettimeofday () in
run_tests tests;
print_endline "\n<COMPLETEDIN::>";
cw_print_completed (Unix.gettimeofday () -. start)
end

and run_test = function
| TestList tests -> "" >::: tests |> run_test
| TestCase func -> "" >:: func |> run_test
Expand Down

0 comments on commit 8054aad

Please sign in to comment.