Module Tezt_wrapper.Uses

Test dependencies.

Test.register and Regression.register take an optional argument ?uses that allows to declare that the test uses a given file.

For instance, you can define:

let data = Uses.make ~tag:"data" ~path:"data/file.dat"

You would then:

~uses:[data] adds the tag of data to the test tags.

Uses.path data checks that the current test was declared with data in its ~uses. And when you declare a test with ~uses:[data], the test checks, at the end, that Uses.path data was called. This helps to maintain the invariant that a test that uses a given file has a given tag.

Note that some uses are added by default to all tests. See section Default Uses below.

type t

Test dependencies.

val make : tag:string -> path:string -> t

Make a test dependency.

Multiple paths can be associated with the same tag, and the same paths can be associated with different tags.

val path : t -> string

Get the path of a test dependency.

val tag : t -> string

Get the tag of a test dependency.

val lookup : string -> t option

Get the first Uses.t that was created using make for a given path.

Paths are considered equal modulo some inconsequential variations. For instance, "./bin//./mavkit-node" and "bin/mavkit-node" are considered equivalent.

Default Uses

The following uses are added by default, but can be removed by specifying ~uses_node:false or ~uses_client:false.

val mavkit_node : t

"./mavkit-node", with tag "node".

val mavkit_client : t

"./mavkit-client", with tag "client".

val mavkit_admin_client : t

"./mavkit-admin-client", with tag "admin_client".

val register_meta_test : unit -> unit

Register a test that generates:

tezt/lib_wrapper/expected/tezt_wrapper.ml/runtime-dependency-tags.out

This file can be used by the manifest to deduce which tests to run. By having this be a regression test, we guarantee that this list is always up-to-date and that there is only one source of truth.

To regenerate the file, run:

dune exec tezt/tests/main.exe -- \
  --reset-regressions -t 'meta: list runtime dependencies'

Since the contents of the file depends on the tests which are registered, but the file is always the same, this function should only be called by the executable that is linked with all tests, i.e. tezt/tests/main.exe.