Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/alcotest-engine/core.ml
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,8 @@ module Make (P : Platform.MAKER) (M : Monad.S) = struct
let test = List.map (select_speed speed_level) test in
let+ results = perform_tests t test args in
let time = P.time () -. start_time in
let success = List.length (List.filter has_run results) in
let failures = List.length (List.filter Run_result.is_failure results) in
let success = List.length (List.filter has_run results) - failures in
if t.config#record_backtrace then
Printexc.record_backtrace initial_backtrace_status;
Pp.{ time; success; failures; errors = List.rev t.errors }
Expand Down
2 changes: 1 addition & 1 deletion src/alcotest-engine/pp.ml
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ struct
| n -> red ppf "%d failure%a!" n pp_plural n
in
Fmt.pf ppf "%a in %.3fs. %d test%a run.@," pp_failures r.failures r.time
r.success pp_plural r.success
(r.success + r.failures) pp_plural (r.success + r.failures)

let suite_results ~log_dir config ppf r =
let print_summary = (not config#compact) || r.failures > 0 in
Expand Down
40 changes: 40 additions & 0 deletions test/e2e/alcotest/failing/dune.inc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
exception_in_test
filter_all_tests
invalid_arg_in_test
json_output_with_failed
long_test_case_name
outside_runner
tail_errors_limit
Expand All @@ -28,6 +29,7 @@
exception_in_test
filter_all_tests
invalid_arg_in_test
json_output_with_failed
long_test_case_name
outside_runner
tail_errors_limit
Expand Down Expand Up @@ -415,6 +417,44 @@
(action
(diff invalid_arg_in_test-js.expected invalid_arg_in_test-js.processed)))

(rule
(target json_output_with_failed.actual)
(action
(with-outputs-to %{target}
(with-accepted-exit-codes (or 1 2 124 125)
(run %{dep:json_output_with_failed.exe})))))

(rule
(target json_output_with_failed.processed)
(action
(with-outputs-to %{target}
(run ../../strip_randomness.exe %{dep:json_output_with_failed.actual}))))

(rule
(alias runtest)
(package alcotest)
(action
(diff json_output_with_failed.expected json_output_with_failed.processed)))

(rule
(target json_output_with_failed-js.actual)
(action
(with-outputs-to %{target}
(with-accepted-exit-codes (or 1 2 124 125)
(run node %{dep:json_output_with_failed.bc.js})))))

(rule
(target json_output_with_failed-js.processed)
(action
(with-outputs-to %{target}
(run ../../strip_randomness.exe %{dep:json_output_with_failed-js.actual}))))

(rule
(alias runtest-js)
(package alcotest)
(action
(diff json_output_with_failed-js.expected json_output_with_failed-js.processed)))

(rule
(target long_test_case_name.actual)
(action
Expand Down
8 changes: 8 additions & 0 deletions test/e2e/alcotest/failing/json_output_with_failed-js.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Testing `test/e2e/alcotest/failing/json_output_with_failed.ml'.
This run has ID `<uuid>'.

{
"success": 2,
"failures": 1,
"time": <test-duration>
}
8 changes: 8 additions & 0 deletions test/e2e/alcotest/failing/json_output_with_failed.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Testing `test/e2e/alcotest/failing/json_output_with_failed.ml'.
This run has ID `<uuid>'.

{
"success": 2,
"failures": 1,
"time": <test-duration>
}
13 changes: 13 additions & 0 deletions test/e2e/alcotest/failing/json_output_with_failed.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
let () =
let open Alcotest in
let id () = () in
let always_fail () = assert false in
run ~argv:[| ""; "--json" |] __FILE__
[
( "test-a",
[
test_case "First test case" `Quick id;
test_case "Second test case always fails" `Quick always_fail;
] );
("test-b", [ test_case "Third test case" `Quick id ]);
]
Loading