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:

OptionMeaning
--fileRun only the tests in the file with exactly this path
--filterRun only the tests whose module::name contains this text
--silk-test-planPath of the plan file. Required.
--silk-test-resultPath of the receipt file. Required.
--silk-test-progressPath of the progress file. Optional.
--silk-test-timeoutEach test's time limit in whole seconds. Optional; 0 or absent is none.
--silk-test-recordPath of the record of passing tests. Optional.

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 --silk-test-record, on a target whose runner has a table of its functions (ELF and Mach-O), the runner skips a selected test that passed in the run that wrote the record, when it would execute the same functions on the same inputs (see silk.testing.selection). It reports the test as CACHED and counts it as cached and passed. At the end it writes the record again.

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#

silk
pub effect fn main() -> i32 ? &mut HostInput

Runs 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, x86_64-pc-windows-msvc, wasm64-unknown-unknown.

View the source of this page