Files
moonwell-client-core/scripts/doc-tests.sh
T
Sam Sung 927f0117fb Test gates run under cargo-nextest, doctests beside them (#2036)
The test gates ran `cargo test`, which runs the workspace's test binaries one after another. On a warm tree the workspace's tests take 103 s that way, and 59 s under cargo-nextest, which runs every binary's tests in one pool; all 10,411 pass both ways.

`check.sh` and `gates.sh` now run tests through `scripts/unit-tests.sh`: cargo-nextest where it is installed, else `cargo test` as before. nextest runs no doctests, so `scripts/doc-tests.sh` runs those of the library crates in scope. Each gate keeps its environment (`BENILLA_REQUIRE_DATA`, `WOW_DATA=`, the skip log), and a failing run's summary now catches nextest's `FAIL` lines. CI is unchanged.

Test: this land's own gates run under it.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 10:27:18 +07:00

25 lines
1.1 KiB
Bash
Executable File

#!/usr/bin/env bash
# The doctests `scripts/unit-tests.sh` leaves to `cargo test` under cargo-nextest, which runs none:
# those of the library packages among the ones named, or of every workspace library with
# `--workspace`. Without nextest the unit-test run has run them already, so this does nothing.
#
# scripts/doc-tests.sh --workspace
# scripts/doc-tests.sh benilla-ui benilla-app
set -euo pipefail
cargo nextest --version >/dev/null 2>&1 || exit 0
root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
flags="$(python3 - "$root" "$@" <<'PY'
import json, subprocess, sys
root, want = sys.argv[1], sys.argv[2:]
meta = json.loads(subprocess.run(["cargo", "metadata", "--format-version", "1", "--no-deps"],
capture_output=True, text=True, cwd=root, check=True).stdout)
libs = [p["name"] for p in meta["packages"]
if any("lib" in t["kind"] for t in p["targets"])
and (want == ["--workspace"] or p["name"] in want)]
print(" ".join("-p " + n for n in sorted(libs)))
PY
)"
[ -n "$flags" ] || exit 0
# shellcheck disable=SC2086 # one word per flag
exec cargo test --no-fail-fast --doc $flags