Runner v0.1.0
TestCase
pub struct TestCase {
pub name: char8[..];
pub run: func() -> ! TestFailure;
}
A test: its name, which the runner reports and filters on, and the function that runs it. Copy.
Fields
| Name | Type | Description |
|---|---|---|
name | char8[..] | The test's name, such as Parser::ReadsNumbers. |
run | func() -> ! TestFailure | What runs it. |
TestOptions
pub struct TestOptions {
pub filter: char8[..];
pub filters: char8[..][..];
pub exact: bool;
pub skip: char8[..];
pub list: bool;
pub quiet: bool;
}
Which tests a run chooses and how it reports them. Copy.
Fields
| Name | Type | Description |
|---|---|---|
filter | char8[..] | Run only tests whose names hold this text, or every test when it is empty and filters is too. |
filters | char8[..][..] | More texts like filter: a test runs when its name holds any of them, or filter. |
exact | bool | Whether a filter must be the whole name rather than part of it. |
skip | char8[..] | Leave out tests whose names hold this text, unless it is empty. |
list | bool | List the chosen tests rather than running them. |
quiet | bool | Report only failures and the summary. |
Constructors
TestOptions
pub func TestOptions() -> TestOptions
Options that run every test and report each one.
Returns: the options
RunTestsWith
pub func RunTestsWith(
tests: TestCase[..],
options: TestOptions
) -> int
Runs the tests that options choose, in order, and reports each as ok, FAILED with its message, or
skipped with its reason, then a summary of the counts and the time taken. A filter that chooses no test at all is
reported as no test matches and given a code of its own, so that rux test, which hands one filter to every
package, can fail the run when no package had a test it matched instead of passing with nothing run.
Parameters
| Name | Type | Description |
|---|---|---|
tests | TestCase[..] | the tests |
options | TestOptions | which to run and how to report them |
Returns: 0 when none failed, 1 when some did, 3 when filters chose no test
RunTests
pub func RunTests(tests: TestCase[..]) -> int
Runs the tests the process's arguments choose. A plain argument is a filter that a test's name must hold, and a
test runs when its name holds any of them; --exact makes each the whole name, --skip <text> leaves out names
holding the text, --list lists the chosen tests without running them, and --quiet reports only failures and
the summary.
Parameters
| Name | Type | Description |
|---|---|---|
tests | TestCase[..] | the tests |
Returns: 0 when none failed, 1 when some did, 2 for arguments it does not understand, 3 when filters chose no test