silk.testing.runner.
The built-in test runner that silk test selects. It runs tests one at a time.
Details#
This module is a normal Silk application made from the public static test primitives. It finds
the tests in the compilation, applies the filters, runs each selected test in order, and writes
a receipt (see silk.testing.exchange).
The host passes these options. Each takes one value:
| Option | Meaning |
|---|---|
--file | Run only the tests in the file with exactly this path |
--filter | Run only the tests whose module::name contains this text |
--silk-test-plan | Path of the plan file. Required. |
--silk-test-result | Path of the receipt file. Required. |
--silk-test-progress | Path of the progress file. Optional. |
--silk-test-timeout | Each test's time limit in whole seconds. Optional; 0 or absent is none. |
The runner checks the complete plan before any test body runs.
On a native target, a failed test's report goes to standard output under the test's name: the message of a failed expectation, an unhandled error, or a fatal trap, with the call path that led to it.
With --silk-test-progress, the runner writes a progress record (see silk.testing.exchange)
before each test body runs, and removes the file when every test has finished. If the file
already holds a record when the runner starts, the test it names stopped an earlier runner
process, for example with a trap. The runner then reports that test as failed, skips the tests
before it, and continues with the next one, so its summary and receipt count the whole run.
With a time limit on a native target with a C library, the runner sets an alarm before each test
body runs. A test that outlives it ends the process with SIGALRM, which the host reports as a
timeout before it continues with the next test.
Errors#
The exit status is 0 if all selected tests pass, 1 if a test fails, and 2 for a usage
error, a plan that is not valid, or an I/O failure.
Import as TestRunner with import silk.testing.runner as TestRunner.
Public declarations: 1.
main#
pub effect fn main() -> i32 ? &mut HostInputRuns each selected test in order and returns the exit status (0, 1 or 2).
Category: Testing.
Profiles: aarch64-apple-darwin, aarch64-unknown-linux-gnu, aarch64-unknown-linux-gnu-no-libc, x86_64-unknown-linux-gnu, x86_64-unknown-linux-gnu-no-libc, wasm32-unknown-unknown, wasm32-wasip1, wasm32-wasip2.