Register a test.
The __FILE__
argument, which should be equal to __FILE__
(i.e. just write Test.register ~__FILE__
), is used to let the user select which files to run from the command-line.
One should be able to infer, from title
, what the test will do. It is typically a short sentence like "addition is commutative"
or "server runs until client tells it to stop"
.
The list of tags
must be composed of short strings which are easy to type on the command line (lowercase letters, digits and underscores). Run the test executable with --list
to get the list of tags which are already used by existing tests. Try to reuse them if possible.
The last argument is a function f
which implements the test. If f
needs to spawn external processes, it should use the Process
module to do so, so that those processes are automatically killed at the end of the test. Similarly, if this function needs to create temporary files, it should declare them with Temp
, and if it needs to have promises that run in the background, it should use Background.register
(and not Lwt.async
in particular).
If f
raises an exception, act as if fail
was called (without the error location unfortunately).
You can call register
several times in the same executable if you want it to run several tests. Each of those tests should be standalone, as the user is able to specify the list of tests to run on the command-line.
The test is not actually run until you call run
.