package expect_test_helpers_async
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=64837b8f4806c4d42b82be130b22fa506affa76004016dfd5a740c988ab42f12
doc/expect_test_helpers_async/Expect_test_helpers_async/index.html
Module Expect_test_helpers_asyncSource
Helpers for producing output inside let%expect_test. Designed for code using Async. See also Expect_test_helpers_base and Expect_test_helpers_core.
with_temp_dir f creates a temporary directory which is fed to f. The directory is removed after f exits.
val within_temp_dir :
?in_dir:string ->
?links:(string * [ `In_path_as | `In_temp_as ] * string) list ->
(unit -> 'a Async.Deferred.t) ->
'a Async.Deferred.twithin_temp_dir ?links f creates a temporary directory, $T, and:
1. For each file, `In_path_as, name in links, links file as $T/bin/name. 2. For each file, `In_temp_as, name in links, links file as $T/name. 3. Adds $T/bin to the PATH environment variable if step 1 added any links.
It then cds to $T and calls f. After f exits, it cds 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. If file and $T are not on the same file system, within_temp_dir copies the files instead of creating hard links.
val with_env_async :
(string * string) list ->
f:(unit -> 'a Async.Deferred.t) ->
'a Async.Deferred.twith_env sets specified environment variables before calling f. After f exits, these variables are reset to their previous values.
val set_temporarily_async :
'a Core.ref ->
'a ->
f:(unit -> 'b Async.Deferred.t) ->
'b Async.Deferred.tLike 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.tLike Ref.sets_temporarily, but waits for a deferred function to finish.
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.trun 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.tsystem ?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_async :
?hide_positions:bool ->
?show_backtrace:bool ->
(unit -> _ Async.Deferred.t) ->
unit Async.Deferred.tshow_raise_async ?hide_positions ?rest f calls f () and prints either the exception raised by f or "did not raise". show_raise_async 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_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.trequire_does_not_raise_async is like require_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.trequire_does_raise_async is like require_does_raise, but for functions that produce a deferred result.
A log that goes to the test runner's controlling terminal, if it exists.
This log's output is not captured by the expect test runner, and instead appears immediately on the attached terminal1. This is especially useful when debugging expect tests that time out.
1: When tests are run by a build system, there may be no controlling terminal, in which case the output of this log is silently discarded. You would need to run inline_test_runner interactively to see output from this log.
Removes connection details (hostnames and ports) from sexps containing the connection string "Client connected via TCP" followed by a host and port pair.
val with_robust_global_log_output :
?map_output:(string -> string) ->
(unit -> unit Async.Deferred.t) ->
unit Async.Deferred.tSets Async.Log.Global output to one that elides log timestamps, time spans, backtraces, and connection strings with hostnames and ports. These settings help make output deterministic. Additionally runs map_output, if provided, on each log line before it is emitted.