Cram¶
- (cram ...)
Configure Cram tests in the current directory (and subdirectories).
A single test may be configured by more than one
cramstanza. In such cases, the values from all applicablecramstanzas are merged together to get the final values for all the fields.See also
- (deps <dep-spec>)
Specify the dependencies of the test.
When testing binaries, it’s important to to specify a dependency on the binary for two reasons:
Dune must know to re-run the test when a dependency changes
The dependencies must be specified to guarantee that they’re visible to the test when running it.
The following introduces a dependency on
foo.exeon all Cram tests in this directory:(cram (deps ../foo.exe))
See also
- (applies_to <predicate-lang>)
Specify the scope of this
cramstanza. By default it applies to all the Cram tests in the current directory. The special:whole_subtreevalue will apply the options to all tests in all subdirectories (recursively). This is useful to apply common options to an entire test suite.The following will apply the stanza to all tests in this directory, except for
foo.tandbar.t:(cram (applies_to * \ foo bar) (deps ../foo.exe))
See also
- (enabled_if <blang>)
Control whether the tests are enabled.
See also
- (alias <name>)
Alias that can be used to run the test. In addition to the user alias, every test
foo.tis attached to the @runtest alias and gets its own@fooalias to make it convenient to run individually.
- (locks <lock-names>)
Specify that the tests must be run while holding the following locks.
See also
- (package <name>)
Attach the tests selected by this stanza to the specified package.
- (runtest_alias <true|false>)
Added in version 3.12.
When set to
false, do not add the tests to theruntestalias. The default is to add every Cram test toruntest, but this is not always desired.
- (timeout <float>)
Added in version 3.20.
Specify a time limit (in seconds) for each individual Cram test.
If a test takes longer than the specified timeout, Dune will terminate it and report a timeout error. This can be useful to catch tests that hang or take unexpectedly long.
The timeout is a floating-point number (e.g., 1.5 for 1.5 seconds). Zero or negative values cause immediate failure when running the cram test.
If multiple
cramstanzas apply to the same test, the lowest of all specified timeouts is used.This field is typically used to guard against unresponsive or non-terminating test cases.
Example:
(cram (timeout 2.5))
This limits each selected test to at most 2.5 seconds of execution time.
- (conflict_markers <ignore|error>)
Added in version 3.21.
Determines how conflict markers inserted by version control systems are inserted. The default behavior is to
ignorethem. Settingerrorwill make the test runner reject such conflicts and refuse to run the test.