Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

T04 Research nextest switch, doctest split, cucumber shim

Question

Cerebro runs plain cargo test. The standard’s testing.md wants four layers:

  • nextest (just test) with .config/nextest.toml, retries = 0 written down (ADR 9), slow-timeout warn and stop at 60 seconds.
  • just doctest as its own layer (cargo test --workspace --doc), nextest doesn’t run doctests, so without this the forced examples rot silently (ADR 10).
  • cucumber (tests/cucumber.rs, harness = false) must run under nextest.

The specific unknown to resolve by experiment: nextest speaks libtest’s protocol; harness = false binaries speak their own. Does nextest (a) see cerebro-tui’s cucumber binary as 0 tests and green it, (b) error, or (c) run it via the shim path the standard uses (--list --format terse answered as one unit, then with_default_cli so nextest flags don’t reach cucumber’s parser)? Cerebro currently sidesteps this by running cucumber as a separate cargo test -p cerebro-tui --test cucumber CI step (see ci.yml).

Exit predicate

A cited note here recording nextest’s actual behavior against cerebro’s harness = false binary, and a recommendation: keep the separate cucumber CI step (lowest risk) OR add the nextest shim. Feeds T06’s just test shape. No code changes in this ticket.

Resolution

Answered by experiment 2026-11-09 on cargo-nextest 0.9.151 against cerebro’s own [[test]] harness = false cucumber binary. No code committed (research ticket); the shim below was a throwaway working-copy edit that was run and reverted.

The unknown resolved: (b) error, loudly. Against the current binary with no shim, cargo nextest run -p cerebro-tui --test cucumber exits 104 with creating test list failed ... command <bin> --list --format terse exited with exit code 2 ... unexpected argument '--list' found. It does NOT see 0 tests and green it (a); it fails. So today’s separate cargo test -p cerebro-tui --test cucumber CI step is load-bearing and correct, and a naive nextest switch would break the build until the shim lands.

The shim works, with two gotchas that both defeat a naive implementation. A conforming harness main is:

#[tokio::main]
async fn main() {
    let args: Vec<String> = std::env::args().collect();
    if args.iter().any(|a| a == "--list") {
        if !args.iter().any(|a| a == "--ignored") {
            println!("cucumber: test");
        }
        return;
    }
    World::cucumber().with_default_cli().run_and_exit("features/").await;
}

Gotcha 1 (why a naive implementation is silently green, the worst outcome): the first attempt printed the libtest-style \n\n1 test footer and answered both --list calls identically. nextest’s parse_list_lines rejects any line not ending : test/: benchmark (footer = hard error), AND it runs two list passes: --list --format terse and --list --format terse --ignored. If the --ignored pass returns the test, nextest tags it ignored and cargo nextest run skips it and reports green with 0 run (“1 skipped”). That is precisely the silent-green failure the ticket feared, and it needs the empty --ignored output to avoid it. The nextest custom-harness docs and third-party harness fixes both flag this.

Gotcha 2: with_default_cli() (pre-seeds cli::Opts::default()) is what stops nextest’s per-test --nocapture --exact <name> invocation from reaching cucumber’s clap parser. Without it the run pass dies on --exact. Cucumber is kept as one unit (all 76 scenarios run per invocation), not per-scenario, which matches the position written in cucumber-rs#370: the maintainer explains process-per-scenario breaks @serial and re-parses features O(N²).

Verified behaviour of the working shim (this session):

  • cargo nextest list discovers cerebro-tui::cucumber as 1 test.
  • cargo nextest run -p cerebro-tui --test cucumber PASS in 0.6 seconds, the report on standard output shows 10 features / 76 scenarios (76 passed) / 409 steps (409 passed).
  • Failure propagation is real: pointing the harness at a missing features path flips it to FAIL ... exit 100 (“Cancelling due to test failure”), so run_and_exit still fails the binary. Green under nextest is trustworthy.

Full-suite shape for T06’s just test (measured, --workspace):

layercommandresult
unit+integration+cucumbercargo nextest run --workspace415 tests run, 0 skipped, about 25 seconds wall clock including compile
same under cargo testcargo test --workspace415 tests, about 40 seconds, no per-test isolation
doctestscargo test --workspace --docnextest runs 0 of these; 1 core doctest today, grows when T11 forces examples

Slowest real test is journal_entries_from_real_cortex_data at 12.6 seconds (it hits the live cortex), so a nextest slow-timeout warning floor anywhere in the 30-60 second band is safe; the standard’s 60 seconds is fine. The retries default of 0 needs writing down in .config/nextest.toml per the standard (ADR 9), and --all-features is a no-op today (no crate declares features), so just test can drop it until features exist.

Recommendation (feeds T06, no code in this ticket): keep cucumber as its own nextest-discoverable binary by landing the shim recorded here, then make just test = cargo nextest run --workspace (which then includes the whole 415-test set plus the cucumber unit), and add just doctest = cargo test --workspace --doc as a separate gate because nextest cannot run it. In CI, the separate cargo test -p cerebro-tui --test cucumber step in ci.yml becomes redundant once the shim is in and nextest is the runner, but it is lowest risk to keep it for one transition, then delete in T06. The doctest layer belongs in T06’s four-layer wiring, not here. CI runners need cargo-nextest installed (the cargo-binstall path ci.yml already uses).

Sources: the cargo nextest run/list output recorded in this session; the nextest design doc “Custom test harnesses”; nextest#122 and #96 (silent-skip and --format terse parsing); cucumber-rs#370 (single-unit rationale); rust-standard docs/standard/testing.md + ADR 9/10/11.