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
26 changes: 26 additions & 0 deletions .config/nextest.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# cargo-nextest configuration.
#
# Install: `cargo install --locked cargo-nextest`
# Run : `cargo nextest run --workspace`
#
# The default profile is what pre-commit / day-to-day runs use. The `slow`
# profile additionally runs tests marked `#[ignore]` — used in CI and for the
# periodic local sweep:
#
# cargo nextest run --workspace --profile slow

[profile.default]
# Show the slowest tests first when something fails — easier triage than the
# default ordering.
status-level = "fail"
failure-output = "immediate-final"
final-status-level = "slow"

# Tests that legitimately need to spawn real subprocesses can occasionally
# exceed cargo's default 60s timeout under cold-cache CI. 120s gives headroom
# without masking a genuine hang.
slow-timeout = { period = "60s", terminate-after = 2 }

[profile.slow]
# Inherits from default; the CLI invocation toggles `--run-ignored all`.
slow-timeout = { period = "90s", terminate-after = 2 }
14 changes: 12 additions & 2 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,19 @@ echo "pre-commit: cargo clippy --all-targets -- -D warnings"
cargo clippy --all-targets --quiet -- -D warnings

# Tests are gated separately. CI runs them regardless.
#
# Prefer `cargo nextest` when it's on PATH — same coverage, faster wall
# clock (~17s vs ~26s on this workspace, M-series, warm cache). Falls back
# to `cargo test --quiet` so contributors without nextest aren't blocked.
# CONTRIBUTING.md documents how to install it.
if [[ "${HEW_HOOK_NO_TESTS:-}" != "1" ]]; then
echo "pre-commit: cargo test"
cargo test --quiet
if command -v cargo-nextest >/dev/null 2>&1; then
echo "pre-commit: cargo nextest run --workspace"
cargo nextest run --workspace
else
echo "pre-commit: cargo test"
cargo test --quiet
fi
fi

echo "pre-commit: ok"
5 changes: 4 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ jobs:
# actually `rustup-init`). Hit us on macos-latest/1.91 — keep this off.
cache-bin: "false"
- run: cargo build --all-targets --locked
- run: cargo test --all-targets --locked
# `--include-ignored` runs the `#[ignore = "slow"]` tests that the
# pre-commit gate and default `cargo test` invocation skip. CI is the
# one place that periodic-sweep coverage must never go missing.
- run: cargo test --all-targets --locked -- --include-ignored

audit:
name: cargo-audit
Expand Down
43 changes: 42 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,52 @@ Allowed prefixes: `feat`, `fix`, `chore`, `docs`, `refactor`, `perf`,

```sh
cargo build # 1.x s incremental, ~30s cold
cargo test # full suite; ~2s after warm cache
cargo test # full suite; ~25s warm cache
cargo clippy --all-targets -- -D warnings
cargo fmt --all
```

### Faster tests via `cargo-nextest` (recommended)

The default `cargo test` runs each test binary serially and reports
per-test output. [`cargo-nextest`](https://nexte.st) runs every binary
in parallel with a tighter scheduler — on this workspace it cuts the
suite from ~25s to under 20s on warm cache, and the `.githooks/pre-commit`
hook automatically prefers it when present.

Install once per machine:

```sh
cargo install --locked cargo-nextest
```

Then:

```sh
cargo nextest run --workspace # default profile — skips #[ignore]d tests
cargo nextest run --workspace --profile slow --run-ignored all # periodic full sweep
```

Plain `cargo test` is still supported (CI keeps it in the matrix to
guarantee both invocations stay green).

### Slow tests gated behind `#[ignore = "slow"]`

A small set of heavy e2e tests — parallel-loop worktree drivers, the
real-git merge-conflict simulator — carry `#[ignore = "slow"]` so the
default `cargo test` / `cargo nextest run` keeps the pre-commit gate fast.
Run them explicitly before tagging a release or merging anything that
touches the loop runner:

```sh
cargo test --workspace -- --include-ignored
# or
cargo nextest run --workspace --profile slow --run-ignored all
```

CI runs the full sweep on every PR, so missing this locally never lands
silently.

Tests are organised as:

- **Unit tests** alongside each module under `hew-core/src/`.
Expand Down
2 changes: 2 additions & 0 deletions hew/tests/loop_parallel_e2e.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ fn read_manifest(repo: &Path) -> serde_json::Value {
}

#[test]
#[ignore = "slow"]
fn e2e_parallel_jobs_2_with_mock_spawner() {
if !git_available() {
eprintln!("git not on PATH, skipping");
Expand Down Expand Up @@ -409,6 +410,7 @@ fn e2e_parallel_jobs_2_with_mock_spawner() {
}

#[test]
#[ignore = "slow"]
fn e2e_parallel_merge_conflict_files_bug_task() {
if !git_available() {
eprintln!("git not on PATH, skipping");
Expand Down
Loading