Module Expect_test_helpers
An extension of Expect_test_helpers_kernel
with Async-aware functions.
module CR = Expect_test_helpers_base.CR
module Sexp_style = Expect_test_helpers_base.Sexp_style
val hide_positions_in_string : Base.string -> Base.string
val sexp_to_string : ?hide_positions:Base.bool -> Base.Sexp.t -> Base.string
val print_s : ?hide_positions:Base.bool -> Base.Sexp.t -> Base.unit
val print_string : ?hide_positions:Base.bool -> Base.string -> Base.unit
val print_endline : ?hide_positions:Base.bool -> Base.string -> Base.unit
val print_cr : ?cr:CR.t -> ?hide_positions:Base.bool -> Base.Source_code_position.t -> Base.Sexp.t -> Base.unit
val require : ?cr:CR.t -> ?hide_positions:Base.bool -> ?if_false_then_print_s:Base.Sexp.t Base.Lazy.t -> Base.Source_code_position.t -> Base.bool -> Base.unit
val require_equal : ?cr:CR.t -> ?hide_positions:Base.bool -> ?if_false_then_print_s:Base.Sexp.t Base.Lazy.t -> ?message:Base.string -> Base.Source_code_position.t -> (module With_equal with type t = 'a) -> 'a -> 'a -> Base.unit
val require_compare_equal : ?cr:CR.t -> ?hide_positions:Base.bool -> ?message:Base.string -> Base.Source_code_position.t -> (module With_compare with type t = 'a) -> 'a -> 'a -> Base.unit
val require_sets_are_equal : ?cr:CR.t -> ?hide_positions:Base.bool -> ?names:(Base.string * Base.string) -> Base.Source_code_position.t -> (module Set with type t = 'a) -> 'a -> 'a -> Base.unit
val show_raise : ?hide_positions:Base.bool -> ?show_backtrace:Base.bool -> (Base.unit -> 'a) -> Base.unit
val require_does_not_raise : ?cr:CR.t -> ?hide_positions:Base.bool -> ?show_backtrace:Base.bool -> Base.Source_code_position.t -> (Base.unit -> Base.unit) -> Base.unit
val require_does_raise : ?cr:CR.t -> ?hide_positions:Base.bool -> ?show_backtrace:Base.bool -> Base.Source_code_position.t -> (Base.unit -> 'a) -> Base.unit
val quickcheck : Base.Source_code_position.t -> ?cr:CR.t -> ?hide_positions:Base.bool -> ?seed:Expect_test_helpers_base__.Expect_test_helpers_base_intf.Quickcheck.Test.Config.Seed.t -> ?sizes:Base.int Base.Sequence.t -> ?trials:Base.int -> ?shrinker:'a Expect_test_helpers_base__.Expect_test_helpers_base_intf.Quickcheck.Shrinker.t -> ?shrink_attempts:Base.int -> ?examples:'a Base.list -> sexp_of:('a -> Base.Sexp.t) -> f:('a -> Base.unit) -> 'a Expect_test_helpers_base__.Expect_test_helpers_base_intf.Quickcheck.Generator.t -> Base.unit
val sexp_style : Sexp_style.t Base.ref
val on_print_cr : (Base.string -> Base.unit) Base.ref
module type With_containers = Expect_test_helpers_kernel__.Expect_test_helpers_kernel_intf.With_containers
module type With_comparable = Expect_test_helpers_kernel__.Expect_test_helpers_kernel_intf.With_comparable
module type With_hashable = Expect_test_helpers_kernel__.Expect_test_helpers_kernel_intf.With_hashable
module Allocation_limit = Expect_test_helpers_kernel.Allocation_limit
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 prepare_heap_to_count_minor_allocation : unit -> unit
val require_allocation_does_not_exceed : ?hide_positions:bool -> Allocation_limit.t -> Core_kernel.Source_code_position.t -> (unit -> 'a) -> 'a
val require_no_allocation : ?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 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 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 With_hashable with type t = 'a) -> 'a list -> unit
module Expect_test_helpers_kernel_private = Expect_test_helpers_kernel.Expect_test_helpers_kernel_private
val with_temp_dir : (string -> 'a Async.Deferred.t) -> 'a Async.Deferred.t
with_temp_dir f
creates a temporary directory which is fed tof
. The directory is removed afterf
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
inlinks
, linksfile
as $T/bin/name
. 3. For eachfile, `In_temp_as, name
inlinks
, linksfile
as $T/name
.It then
cd
s to $T and callsf
. Afterf
exits, itcd
s back, removes the temporary directory, and restores the original PATH.within_temp_dir
creates hard links to ensure that files remain available and unchanged even if jenga starts to rebuild while the test is running. Iffile
and $T are not on the same file system,within_temp_dir
copies the files instead of creating hard links.
module Print_rule : sig ... end
val run : ?enable_ocaml_backtraces:bool -> ?extend_env:(string * string) list -> ?hide_positions:bool -> ?postprocess:(string -> string) -> ?print_cmdline:bool -> ?print_stdout:Print_rule.t -> ?print_stderr:Print_rule.t -> ?stdin:string -> ?working_dir:string -> string -> string list -> unit Async.Deferred.t
run prog args
creates a child process that runsprog
, with argumentsargs
, its environment extended withextend_env
and its stdin coming fromstdin
. No expansion or escaping is done toargs
orstdin
. 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 fromstdin
. The child process's stdout and stderr are captured separately for comparison. Unlike withUnix.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_async : ?hide_positions:bool -> (unit -> _ Async.Deferred.t) -> unit Async.Deferred.t
show_raise_async ?hide_positions ?rest f
callsf ()
and prints either the exception raised byf
or "did not raise".show_raise_async
ignores the result off
so that one doesn't have to put anignore
insidef
.~hide_positions
operates as inprint_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_async : ?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_async
is likerequire_does_not_raise
, but for functions that produce a deferred result.
val require_does_raise_async : ?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_async
is likerequire_does_raise
, but for functions that produce a deferred result.
module Expect_test_config = Async.Expect_test_config
We export
Expect_test_config
so that the%expect
syntax uses Async, to prevent a confusing situation in which one is usingExpect_test_helpers
functions, which expect Async to be running, but Async isn't running.