diff --git a/CHANGES.md b/CHANGES.md index e2a2732c..cf38b2ed 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -5,6 +5,8 @@ - Fix compatibility with `fmt.0.8.8+dune` by adding a missing `fmt` dependency in `alcotest`'s dune file (#266, @NathanReb) +- Only show "in progress" lines when writing to a TTY. (#267, @CraigFe) + ### 1.2.1 (2020-07-15) - Surround pretty-printed diffs with quotes to make trailing whitespace more diff --git a/src/alcotest-engine/core.ml b/src/alcotest-engine/core.ml index 2a1dd74f..d0fc36f2 100644 --- a/src/alcotest-engine/core.ml +++ b/src/alcotest-engine/core.ml @@ -207,12 +207,12 @@ struct let log_dir = log_dir ~via_symlink:true t |> maybe_collapse_home in Pp.suite_results ~verbose ~show_errors ~json ~compact ~log_dir - let pp_event ~prior_error ~tests_so_far t = + let pp_event ~isatty ~prior_error ~tests_so_far t = let selector_on_failure = (not prior_error) && not (t.verbose || t.show_errors) in if not t.json then - Pp.event ~compact:t.compact ~max_label:t.max_label + Pp.event ~isatty ~compact:t.compact ~max_label:t.max_label ~doc_of_test_name:(Suite.doc_of_test_name t.suite) ~selector_on_failure ~tests_so_far else Fmt.nop @@ -282,9 +282,12 @@ struct let perform_test t args { tests_so_far; prior_error } suite = let open Suite in let test = suite.fn in - let pp_event = pp_event t ~prior_error ~tests_so_far in + let print_event = + pp_event t ~prior_error ~tests_so_far ~isatty:(P.stdout_isatty ()) + Fmt.stdout + in M.return () >>= fun () -> - pp_event Fmt.stdout (`Start suite.name); + print_event (`Start suite.name); Fmt.(flush stdout) () (* Show event before any test stderr *); test args >|= fun result -> (* Store errors *) @@ -306,7 +309,7 @@ struct (* Show any remaining test output before the event *) Fmt.(flush stdout ()); Fmt.(flush stderr ()); - pp_event Fmt.stdout (`Result (suite.name, result)); + print_event (`Result (suite.name, result)); let state = { tests_so_far = tests_so_far + 1; prior_error = errored || prior_error } in diff --git a/src/alcotest-engine/platform.ml b/src/alcotest-engine/platform.ml index c6215bfa..ac4bcf35 100644 --- a/src/alcotest-engine/platform.ml +++ b/src/alcotest-engine/platform.ml @@ -1,18 +1,38 @@ module type S = sig val time : unit -> float + (** [time ()] returns the current timestamp, used to measure the duration of a + testrun. *) val getcwd : unit -> string + (** [getcwd ()] returns the current working directory. *) val prepare : base:string -> dir:string -> name:string -> unit + (** [prepare ~base ~dir ~name] is called before test suite execution. [base] + is the parent of the log directory, [dir] the log directory (including + unique testrun ID), and [name] is the test name. On Unix, this function + creates the log directory [dir] for the test output, and sets up the + symlink [latest] to the latest result. *) type 'a promise + (** The type of monadic actions handled by {!with_redirect}. *) + + val stdout_isatty : unit -> bool + (** Return [true] if standard output refers to a terminal or console window, + [false] otherwise. *) val with_redirect : string -> (unit -> 'a promise) -> 'a promise + (** [with_redirect output_file f] is called for each test. On Unix, it it + deals with redirection of standard streams to the [output_file]. The + implementation of [with_redirect] has to make sure to call [f] in order to + run the test case. *) val setup_std_outputs : ?style_renderer:Fmt.style_renderer -> ?utf_8:bool -> unit -> unit + (** [setup_std_outputs ~style_renderer ~utf_8 ()] is called at startup of + alcotest and sets up the standard streams for colored output. *) val home_directory : unit -> (string, [ `Msg of string ]) result + (** [home_directory ()] is the current user's HOME directory, if it exists. *) end module type MAKER = functor (M : Monad.S) -> S with type 'a promise := 'a M.t diff --git a/src/alcotest-engine/platform.mli b/src/alcotest-engine/platform.mli deleted file mode 100644 index 67a69ec1..00000000 --- a/src/alcotest-engine/platform.mli +++ /dev/null @@ -1,34 +0,0 @@ -module type S = sig - val time : unit -> float - (** [time ()] returns the current timestamp, used to measure the duration of a - testrun. *) - - val getcwd : unit -> string - (** [getcwd ()] returns the current working directory. *) - - val prepare : base:string -> dir:string -> name:string -> unit - (** [prepare ~base ~dir ~name] is called before test suite execution. [base] - is the parent of the log directory, [dir] the log directory (including - unique testrun ID), and [name] is the test name. On Unix, this function - creates the log directory [dir] for the test output, and sets up the - symlink [latest] to the latest result. *) - - type 'a promise - (** The type of monadic actions handled by {!with_redirect}. *) - - val with_redirect : string -> (unit -> 'a promise) -> 'a promise - (** [with_redirect output_file f] is called for each test. On Unix, it it - deals with redirection of standard streams to the [output_file]. The - implementation of [with_redirect] has to make sure to call [f] in order to - run the test case. *) - - val setup_std_outputs : - ?style_renderer:Fmt.style_renderer -> ?utf_8:bool -> unit -> unit - (** [setup_std_outputs ~style_renderer ~utf_8 ()] is called at startup of - alcotest and sets up the standard streams for colored output. *) - - val home_directory : unit -> (string, [ `Msg of string ]) result - (** [home_directory ()] is the current user's HOME directory, if it exists. *) -end - -module type MAKER = functor (M : Monad.S) -> S with type 'a promise := 'a M.t diff --git a/src/alcotest-engine/pp.ml b/src/alcotest-engine/pp.ml index 9f91eb2a..a977d290 100644 --- a/src/alcotest-engine/pp.ml +++ b/src/alcotest-engine/pp.ml @@ -122,24 +122,25 @@ let event_line ~max_label ~doc_of_test_name ppf = function (info ~max_label ~doc_of_test_name) ppf p | _ -> assert false -let event ~compact ~max_label ~doc_of_test_name ~selector_on_failure +let event ~isatty ~compact ~max_label ~doc_of_test_name ~selector_on_failure ~tests_so_far ppf event = - match (compact, event) with - | true, `Start _ -> () - | true, `Result (_, r) -> - pp_result_compact ppf r; - (* Wrap compact output to terminal width manually *) - if (tests_so_far + 1) mod terminal_width () = 0 then - Format.pp_force_newline ppf (); - () - | false, `Start tname -> + match (compact, isatty, event) with + | true, _, `Start _ | _, false, `Start _ -> () + | false, true, `Start tname -> Fmt.( left_padding ~with_selector:false ++ const (left left_c yellow_s) "..." ++ const (info ~max_label ~doc_of_test_name) tname) ppf () - | false, `Result (tname, r) -> - Fmt.pf ppf "\r%a@," + | true, _, `Result (_, r) -> + pp_result_compact ppf r; + (* Wrap compact output to terminal width manually *) + if (tests_so_far + 1) mod terminal_width () = 0 then + Format.pp_force_newline ppf (); + () + | false, _, `Result (tname, r) -> + if isatty then Fmt.pf ppf "\r"; + Fmt.pf ppf "%a@," (pp_result_full ~max_label ~doc_of_test_name ~selector_on_failure) (tname, r) diff --git a/src/alcotest-engine/pp.mli b/src/alcotest-engine/pp.mli index d123824b..1160725f 100644 --- a/src/alcotest-engine/pp.mli +++ b/src/alcotest-engine/pp.mli @@ -41,6 +41,7 @@ val event_line : [ `Result of Test_name.t * [< Run_result.t ] | `Start of Test_name.t ] Fmt.t val event : + isatty:bool -> compact:bool -> max_label:int -> doc_of_test_name:(Test_name.t -> string) -> diff --git a/src/alcotest-mirage/alcotest_mirage.ml b/src/alcotest-mirage/alcotest_mirage.ml index 31cebf40..64418999 100644 --- a/src/alcotest-mirage/alcotest_mirage.ml +++ b/src/alcotest-mirage/alcotest_mirage.ml @@ -6,6 +6,8 @@ module Make (C : Mirage_clock.MCLOCK) = struct let prepare ~base:_ ~dir:_ ~name:_ = () + let stdout_isatty () = true + let with_redirect _ fn = fn () let setup_std_outputs ?style_renderer:_ ?utf_8:_ () = () diff --git a/src/alcotest/alcotest.ml b/src/alcotest/alcotest.ml index eaa7ddcb..396ad10c 100644 --- a/src/alcotest/alcotest.ml +++ b/src/alcotest/alcotest.ml @@ -73,6 +73,8 @@ module Unix (M : Alcotest_engine.Monad.S) = struct else if not (Sys.is_directory dir) then Fmt.failwith "exists but is not a directory: %S" dir + let stdout_isatty () = Unix.(isatty stdout) + let with_redirect file fn = M.return () >>= fun () -> Fmt.(flush stdout) (); diff --git a/test/e2e/alcotest-lwt/failing/async_failure.expected b/test/e2e/alcotest-lwt/failing/async_failure.expected index 91f21290..2a64acb9 100644 --- a/test/e2e/alcotest-lwt/failing/async_failure.expected +++ b/test/e2e/alcotest-lwt/failing/async_failure.expected @@ -1,8 +1,8 @@ Testing `foo'. This run has ID `'. - ... all 0 one. > [FAIL] all 0 one. - ... all 1 two. [OK] all 1 two. +> [FAIL] all 0 one. + [OK] all 1 two. ┌──────────────────────────────────────────────────────────────────────────────┐ │ [FAIL] all 0 one. │ diff --git a/test/e2e/alcotest-lwt/failing/fail_with.expected b/test/e2e/alcotest-lwt/failing/fail_with.expected index 350f8a92..466a4a2d 100644 --- a/test/e2e/alcotest-lwt/failing/fail_with.expected +++ b/test/e2e/alcotest-lwt/failing/fail_with.expected @@ -1,8 +1,8 @@ Testing `foo'. This run has ID `'. - ... all 0 one. > [FAIL] all 0 one. - ... all 1 two. [OK] all 1 two. +> [FAIL] all 0 one. + [OK] all 1 two. ┌──────────────────────────────────────────────────────────────────────────────┐ │ [FAIL] all 0 one. │ diff --git a/test/e2e/alcotest/failing/check_basic.expected b/test/e2e/alcotest/failing/check_basic.expected index 1fbc9171..7e706f6d 100644 --- a/test/e2e/alcotest/failing/check_basic.expected +++ b/test/e2e/alcotest/failing/check_basic.expected @@ -1,32 +1,32 @@ Testing `check_basic'. This run has ID `'. - ... different basic 0 bool.ASSERT bool - [FAIL] different basic 0 bool. - ... different basic 1 int.ASSERT int - [FAIL] different basic 1 int. - ... different basic 2 int32.ASSERT int32 - [FAIL] different basic 2 int32. - ... different basic 3 int64.ASSERT int64 - [FAIL] different basic 3 int64. - ... different basic 4 float.ASSERT float - [FAIL] different basic 4 float. - ... different basic 5 char.ASSERT char - [FAIL] different basic 5 char. - ... different basic 6 string.ASSERT string - [FAIL] different basic 6 string. - ... different basic 7 bytes.ASSERT bytes - [FAIL] different basic 7 bytes. - ... different composite 0 list.ASSERT list - [FAIL] different composite 0 list. - ... different composite 1 array.ASSERT array - [FAIL] different composite 1 array. - ... different composite 2 option some.ASSERT option some - [FAIL] different composite 2 option some. - ... different composite 3 result.ASSERT result - [FAIL] different composite 3 result. - ... different composite 4 pair.ASSERT pair - [FAIL] different composite 4 pair. +ASSERT bool + [FAIL] different basic 0 bool. +ASSERT int + [FAIL] different basic 1 int. +ASSERT int32 + [FAIL] different basic 2 int32. +ASSERT int64 + [FAIL] different basic 3 int64. +ASSERT float + [FAIL] different basic 4 float. +ASSERT char + [FAIL] different basic 5 char. +ASSERT string + [FAIL] different basic 6 string. +ASSERT bytes + [FAIL] different basic 7 bytes. +ASSERT list + [FAIL] different composite 0 list. +ASSERT array + [FAIL] different composite 1 array. +ASSERT option some + [FAIL] different composite 2 option some. +ASSERT result + [FAIL] different composite 3 result. +ASSERT pair + [FAIL] different composite 4 pair. ┌──────────────────────────────────────────────────────────────────────────────┐ │ [FAIL] different basic 0 bool. │ diff --git a/test/e2e/alcotest/failing/check_long.expected b/test/e2e/alcotest/failing/check_long.expected index b3f82df8..0af5d0f2 100644 --- a/test/e2e/alcotest/failing/check_long.expected +++ b/test/e2e/alcotest/failing/check_long.expected @@ -1,12 +1,12 @@ Testing `check_long'. This run has ID `'. - ... wrapping 0 list.ASSERT list - [FAIL] wrapping 0 list. - ... wrapping 1 array.ASSERT array - [FAIL] wrapping 1 array. - ... wrapping 2 nested options.ASSERT nested options - [FAIL] wrapping 2 nested options. +ASSERT list + [FAIL] wrapping 0 list. +ASSERT array + [FAIL] wrapping 1 array. +ASSERT nested options + [FAIL] wrapping 2 nested options. ┌──────────────────────────────────────────────────────────────────────────────┐ │ [FAIL] wrapping 0 list. │ diff --git a/test/e2e/alcotest/failing/exception_in_test.expected b/test/e2e/alcotest/failing/exception_in_test.expected index a03e216b..90357658 100644 --- a/test/e2e/alcotest/failing/exception_in_test.expected +++ b/test/e2e/alcotest/failing/exception_in_test.expected @@ -1,9 +1,9 @@ Testing `suite-with-failures'. This run has ID `'. - ... test-a 0 Passing. [OK] test-a 0 Passing. - ... test-a 1 Failing. > [FAIL] test-a 1 Failing. - ... test-b 0 Another pass. [OK] test-b 0 Another pass. + [OK] test-a 0 Passing. +> [FAIL] test-a 1 Failing. + [OK] test-b 0 Another pass. ┌──────────────────────────────────────────────────────────────────────────────┐ │ [FAIL] test-a 1 Failing. │ diff --git a/test/e2e/alcotest/failing/invalid_arg_in_test.expected b/test/e2e/alcotest/failing/invalid_arg_in_test.expected index 8b0b4aca..768a8f0c 100644 --- a/test/e2e/alcotest/failing/invalid_arg_in_test.expected +++ b/test/e2e/alcotest/failing/invalid_arg_in_test.expected @@ -1,9 +1,9 @@ Testing `suite-with-failures'. This run has ID `'. - ... test-a 0 Passing. [OK] test-a 0 Passing. - ... test-a 1 Failing. > [FAIL] test-a 1 Failing. - ... test-b 0 Another pass. [OK] test-b 0 Another pass. + [OK] test-a 0 Passing. +> [FAIL] test-a 1 Failing. + [OK] test-b 0 Another pass. ┌──────────────────────────────────────────────────────────────────────────────┐ │ [FAIL] test-a 1 Failing. │ diff --git a/test/e2e/alcotest/failing/long_test_case_name.expected b/test/e2e/alcotest/failing/long_test_case_name.expected index 0275d880..38511842 100644 --- a/test/e2e/alcotest/failing/long_test_case_name.expected +++ b/test/e2e/alcotest/failing/long_test_case_name.expected @@ -1,8 +1,8 @@ Testing `suite-with-failures'. This run has ID `'. - ... test-a 0 Passing. [OK] test-a 0 Passing. - ... test-a 1 Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse mollis, orci sed venenatis efficitur, eros est imperdiet purus, sit amet tincidunt massa diam ut elit. > [FAIL] test-a 1 Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse mollis, orci sed venenatis efficitur, eros est imperdiet purus, sit amet tincidunt massa diam ut elit. + [OK] test-a 0 Passing. +> [FAIL] test-a 1 Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse mollis, orci sed venenatis efficitur, eros est imperdiet purus, sit amet tincidunt massa diam ut elit. ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │ [FAIL] test-a 1 Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse mollis, orci sed venenatis efficitur, eros est imperdiet purus, sit amet tincidunt massa diam ut elit. │ diff --git a/test/e2e/alcotest/failing/tail_errors_limit.expected b/test/e2e/alcotest/failing/tail_errors_limit.expected index ac82c309..e47f8cee 100644 --- a/test/e2e/alcotest/failing/tail_errors_limit.expected +++ b/test/e2e/alcotest/failing/tail_errors_limit.expected @@ -1,7 +1,7 @@ Testing `tail_errors_limit'. This run has ID `'. - ... failing 0 test. > [FAIL] failing 0 test. +> [FAIL] failing 0 test. ┌──────────────────────────────────────────────────────────────────────────────┐ │ [FAIL] failing 0 test. │ diff --git a/test/e2e/alcotest/failing/tail_errors_unlimited.expected b/test/e2e/alcotest/failing/tail_errors_unlimited.expected index 4eb6dfd7..2a2a8938 100644 --- a/test/e2e/alcotest/failing/tail_errors_unlimited.expected +++ b/test/e2e/alcotest/failing/tail_errors_unlimited.expected @@ -1,7 +1,7 @@ Testing `tail_errors_unlimited'. This run has ID `'. - ... failing 0 test. > [FAIL] failing 0 test. +> [FAIL] failing 0 test. ┌──────────────────────────────────────────────────────────────────────────────┐ │ [FAIL] failing 0 test. │ diff --git a/test/e2e/alcotest/inside-dune/color-overridden.expected b/test/e2e/alcotest/inside-dune/color-overridden.expected index 14b5edeb..329004ff 100644 --- a/test/e2e/alcotest/inside-dune/color-overridden.expected +++ b/test/e2e/alcotest/inside-dune/color-overridden.expected @@ -1,9 +1,9 @@ Testing `test_color'. This run has ID `'. - ... alpha 0 Output may or may not contain ANSII escape codes. [OK] alpha 0 Output may or may not contain ANSII escape codes. - ... alpha 1 according to whether or not [--color] is set. [OK] alpha 1 according to whether or not [--color] is set. - ... alpha 2 (See the corresponding [dune] file.). [OK] alpha 2 (See the corresponding [dune] file.). + [OK] alpha 0 Output may or may not contain ANSII escape codes. + [OK] alpha 1 according to whether or not [--color] is set. + [OK] alpha 2 (See the corresponding [dune] file.). Full test results in `/_build/_tests/'. Test Successful in s. 3 tests run. diff --git a/test/e2e/alcotest/passing/and_exit_false.expected b/test/e2e/alcotest/passing/and_exit_false.expected index 63bf37d1..648f765d 100644 --- a/test/e2e/alcotest/passing/and_exit_false.expected +++ b/test/e2e/alcotest/passing/and_exit_false.expected @@ -1,7 +1,7 @@ Testing `suite-name'. This run has ID `'. - ... test-a 0 Test case. [OK] test-a 0 Test case. + [OK] test-a 0 Test case. Full test results in `/_build/_tests/'. Test Successful in s. 1 test run. diff --git a/test/e2e/alcotest/passing/and_exit_true.expected b/test/e2e/alcotest/passing/and_exit_true.expected index 01a5d682..5a5a87cb 100644 --- a/test/e2e/alcotest/passing/and_exit_true.expected +++ b/test/e2e/alcotest/passing/and_exit_true.expected @@ -1,7 +1,7 @@ Testing `suite-name'. This run has ID `'. - ... test-a 0 Test case. [OK] test-a 0 Test case. + [OK] test-a 0 Test case. Full test results in `/_build/_tests/'. Test Successful in s. 1 test run. diff --git a/test/e2e/alcotest/passing/assert_and_verbose.expected b/test/e2e/alcotest/passing/assert_and_verbose.expected index 4ed694d6..a1890d58 100644 --- a/test/e2e/alcotest/passing/assert_and_verbose.expected +++ b/test/e2e/alcotest/passing/assert_and_verbose.expected @@ -1,20 +1,20 @@ Testing `assert-and-verbose'. This run has ID `'. - ... alpha 0 check → stdout.ASSERT alpha-0 check +ASSERT alpha-0 check alpha-0 standard out - [OK] alpha 0 check → stdout. - ... alpha 1 stdout → check. + [OK] alpha 0 check → stdout. + alpha-1 standard out ASSERT alpha-1 check - [OK] alpha 1 stdout → check. - ... alpha 2 check → stderr.ASSERT alpha-2 check + [OK] alpha 1 stdout → check. +ASSERT alpha-2 check alpha-2 standard error - [OK] alpha 2 check → stderr. - ... beta 0 stdout → check → stderr. + [OK] alpha 2 check → stderr. + beta-0 standard out ASSERT beta-0 check beta-0 standard error - [OK] beta 0 stdout → check → stderr. + [OK] beta 0 stdout → check → stderr. Test Successful in s. 4 tests run. diff --git a/test/e2e/alcotest/passing/assert_not_printed.expected b/test/e2e/alcotest/passing/assert_not_printed.expected index 85f179e2..149db26a 100644 --- a/test/e2e/alcotest/passing/assert_not_printed.expected +++ b/test/e2e/alcotest/passing/assert_not_printed.expected @@ -1,9 +1,9 @@ Testing `assert-not-printed'. This run has ID `'. - ... alpha 0 0. [OK] alpha 0 0. - ... alpha 1 1. [OK] alpha 1 1. - ... beta 0 2. [OK] beta 0 2. + [OK] alpha 0 0. + [OK] alpha 1 1. + [OK] beta 0 2. Full test results in `/_build/_tests/'. Test Successful in s. 3 tests run. diff --git a/test/e2e/alcotest/passing/basic.expected b/test/e2e/alcotest/passing/basic.expected index 35822db8..2710d2b8 100644 --- a/test/e2e/alcotest/passing/basic.expected +++ b/test/e2e/alcotest/passing/basic.expected @@ -1,10 +1,10 @@ Testing `suite-name'. This run has ID `'. - ... test-a 0 First test case. [OK] test-a 0 First test case. - ... test-a 1 Second test case. [OK] test-a 1 Second test case. - ... test-b 0 Third test case. [OK] test-b 0 Third test case. - ... test-c 0 Fourth test case. [OK] test-c 0 Fourth test case. + [OK] test-a 0 First test case. + [OK] test-a 1 Second test case. + [OK] test-b 0 Third test case. + [OK] test-c 0 Fourth test case. Full test results in `/_build/_tests/'. Test Successful in s. 4 tests run. diff --git a/test/e2e/alcotest/passing/check_basic.expected b/test/e2e/alcotest/passing/check_basic.expected index 0b8980a1..ac465038 100644 --- a/test/e2e/alcotest/passing/check_basic.expected +++ b/test/e2e/alcotest/passing/check_basic.expected @@ -1,29 +1,29 @@ Testing `passing testables'. This run has ID `'. - ... reflexive basic 0 unit. [OK] reflexive basic 0 unit. - ... reflexive basic 1 bool. [OK] reflexive basic 1 bool. - ... reflexive basic 2 int. [OK] reflexive basic 2 int. - ... reflexive basic 3 int32. [OK] reflexive basic 3 int32. - ... reflexive basic 4 int64. [OK] reflexive basic 4 int64. - ... reflexive basic 5 float. [OK] reflexive basic 5 float. - ... reflexive basic 6 char. [OK] reflexive basic 6 char. - ... reflexive basic 7 string. [OK] reflexive basic 7 string. - ... reflexive basic 8 bytes. [OK] reflexive basic 8 bytes. - ... reflexive composite 0 empty list. [OK] reflexive composite 0 empty list. - ... reflexive composite 1 non-empty list. [OK] reflexive composite 1 non-empty list. - ... reflexive composite 2 empty array. [OK] reflexive composite 2 empty array. - ... reflexive composite 3 non-empty array. [OK] reflexive composite 3 non-empty array. - ... reflexive composite 4 option some. [OK] reflexive composite 4 option some. - ... reflexive composite 5 option none. [OK] reflexive composite 5 option none. - ... reflexive composite 6 result ok. [OK] reflexive composite 6 result ok. - ... reflexive composite 7 result error. [OK] reflexive composite 7 result error. - ... reflexive composite 8 pair. [OK] reflexive composite 8 pair. - ... negation 0 checked exceptions. [OK] negation 0 checked exceptions. - ... negation 1 negated testables. [OK] negation 1 negated testables. - ... fuzzy equality 0 float thresholds. [OK] fuzzy equality 0 float thresholds. - ... fuzzy equality 1 sorted list. [OK] fuzzy equality 1 sorted list. - ... labeled check 0 passing. [OK] labeled check 0 passing. + [OK] reflexive basic 0 unit. + [OK] reflexive basic 1 bool. + [OK] reflexive basic 2 int. + [OK] reflexive basic 3 int32. + [OK] reflexive basic 4 int64. + [OK] reflexive basic 5 float. + [OK] reflexive basic 6 char. + [OK] reflexive basic 7 string. + [OK] reflexive basic 8 bytes. + [OK] reflexive composite 0 empty list. + [OK] reflexive composite 1 non-empty list. + [OK] reflexive composite 2 empty array. + [OK] reflexive composite 3 non-empty array. + [OK] reflexive composite 4 option some. + [OK] reflexive composite 5 option none. + [OK] reflexive composite 6 result ok. + [OK] reflexive composite 7 result error. + [OK] reflexive composite 8 pair. + [OK] negation 0 checked exceptions. + [OK] negation 1 negated testables. + [OK] fuzzy equality 0 float thresholds. + [OK] fuzzy equality 1 sorted list. + [OK] labeled check 0 passing. Full test results in `/_build/_tests/'. Test Successful in s. 23 tests run. diff --git a/test/e2e/alcotest/passing/cli_verbose.expected b/test/e2e/alcotest/passing/cli_verbose.expected index 1d5929ff..a2153997 100644 --- a/test/e2e/alcotest/passing/cli_verbose.expected +++ b/test/e2e/alcotest/passing/cli_verbose.expected @@ -1,7 +1,7 @@ Testing `cli_verbose'. This run has ID `'. - ... alpha 0 0.SHOULD APPEAR IN TEST OUTPUT - [OK] alpha 0 0. +SHOULD APPEAR IN TEST OUTPUT + [OK] alpha 0 0. Test Successful in s. 1 test run. diff --git a/test/e2e/alcotest/passing/dune.inc b/test/e2e/alcotest/passing/dune.inc index f71b1e9d..c3eae9bb 100644 --- a/test/e2e/alcotest/passing/dune.inc +++ b/test/e2e/alcotest/passing/dune.inc @@ -11,6 +11,7 @@ empty_test_name filter_name filter_name_regex + isatty json_output list_tests only_monadic_effects @@ -33,6 +34,7 @@ empty_test_name filter_name filter_name_regex + isatty json_output list_tests only_monadic_effects @@ -319,6 +321,31 @@ (action (diff filter_name_regex.expected filter_name_regex.processed))) +(rule + (target isatty.actual) + (action + (with-outputs-to %{target} + (run %{dep:isatty.exe}) + ) + ) +) + +(rule + (target isatty.processed) + (action + (with-outputs-to %{target} + (run ../../strip_randomness.exe %{dep:isatty.actual}) + ) + ) +) + + +(rule + (alias runtest) + (package alcotest) + (action + (diff isatty.expected isatty.processed))) + (rule (target json_output.actual) (action diff --git a/test/e2e/alcotest/passing/empty_test_name.expected b/test/e2e/alcotest/passing/empty_test_name.expected index 3b72cd2d..743f6168 100644 --- a/test/e2e/alcotest/passing/empty_test_name.expected +++ b/test/e2e/alcotest/passing/empty_test_name.expected @@ -1,7 +1,7 @@ Testing `'. This run has ID `'. - ... 0 1. [OK] 0 1. + [OK] 0 1. Full test results in `/_build/_tests/'. Test Successful in s. 1 test run. diff --git a/test/e2e/alcotest/passing/filter_name.expected b/test/e2e/alcotest/passing/filter_name.expected index c7143412..6d03efa4 100644 --- a/test/e2e/alcotest/passing/filter_name.expected +++ b/test/e2e/alcotest/passing/filter_name.expected @@ -1,9 +1,9 @@ Testing `suite-name'. This run has ID `'. - ... test-a 0 First test case. [OK] test-a 0 First test case. - ... test-a 1 Second test case. [OK] test-a 1 Second test case. - ... test-b 0 Skipped failing test. [SKIP] test-b 0 Skipped failing test. + [OK] test-a 0 First test case. + [OK] test-a 1 Second test case. + [SKIP] test-b 0 Skipped failing test. Full test results in `/_build/_tests/'. Test Successful in s. 2 tests run. diff --git a/test/e2e/alcotest/passing/filter_name_regex.expected b/test/e2e/alcotest/passing/filter_name_regex.expected index 50ffb337..e8a8d769 100644 --- a/test/e2e/alcotest/passing/filter_name_regex.expected +++ b/test/e2e/alcotest/passing/filter_name_regex.expected @@ -1,11 +1,11 @@ Testing `suite-name'. This run has ID `'. - ... basic-run-a 0 Executed. [OK] basic-run-a 0 Executed. - ... basic-run-a 1 Also executed. [OK] basic-run-a 1 Also executed. - ... basic-run-b 0 Skipped. [SKIP] basic-run-b 0 Skipped. - ... basic-run-c 0 Executed. [OK] basic-run-c 0 Executed. - ... complex-run-a 0 Skipped. [SKIP] complex-run-a 0 Skipped. + [OK] basic-run-a 0 Executed. + [OK] basic-run-a 1 Also executed. + [SKIP] basic-run-b 0 Skipped. + [OK] basic-run-c 0 Executed. + [SKIP] complex-run-a 0 Skipped. Full test results in `/_build/_tests/'. Test Successful in s. 3 tests run. diff --git a/test/e2e/alcotest/passing/isatty.expected b/test/e2e/alcotest/passing/isatty.expected new file mode 100644 index 00000000..a46872c9 --- /dev/null +++ b/test/e2e/alcotest/passing/isatty.expected @@ -0,0 +1,10 @@ +Testing `isatty'. +This run has ID `'. + + ... test-a 0 First test case. [OK] test-a 0 First test case. + ... test-a 1 Second test case. [OK] test-a 1 Second test case. + ... test-b 0 Third test case. [OK] test-b 0 Third test case. + ... test-c 0 Fourth test case. [OK] test-c 0 Fourth test case. + +Full test results in `/_build/_tests/'. +Test Successful in s. 4 tests run. diff --git a/test/e2e/alcotest/passing/isatty.ml b/test/e2e/alcotest/passing/isatty.ml new file mode 100644 index 00000000..3ecc9648 --- /dev/null +++ b/test/e2e/alcotest/passing/isatty.ml @@ -0,0 +1,25 @@ +(** Test of the "in progress" output lines printed for each test-case (which are + only shown when standard output is a TTY). *) + +module Platform (M : Alcotest_engine.Monad.S) = struct + include Alcotest.Unix (M) + + let stdout_isatty () = true +end + +module Alcotest = + Alcotest_engine.Core.Make (Platform) (Alcotest_engine.Monad.Identity) + +let () = + let open Alcotest in + let id () = () in + run "isatty" + [ + ( "test-a", + [ + test_case "First test case" `Quick id; + test_case "Second test case" `Quick id; + ] ); + ("test-b", [ test_case "Third test case" `Quick id ]); + ("test-c", [ test_case "Fourth test case" `Slow id ]); + ] diff --git a/test/e2e/alcotest/passing/quick_only.expected b/test/e2e/alcotest/passing/quick_only.expected index 40025eb6..fb60531a 100644 --- a/test/e2e/alcotest/passing/quick_only.expected +++ b/test/e2e/alcotest/passing/quick_only.expected @@ -1,10 +1,10 @@ Testing `suite-name'. This run has ID `'. - ... test-a 0 Quick. [OK] test-a 0 Quick. - ... test-a 1 Slow. [SKIP] test-a 1 Slow. - ... test-b 0 Slow. [SKIP] test-b 0 Slow. - ... test-b 1 Quick. [OK] test-b 1 Quick. + [OK] test-a 0 Quick. + [SKIP] test-a 1 Slow. + [SKIP] test-b 0 Slow. + [OK] test-b 1 Quick. Full test results in `/_build/_tests/'. Test Successful in s. 2 tests run. diff --git a/test/e2e/alcotest/passing/quick_only_regex.expected b/test/e2e/alcotest/passing/quick_only_regex.expected index c0a2e8b0..ac4a007c 100644 --- a/test/e2e/alcotest/passing/quick_only_regex.expected +++ b/test/e2e/alcotest/passing/quick_only_regex.expected @@ -1,10 +1,10 @@ Testing `suite-name'. This run has ID `'. - ... test-a 0 Quick & passes filter. [OK] test-a 0 Quick & passes filter. - ... test-a 1 Slow & passes filter. [SKIP] test-a 1 Slow & passes filter. - ... test-b 0 Slow & fails filter. [SKIP] test-b 0 Slow & fails filter. - ... test-b 1 Quick & fails filter. [SKIP] test-b 1 Quick & fails filter. + [OK] test-a 0 Quick & passes filter. + [SKIP] test-a 1 Slow & passes filter. + [SKIP] test-b 0 Slow & fails filter. + [SKIP] test-b 1 Quick & fails filter. Full test results in `/_build/_tests/'. Test Successful in s. 1 test run. diff --git a/test/e2e/alcotest/passing/separator_testname.expected b/test/e2e/alcotest/passing/separator_testname.expected index 9631bb40..54df9608 100644 --- a/test/e2e/alcotest/passing/separator_testname.expected +++ b/test/e2e/alcotest/passing/separator_testname.expected @@ -1,7 +1,7 @@ Testing `suite-name'. This run has ID `'. - ... with/separator 0 First test case. [OK] with/separator 0 First test case. + [OK] with/separator 0 First test case. Full test results in `/_build/_tests/'. Test Successful in s. 1 test run. diff --git a/test/e2e/alcotest/passing/unicode_testname.expected b/test/e2e/alcotest/passing/unicode_testname.expected index fd22ce1c..94336ba3 100644 --- a/test/e2e/alcotest/passing/unicode_testname.expected +++ b/test/e2e/alcotest/passing/unicode_testname.expected @@ -1,8 +1,8 @@ Testing `Suite name containing file separators / and non-ASCII characters 🔥'. This run has ID `'. - ... 🔥 0 Non ASCII unicode character. [OK] 🔥 0 Non ASCII unicode character. - ... 🔥a-b 0 Non ASCII and ASCII characters. [OK] 🔥a-b 0 Non ASCII and ASCII characters. + [OK] 🔥 0 Non ASCII unicode character. + [OK] 🔥a-b 0 Non ASCII and ASCII characters. Full test results in `/_build/_tests/'. Test Successful in s. 2 tests run. diff --git a/test/e2e/alcotest/passing/verbose_newlines.expected b/test/e2e/alcotest/passing/verbose_newlines.expected index e7736177..94626835 100644 --- a/test/e2e/alcotest/passing/verbose_newlines.expected +++ b/test/e2e/alcotest/passing/verbose_newlines.expected @@ -1,13 +1,13 @@ Testing `suite-name'. This run has ID `'. - ... alpha 0 0 newlines.Print inside alpha [OK] alpha 0 0 newlines. - ... beta 0 1 newline.Print inside beta - [OK] beta 0 1 newline. - ... gamma 0 1 newline + long line.Print inside gamma -Lorem ipsum dolor sit amet, consectetur adipiscing elit, nullam malesuada dictum tortor in venenatis. [OK] gamma 0 1 newline + long line. - ... delta 0 1 newline + long check.Print inside delta +Print inside alpha [OK] alpha 0 0 newlines. +Print inside beta + [OK] beta 0 1 newline. +Print inside gamma +Lorem ipsum dolor sit amet, consectetur adipiscing elit, nullam malesuada dictum tortor in venenatis. [OK] gamma 0 1 newline + long line. +Print inside delta ASSERT Lorem ipsum dolor sit amet, consectetur adipiscing elit, nullam malesuada dictum tortor in venenatis. - [OK] delta 0 1 newline + long check. + [OK] delta 0 1 newline + long check. Test Successful in s. 4 tests run.