Module Expect_test_helpers_async
Helpers for producing output inside let%expect_test
. Designed for code using Async
. See also Expect_test_helpers_base
and Expect_test_helpers_core
.
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.
val set_temporarily_async : 'a Core.ref -> 'a -> f:(unit -> 'b Async.Deferred.t) -> 'b Async.Deferred.t
Like
Ref.set_temporarily
, but waits for a deferred function to finish.
val sets_temporarily_async : Core.Ref.And_value.t list -> f:(unit -> 'a Async.Deferred.t) -> 'a Async.Deferred.t
Like
Ref.sets_temporarily
, but waits for a deferred function to finish.
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:Expect_test_helpers_core.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:Expect_test_helpers_core.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.