Files
nextcraft/apps/ai-service/scripts/test.sh
T
CIAgent 02d324b896 test(P01): harness wiring — coverage, timeouts, markers, turbo pipeline, leak fixes (REQ-7-001)
- pytest-cov + [tool.coverage] config (95% branch, term-missing every run); c8
  wired around tsx --test in web (95.9%) + cli (76.9%) — no runner swap (D-052)
- markers fast/real_server/userns under --strict-markers (D-053); real_server ×5
  uvicorn suites + userns ×2 files + 1 test (test_manager real-unshare catch);
  test_sandbox_agent unmarked per G-105 (plain stdlib process), outlier timeout(120)
- pytest-timeout signal method: 60s global, 180s via conftest collection hook for
  marked tiers; BOTH tiers probe-proven (60.07s / 180.07s)
- FAST=1 fast subset: 621 passed, 49 deselected, 55.4s bare (MH-M2 <60s holds);
  FAST implies NO_COV per verifier GAP-1 fix
- CLI fresh-clone E2E env-gated (CLI_E2E=1, D-055): visible skip, opt-in green
  (902s aggregate step budget); path-invocation silent return → visible skip
- web#test turbo task + root test/web:test/web:test:cov/cli:test:cov/cli:test:e2e/
  ai:test:fast scripts; pnpm test runs 3/3 workspaces (3m)
- leak fixes: AI_PROVIDER via monkeypatch (probe-proven restore),
  seed_verified_identity check-first + IntegrityError-only, test_engine.py:428
  Path.read_text (P3 item done early)
- PLAN.md count discipline: baseline 670/53/64 (671→670 collection fact; 61→64
  v0.5.7 hotfix tests); Task 1-1-04 no-split decision recorded (6.8s combined)

---ci---
phase: 1
milestone: v0.7
status: execute
---/ci---
2026-09-26 17:40:05 +00:00

39 lines
1.2 KiB
Bash
Executable File

#!/usr/bin/env bash
# Test runner: pytest via venv — mock provider only, zero network calls.
#
# P1 harness wiring (Task 1-1-01/1-1-02):
# default full suite WITH coverage (term + missing lines)
# NO_COV=1 coverage off (bare pytest flags, no --cov args)
# FAST=1 fast subset only: -m "not real_server and not userns"
#
# Extra args pass through: `bash scripts/test.sh tests/api -k foo`.
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
APP_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
VENV="$APP_DIR/.venv"
if [ ! -x "$VENV/bin/pytest" ]; then
echo "venv missing — run scripts/bootstrap.sh first" >&2
exit 1
fi
cd "$APP_DIR"
# Assemble args; pytest arg order: later options win, so user-passed "$@"
# always overrides the wiring below.
ARGS=("-q")
if [ "${FAST:-0}" = "1" ]; then
# Fast subset: exclude the real-server and user-namespace tiers.
# The fast loop is the dev loop — coverage evidence comes from the full run.
ARGS+=("-m" "not real_server and not userns")
NO_COV=1
fi
if [ "${NO_COV:-0}" = "1" ]; then
# Opt-out: bare run, no coverage tooling at all.
ARGS+=()
else
ARGS+=("--cov=ai_service" "--cov-report=term-missing")
fi
exec "$VENV/bin/pytest" "${ARGS[@]}" "$@"