Module Testo.Lazy_with_output

EXPERIMENTAL Lazy computations that capture and restore stdout/stderr.

This is intended to save computation time when multiple tests share the same preliminary, costly computation.

type 'a t

EXPERIMENTAL

A lazy computation similar to OCaml's Lazy.t that also captures and restores stdout and stderr output just like it catches, stores and re-raises exceptions.

type redirect =
  1. | Stdout_to_stderr
  2. | Stderr_to_stdout

Stdout_to_stderr cause all stdout output to be printed on stderr. Stderr_to_stdout is the other way around.

val create : ?redirect:redirect -> (unit -> 'a Promise.t) -> 'a t

EXPERIMENTAL

Store a lazy computation. This doesn't compute it yet.

During the computation, Stdout and stderr outputs are captured separately, then printed out one after the other, with stdout coming first before stderr. To preserve the original interleaving of standard output and error output as it would normally appear in a console, use a redirect from stdout to stderr or vice-versa with the redirect option so as to merge the two streams into one for the duration of the computation.

val force : 'a t -> 'a Promise.t

EXPERIMENTAL

Run the lazy computation if it hasn't run yet. If the computation was already performed, the original standard and error outputs are printed again. The original result is returned or the original exception is re-raised with the original stack backtrace if applicable.