Skip to content
CryoCryo home
Stdlibtest

runner

import std::test::runner; · source

run_all

function run_all(argc: i32, argv: u8**, descriptors: TestDescriptor*, count: u64) -> i32;

run_all is the entry point the compiler-synthesized test main calls. It parses the CLI arguments into a RunOptions, forks per test — in parallel across jobs workers, fed through an mpsc channel — and prints results in the chosen format.

The descriptors it receives are TestDescriptors, one per discovered test.

TestOutcome is what a forked child's exit is classified into: Fail carries the exit code, the terminating signal, and whether it was a signal; DidNotPanic is a ![should_panic] test that returned normally; Timeout carries the limit it exceeded.

RunOptions

type struct RunOptions {
    filter:           String;
    exact:            boolean;
    include_ignored:  boolean;
    list_only:        boolean;
    quiet:            boolean;
    format:           TestFormat;
    format_explicit:  boolean;
    color:            ColorMode;
    color_explicit:   boolean;
    color_active:     boolean;
    timeout_secs:     u32;
    timeout_explicit: boolean;
    jobs:             u32;
    jobs_explicit:    boolean;
    capture:          boolean;
    show_output:      boolean;
    child_idx:        i64;

    static default() -> RunOptions;
}

The parsed command line: a name filter and whether it must match exactly, include_ignored, list_only, quiet, per-test timeout_secs, parallel jobs, and whether to capture or show_output. default() is what an empty command line parses to.

TestFormat and ColorMode

type enum TestFormat {
    Plain;
    Pretty;
    Compact;
}
type enum ColorMode {
    Auto;
    Always;
    Never;
}

TestOutcome

type enum TestOutcome {
    Pass;
    Fail(i32, i32, boolean);
    Skipped;
    DidNotPanic;
    Timeout(u32);
    RunnerError(i32);
}

What a forked child's exit is classified into: Fail carries the exit code, the terminating signal, and whether it was a signal; DidNotPanic is a ![should_panic] test that returned normally; Timeout carries the limit it exceeded; RunnerError is the runner's own failure to fork or reap.

Trait implementations

implement trait Drop for struct RunOptions

For the toolchain side — discovery, forking, and reporting — see Testing in the language reference.