An extension of Expect_test_helpers_kernel
with Async-aware functions.
include module type of sig ... end with module Expect_test_config := Expect_test_helpers_kernel.Expect_test_config
module Allocation_limit = Expect_test_helpers_kernel.Allocation_limit
module CR = Expect_test_helpers_kernel.CR
val sexp_to_string : ?hide_positions:bool ‑> Core_kernel.Sexp.t ‑> string
val print_s : ?hide_positions:bool ‑> Core_kernel.Sexp.t ‑> unit
val print_and_check_stable_type : ?cr:CR.t ‑> ?hide_positions:bool ‑> ?max_binable_length:int ‑> Core_kernel.Source_code_position.t ‑> (module Core_kernel.Stable_without_comparator with type t = 'a) ‑> 'a list ‑> unit
val print_and_check_stable_int63able_type : ?cr:CR.t ‑> ?hide_positions:bool ‑> ?max_binable_length:int ‑> Core_kernel.Source_code_position.t ‑> (module Core_kernel.Stable_int63able with type t = 'a) ‑> 'a list ‑> unit
val print_bin_ios : (module Expect_test_helpers_kernel__.Expect_test_helpers_kernel_intf.Print_bin_ios_arg with type t = 'a) ‑> 'a list ‑> unit
val print_bin_ios_with_max : ?cr:CR.t ‑> ?hide_positions:bool ‑> Core_kernel.Source_code_position.t ‑> (module Expect_test_helpers_kernel__.Expect_test_helpers_kernel_intf.Print_bin_ios_with_max_arg with type t = 'a) ‑> 'a list ‑> unit
val print_cr : ?cr:CR.t ‑> ?hide_positions:bool ‑> Core_kernel.Source_code_position.t ‑> Core_kernel.Sexp.t ‑> unit
val require : ?cr:CR.t ‑> ?hide_positions:bool ‑> ?if_false_then_print_s:Core_kernel.Sexp.t Core_kernel.Lazy.t ‑> Core_kernel.Source_code_position.t ‑> bool ‑> unit
val require_equal : ?cr:CR.t ‑> ?hide_positions:bool ‑> ?message:string ‑> Core_kernel.Source_code_position.t ‑> (module Expect_test_helpers_kernel__.Expect_test_helpers_kernel_intf.With_equal with type t = 'a) ‑> 'a ‑> 'a ‑> unit
val require_compare_equal : ?cr:CR.t ‑> ?hide_positions:bool ‑> ?message:string ‑> Core_kernel.Source_code_position.t ‑> (module Expect_test_helpers_kernel__.Expect_test_helpers_kernel_intf.With_compare with type t = 'a) ‑> 'a ‑> 'a ‑> unit
val require_sets_are_equal : ?cr:CR.t ‑> ?hide_positions:bool ‑> ?names:(string * string) ‑> Core_kernel.Source_code_position.t ‑> (module Expect_test_helpers_kernel__.Expect_test_helpers_kernel_intf.Set with type t = 'a) ‑> 'a ‑> 'a ‑> unit
val require_does_not_raise : ?cr:CR.t ‑> ?hide_positions:bool ‑> ?show_backtrace:bool ‑> Core_kernel.Source_code_position.t ‑> (unit ‑> unit) ‑> unit
val require_does_raise : ?cr:CR.t ‑> ?hide_positions:bool ‑> ?show_backtrace:bool ‑> Core_kernel.Source_code_position.t ‑> (unit ‑> 'a) ‑> unit
val require_allocation_does_not_exceed : ?cr:CR.t ‑> ?hide_positions:bool ‑> Allocation_limit.t ‑> Core_kernel.Source_code_position.t ‑> (unit ‑> 'a) ‑> 'a
val require_no_allocation : ?cr:CR.t ‑> ?hide_positions:bool ‑> Core_kernel.Source_code_position.t ‑> (unit ‑> 'a) ‑> 'a
val print_and_check_container_sexps : ?cr:CR.t ‑> ?hide_positions:bool ‑> Core_kernel.Source_code_position.t ‑> (module Expect_test_helpers_kernel__.Expect_test_helpers_kernel_intf.With_containers with type t = 'a) ‑> 'a list ‑> unit
val print_and_check_comparable_sexps : ?cr:CR.t ‑> ?hide_positions:bool ‑> Core_kernel.Source_code_position.t ‑> (module Expect_test_helpers_kernel__.Expect_test_helpers_kernel_intf.With_comparable with type t = 'a) ‑> 'a list ‑> unit
val print_and_check_hashable_sexps : ?cr:CR.t ‑> ?hide_positions:bool ‑> Core_kernel.Source_code_position.t ‑> (module Expect_test_helpers_kernel__.Expect_test_helpers_kernel_intf.With_hashable with type t = 'a) ‑> 'a list ‑> unit
val quickcheck : Core_kernel.Source_code_position.t ‑> ?cr:CR.t ‑> ?hide_positions:bool ‑> ?seed:Core_kernel.Quickcheck.seed ‑> ?sizes:int Core_kernel.Sequence.t ‑> ?trials:int ‑> ?attempts:int ‑> ?filter:('a ‑> bool) ‑> ?shrinker:'a Core_kernel.Quickcheck.Shrinker.t ‑> ?shrink_attempts:Core_kernel.Quickcheck.shrink_attempts ‑> ?examples:'a list ‑> sexp_of:('a ‑> Core_kernel.Sexp.t) ‑> f:('a ‑> unit) ‑> 'a Core_kernel.Quickcheck.Generator.t ‑> unit
val on_print_cr : (string ‑> unit) Core_kernel.ref
module Expect_test_config = Expect_test_helpers_kernel.Expect_test_config
val with_temp_dir : (string ‑> 'a Async.Deferred.t) ‑> 'a Async.Deferred.t
with_temp_dir f
creates a temporary directory which is fed to f
. The directory
is removed after f
exits.
val within_temp_dir : ?links:(string * [ `In_path_as | `In_temp_as ] * string) list ‑> (unit ‑> 'a Async.Deferred.t) ‑> 'a Async.Deferred.t
within_temp_dir ?links f
creates a temporary directory, $T, and:
1. Adds $T/bin to the PATH environment variable.
2. For each file, `In_path_as, name
in links
, links file
as $T/bin/name
.
3. For each file, `In_temp_as, name
in links
, links file
as $T/name
.
It then cd
s to $T and calls f
. After f
exits, it cd
s back, removes the
temporary directory, and restores the original PATH.
val run : ?enable_ocaml_backtraces:bool ‑> ?extend_env:(string * string) list ‑> ?hide_positions:bool ‑> ?print_cmdline:bool ‑> ?stdin:string ‑> ?working_dir:string ‑> string ‑> string list ‑> unit Async.Deferred.t
run prog args
creates a child process that runs prog
, with arguments args
, its
environment extended with extend_env
and its stdin coming from stdin
. No
expansion or escaping is done to args
or stdin
. The child process's stdout and
stderr are captured separately for comparison.
val system : ?enable_ocaml_backtraces:bool ‑> ?hide_positions:bool ‑> ?print_cmdline:bool ‑> ?stdin:string ‑> string ‑> unit Async.Deferred.t
system ?stdin cmd
creates a child process that runs /bin/sh
, with arguments
"-c"; cmd
and its stdin coming from stdin
. The child process's stdout and stderr
are captured separately for comparison. Unlike with Unix.system
, the child shell's
stdin is never a tty, even if the stdin of this process is a tty, and the child
shell's stderr is never copied to this process's stderr.
val show_raise' : ?hide_positions:bool ‑> (unit ‑> _ Async.Deferred.t) ‑> unit Async.Deferred.t
show_raise' ?hide_positions ?rest f
calls f ()
and prints either the exception
raised by f
or "did not raise". show_raise'
ignores the result of f
so that one
doesn't have to put an ignore
inside f
. ~hide_positions
operates as in
print_s
, to make output less fragile. Once a result is returned, the rest of the
errors are printed to stdout.
val require_does_not_raise' : ?cr:CR.t ‑> ?hide_positions:bool ‑> ?show_backtrace:bool ‑> Core.Source_code_position.t ‑> (unit ‑> unit Async.Deferred.t) ‑> unit Async.Deferred.t
require_does_not_raise'
is like require_does_not_raise
, but for functions that
produce a deferred result.
val require_does_raise' : ?cr:CR.t ‑> ?hide_positions:bool ‑> ?show_backtrace:bool ‑> Core.Source_code_position.t ‑> (unit ‑> _ Async.Deferred.t) ‑> unit Async.Deferred.t
require_does_raise'
is like require_does_raise
, but for functions that produce a
deferred result.
module Expect_test_config : Expect_test_helpers__.Import.Expect_test_config_lib.S with type 'a IO.t = 'a Async.Deferred.t
We export Expect_test_config
so that the %expect
syntax uses Async, to prevent a
confusing situation in which one is using Expect_test_helpers
functions, which
expect Async to be running, but Async isn't running. Also, we override
Expect_test_config.run f
so that, if f ()
raises, run
prints the exception
rather than raising. Printing works better with the expect-test workflow than an
unhandled exception, because there is a .corrected
file that one can accept and
inspect.