package tezt

  1. Overview
  2. Docs

Run Tezt regression tests and capture their output.

NOTE: consider using dune cram when it becomes available: https://dune.readthedocs.io/en/stable/tests.html#cram-tests

val register : __FILE__:string -> title:string -> tags:string list -> output_file:string -> (unit -> unit Lwt.t) -> unit

Register a regression test.

This function is a wrapper around Test.register. It adds the "regression" tag to the tags list provided by the argument.

The output_file specifies the name of the file where the output of the test is stored and read to be compared on subsequent runs. The actual filename is Cli.options.regression_dir // output_file ^ ".out".

Note that output_file can contain subdirectories. For instance, using the default --regression-dir, ~output_file:"math/sqrt" will result in the creation of directory "tezt/_regressions/math" if needed and regression output will be written in "tezt/_regressions/math/sqrt.out".

val capture : string -> unit

Capture some output of a regression test.

Call this to record a string into the output_file given to register. A newline character \n will be added after it.

This function only records its argument when called while a regression test is running, i.e. from the body of Regression.register. If you call it outside of Regression.register, it has no effect. So you can define a function that captures and use it with or without regression testing.

A typical use is to define custom process hooks that substitute non-deterministic parts of the output with deterministic ones. See also hooks.

val hooks : Process.hooks

Hooks that enable regression testing when attached to a process ran from a registered regression test function.

The hooks will capture the spawned command, its arguments and the output of its execution into the registered output_file.

OCaml

Innovation. Community. Security.