{ } JustinGeoSci

Ostiarius User Guide

Ostiarius is a command-line tool that checks whether a cargo test gate proves what it claims. This guide has two pages, this one for getting started and Commands for the options, the mutation tables and the exit codes.

Overview

A test gate makes two kinds of claim that its exit code cannot support on its own. The first is a claim about coverage, that a filtered run exercised the tests it was meant to. cargo test exits successfully when a filter matches nothing, so a gate that names a module path which no longer exists passes silently. The second is a claim about an argument, that a particular comparison, bound or invariant in the code is what keeps the results right. A passing suite says nothing about which arguments its tests actually depend on.

Ostiarius makes both claims checkable with two subcommands. count asserts how many tests passed, in total, per test binary and by name. mutate breaks each declared argument on purpose and requires the tests that depend on it to fail, then restores every file it edited byte for byte.

It is a single binary with two dependencies, toml for reading tables and ctrlc for stopping cleanly, and it forbids unsafe code. It is a different tool from cargo-mutants, which generates mutations across a whole codebase automatically. ostiarius mutate tests specific arguments that you declare, which shows that named tests depend on them rather than that the suite catches changes in general, and the two can be used together.

Conventions

A few conventions hold throughout the tool:

  • Runner: ostiarius reads the human-readable output of libtest, the test harness behind cargo test. Other runners, such as cargo-nextest, are not supported yet.
  • Zero is a failure: a run in which no test passed fails unless --allow-empty says that is expected. A gate that tests nothing is the case the tool exists to catch.
  • Captured output is not results: a failing test can print anything, including a line shaped like a result, so a test’s captured output is never read as results. For the same reason the tool refuses commands that use --nocapture or --show-output, and commands that use -q or --quiet, which leave out the test names it reads.
  • Test names are full paths as cargo test prints them, such as interval::tests::touching_intervals_overlap. Doctests are named without their (line N) suffix, or a mode after it such as - compile fail, and with forward slashes, so a name stays valid when lines above it move.
  • Files come back unchanged: every file mutate edits is saved first and restored byte for byte, and the restored bytes are read back and compared before the run moves on.
  • Exit codes are fixed and documented, so either subcommand can stand in a script. They are listed under Exit codes.

Installation

Requirements

  • Rust ≥ 1.87, edition 2024
  • Tested on Windows with PowerShell 5.1 and on Linux

From crates.io

cargo install --locked ostiarius

--locked builds with the exact dependency versions the release was tested with, recorded in its Cargo.lock, rather than the newest compatible ones. The binary is installed in Cargo’s own bin folder, which the Rust installer has already put on your PATH.

From source

git clone https://github.com/JustinGeoSci/ostiarius.git
cd ostiarius

cargo install --locked --path .

The repository also holds the complete mutation-table reference, which lists every key, rule and message, and a worked example in examples/intervals.

Quick start

Count the tests a run passed

Give count a floor and the command to run. It passes the command’s output through, then prints the totals and the result of each check.

$ ostiarius count --min-passed 40 -- cargo test -p mycrate --release
...
42 passed, 0 failed, 1 ignored, in 3 test binaries

A filter that matches nothing, which cargo test alone reports as a success, fails here with exit code 1:

$ ostiarius count -- cargo test --lib no_such_test
...
0 passed, 0 failed, 0 ignored, in 1 test binaries
FAILED: no test passed (does the filter match anything?); use --allow-empty if that is expected

Test an argument with a mutation table

A mutation table is a TOML file. Each entry names one edit that breaks an argument, and the tests that must fail when it is broken. The table below comes from the example in the repository, a function overlaps that decides whether two closed intervals share a point. The argument is that the comparison is closed, so intervals that only touch still overlap.

version = 1
root = "intervals"
command = ["cargo", "test", "--lib"]
min_passed = 5

[[mutation]]
id = "open-interval"
what = "the closed comparison made open"
file = "src/interval.rs"
find = "a.lo <= b.hi && b.lo <= a.hi"
replace = "a.lo < b.hi && b.lo < a.hi"
must_fail = ["interval::tests::touching_intervals_overlap"]

Running the full table first runs the tests on the unmutated tree, then each entry, then the tests once more on the restored tree:

$ ostiarius mutate examples/intervals.mutations.toml
root: /home/me/ostiarius/examples/intervals
ok   baseline: 5 passed in 0.5 s (entry timeout up to 60 s): cargo test --lib
ok   open-interval            the closed comparison made open: fails touching_intervals_overlap
ok   one-sided                one of the two bound checks dropped: fails adjacent_intervals_do_not, disjoint_intervals_do_not, overlap_is_symmetric
ok   off-by-one               the upper bound widened by one: fails adjacent_intervals_do_not, overlap_is_symmetric
ok   restored: 5 passed (need 5): cargo test --lib

An entry that no test notices is reported as nothing caught it. That means either that the argument is not load-bearing for these tests or that the edit misses the code they exercise, and both are worth knowing. From here, Commands covers every option, what a run does to your files, and the table keys.