011: Testing Strategy¶
- Type: Operational
- Status: Accepted
- Date: 2026-12-02
- Author(s) / Deciders: João V. Farias
- Question: How are tests organized across unit, integration, and end-to-end boundaries, and what gates apply to changes?
Context¶
Booting live Wine prefixes and downloading large SDK archives on every pull request makes continuous integration slow and vulnerable to upstream network failures. Relying solely on isolated unit tests, however, misses CLI exit-code regressions, --json format drift, lockfile errors, and invalid Nushell signatures. A three-tier suite separates fast offline verification from live Wine execution.
Test pyramid and tiers¶
Tests are grouped into three Cargo test targets mapped to execution speed and external dependencies:
| Tier | Scope and purpose | Environment | Location |
|---|---|---|---|
| Unit tests | Config precedence, target merging, SHA-256 lockfile hashing, MiniJinja templates, winpath(...), safe exec path translation, DAG cycle checks, OS mismatch warnings, and Nushell script signature rules. |
Offline, no Wine binary required. | tests/unit/ |
| Integration tests | Compiled winesmith CLI invoked via assert_cmd against temp directories, shell stub runners, loopback HTTP servers, /proc guards, --locked, --json contracts, and live nu validation of generated completions. |
Offline using loopback HTTP and shell stubs (live nu when present on PATH). |
tests/integration/ |
| Live Wine E2E tests | Real system Wine or Kron4ek Wine 10 staging-amd64-wow64 runs covering win7 and win11 prefix boots, doctor --json, mounted drive hybrid tasks, and Kron4ek downloads (#[ignore]). |
Local host Wine or network runner. | tests/e2e/ |
White-box and black-box boundaries¶
Unit tests inspect internal config resolution, lexical path normalization, CRLF wrapper generation, lockfile sorting, and topological task ordering without spawning subprocesses. Integration tests invoke the compiled binary via CLI flags to verify exit codes (0 to 4), clean stdout under --json, lockfile errors, and nu --commands "source ..." syntax checks.
Requirements and restrictions¶
Four verification rules govern pull requests and defect fixes:
- Core non-Wine modules (
config,exec/paths,tasks,recipeURL/state resolution,completions) SHOULD maintain at least 80% line coverage when measured withcargo-llvm-cov. - Every pull request MUST pass all unit and hermetically mocked integration tests (
cargo test --all-targets) with zero skipped assertions. - Live Wine tests under
tests/e2e/MUST carry#[ignore]so PR CI remains offline and deterministic while local runs (cargo test --test e2e -- --ignored --nocapture) verify real Wine execution. - Every bug fix MUST add a regression test reproducing the original failure.
Alternatives¶
Running full live Wine downloads on every pull request catches upstream URL changes immediately, though network instability and prefix boot latency block routine commits. Omitting automated integration and shell-syntax tests lowers setup cost, yet lets subtle quoting bugs and broken extern --strict signatures slip into releases.
Decision¶
Adopt this three-tier Rust test pyramid: mandatory unit and hermetic CLI integration tests on every pull request, and #[ignore] live Wine E2E tests in tests/e2e/. Integration suites run live nu signature verification when nu is installed, while core non-Wine modules target at least 80% coverage.
Consequences¶
Positives¶
Pull request test suites execute deterministically without external network calls. Black-box CLI and Nushell tests detect regressions in exit codes, JSON schemas, and strict command signatures before tagging releases.
Negatives¶
Integration suites rely on maintained fake runner shell scripts and loopback HTTP fixtures to simulate upstream Wine and archive servers. Upstream SDK URL changes are discovered during manual E2E runs (--ignored) rather than on every PR.