Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions .config/nextest.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# cargo-nextest configuration for Weaver.
#
# Setup scripts are an experimental nextest feature; the `[scripts.setup.*]`
# tables below need this opt-in.
experimental = ["setup-scripts"]
#
# Scope: every `cargo nextest` invocation, including `make test` and the
# coverage lane. nextest does not run doctests, which `make test` runs
# separately with `cargo test --doc`.
Expand Down Expand Up @@ -41,3 +45,79 @@ max-threads = 1
filter = 'binary(=load_manifest) | binary(=compile_time) | binary(=missing_docs_policy)'
test-group = "nested-cargo-builds"
slow-timeout = { period = "120s", terminate-after = 5 }

# Every test binary selected below compiles something in a nested cargo or
# trybuild build inside its own timed body. If nothing has filled those build
# directories first, the first test to reach each pays a cold dependency build
# and its timeout fails an assertion that is sound. These setup scripts pay for
# the builds once, before any selected test starts, under their own allowance,
# so every timed body then finds the directories warm. (The same move as
# ortho-config #710 and whitaker #518.)
#
# `weaver-binary` builds the `weaver` executable that the end-to-end binaries
# otherwise build on first use, inside whichever test reaches it first. It uses
# the exact flags of `make test` (`CARGO_FLAGS` in the Makefile): a build with
# a different feature set would overwrite `target/debug/weaver` with an
# executable that lacks the features the snapshots need (the Python graph-slice
# snapshots fail), so keep the two in step. After `make test`'s own build it
# finds everything fresh and does no work.
# The `warm-*` scripts run the trybuild and example-rendering binaries once,
# one script per binary. A failing test in a warm-up makes its script exit
# non-zero and nextest then runs none of the tests it serves, so the run fails
# with that test's own output. Every command is `--frozen` (locked and
# offline): the gate has already fetched, so none may resolve or touch the
# registry. The `warm-*` scripts pass `--all-features`, as `make test` does, because `weaver-plugins`'
# `compile_time` test only exists with its `test-support` feature, and a
# differently featured build would not be the one the timed run reuses.
[scripts.setup.weaver-binary]
command = ["cargo", "build", "--frozen", "--workspace", "--all-targets", "--all-features"]
slow-timeout = { period = "300s", terminate-after = 3 }

[scripts.setup.warm-config-compile]
command = ["cargo", "test", "--frozen", "--all-features", "-p", "weaver-config", "--test", "compile_time"]
slow-timeout = { period = "300s", terminate-after = 3 }

[scripts.setup.warm-docs-gate-compile-time]
command = ["cargo", "test", "--frozen", "--all-features", "-p", "weaver-docs-gate", "--test", "compile_time"]
slow-timeout = { period = "300s", terminate-after = 3 }

[scripts.setup.warm-docs-gate-load-manifest]
command = ["cargo", "test", "--frozen", "--all-features", "-p", "weaver-docs-gate", "--test", "load_manifest"]
slow-timeout = { period = "300s", terminate-after = 3 }

[scripts.setup.warm-plugins-compile]
command = ["cargo", "test", "--frozen", "--all-features", "-p", "weaver-plugins", "--test", "compile_time"]
slow-timeout = { period = "300s", terminate-after = 3 }

[scripts.setup.warm-cli-docs-policy]
command = ["cargo", "test", "--frozen", "--all-features", "-p", "weaver-cli", "--test", "missing_docs_policy"]
slow-timeout = { period = "300s", terminate-after = 3 }

[[profile.default.scripts]]
filter = 'package(weaver-e2e)'
setup = "weaver-binary"

# One script per binary, each selected by the binary it warms, so a run that
# selects one of these tests warms only that binary's build and an unrelated
# failing binary cannot stop it. A new nested-build test binary needs both an
# entry in the override's `filter` and a script rule here (docs/developers-guide.md
# section 3.3).
[[profile.default.scripts]]
filter = 'binary_id(=weaver-config::compile_time)'
setup = "warm-config-compile"

[[profile.default.scripts]]
filter = 'binary_id(=weaver-docs-gate::compile_time)'
setup = "warm-docs-gate-compile-time"

[[profile.default.scripts]]
filter = 'binary_id(=weaver-docs-gate::load_manifest)'
setup = "warm-docs-gate-load-manifest"

[[profile.default.scripts]]
filter = 'binary_id(=weaver-plugins::compile_time)'
setup = "warm-plugins-compile"

[[profile.default.scripts]]
filter = 'binary_id(=weaver-cli::missing_docs_policy)'
setup = "warm-cli-docs-policy"
6 changes: 3 additions & 3 deletions crates/weaver-docs-gate/tests/load_manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,12 +277,12 @@ fn read_file(dir_path: &Utf8Path, file_name: &str) -> TestResult<Result<String,

/// Run the documented matrix-rendering example with caller-supplied args.
fn run_render_boundary_matrix(args: &[&str]) -> TestResult<Output> {
// The enclosing test build has already fetched the locked dependencies, so
// this nested cargo must not resolve or download anything. Everything
// after `--` belongs to the example, not to cargo.
Command::new(env!("CARGO"))
.args([
"run",
// The enclosing test build has already fetched the locked
// dependencies, so this nested cargo must not resolve or
// download anything.
"--frozen",
"-p",
"weaver-docs-gate",
Expand Down
27 changes: 25 additions & 2 deletions docs/developers-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,31 @@ builds it with the other targets before any test starts.
`tests/workflow_contracts/nextest_config_test.py` reads the file with `tomllib`
and checks the group, the override and the timeouts; it starts no `cargo`. The
Concordat `nested-cargo-nextest` rule (NC-004, NC-005) holds the same property
from outside. A new test binary that starts a compiler joins the override's
`filter`.
from outside. A new test binary that starts a compiler needs two entries in
`.config/nextest.toml`, and leaving either out leaves it unprepared:

- Add it to the override's `filter`, which puts it in the serial group.
- Add a `[scripts.setup.warm-…]` script that runs it with
`cargo test --frozen --all-features -p <package> --test <binary>`, and a
`[[profile.default.scripts]]` rule whose `filter` selects that binary with
`binary_id(=<package>::<binary>)`, which the Concordat reader can follow
where it cannot follow an intersection. The script pays for the nested or
trybuild build once, before any selected test starts, so the timed body finds
it built.

Each warm-up script has its own allowance of 300 seconds per period and
terminates after three periods. A test in a warm-up that fails makes its script
fail, and nextest then runs none of the tests that script serves and reports
the failing test's own output. Each rule selects one binary, so a run that
selects only some of these tests warms only those, and an unrelated failing
binary cannot stop them. The isolation is between binaries, not between test
cases: `cargo test --test <binary>` runs every non-ignored case in its binary,
so a failing case in a binary blocks a run filtered to another case of the same
binary. Every script uses `--frozen`, so it never resolves or touches the
registry; run `cargo fetch --locked` first on a clean tree. The `weaver-binary`
script builds `weaver` with the flags of `make test`, and must keep them in
step with it, or it overwrites `target/debug/weaver` with a binary that lacks
the features the snapshots need.

## 4 Workspace lint policy

Expand Down
Loading