Runner v0.1.0

Source
Running a table of tests with filters, as the generated test runner does.

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.

Source

Fields

NameTypeDescription
namechar8[..]The test's name, such as Parser::ReadsNumbers.
runfunc() -> ! TestFailureWhat 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.

Source

Fields

NameTypeDescription
filterchar8[..]Run only tests whose names hold this text, or every test when it is empty and filters is too.
filterschar8[..][..]More texts like filter: a test runs when its name holds any of them, or filter.
exactboolWhether a filter must be the whole name rather than part of it.
skipchar8[..]Leave out tests whose names hold this text, unless it is empty.
listboolList the chosen tests rather than running them.
quietboolReport only failures and the summary.

Constructors

TestOptions

pub func TestOptions() -> TestOptions

Options that run every test and report each one.

Returns: the options

Source

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.

Source

Parameters

NameTypeDescription
testsTestCase[..]the tests
optionsTestOptionswhich 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.

Source

Parameters

NameTypeDescription
testsTestCase[..]the tests

Returns: 0 when none failed, 1 when some did, 2 for arguments it does not understand, 3 when filters chose no test