Six test runner scripts at tests/: run-rust, run-godot, run-ipc-fixtures, run-ipc-protocol, run-ipc-integration, run-all. Plus run-ipc-benchmark for Layer 3 timing. All produce structured JSON stdout, support --filter, and exit 0/non-zero. Makefile targets updated to delegate to scripts. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
55 lines
1.6 KiB
Bash
Executable File
55 lines
1.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# tests/run-rust: Run Rust test suite via cargo nextest (D-030)
|
|
# Exit: 0 = all pass, non-zero = failure
|
|
# Stdout: {"suite":"rust","total":N,"passed":N,"failed":N,"duration_ms":N}
|
|
set -euo pipefail
|
|
|
|
FILTER=""
|
|
while [[ $# -gt 0 ]]; do
|
|
case "$1" in
|
|
--filter) FILTER="${2:-}"; shift 2 ;;
|
|
--filter=*) FILTER="${1#--filter=}"; shift ;;
|
|
*) echo "Unknown argument: $1" >&2; exit 2 ;;
|
|
esac
|
|
done
|
|
|
|
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
cd "$REPO_ROOT/server"
|
|
|
|
START_MS=$(date +%s%3N)
|
|
TMPOUT=$(mktemp)
|
|
|
|
NEXTEST_ARGS=(nextest run --color never)
|
|
if [[ -n "$FILTER" ]]; then
|
|
NEXTEST_ARGS+=(-E "test(~${FILTER})")
|
|
fi
|
|
|
|
set +e
|
|
cargo "${NEXTEST_ARGS[@]}" 2>&1 | tee "$TMPOUT" >&2
|
|
EXIT_CODE=${PIPESTATUS[0]}
|
|
set -e
|
|
|
|
END_MS=$(date +%s%3N)
|
|
DURATION_MS=$((END_MS - START_MS))
|
|
|
|
# Parse nextest summary: " Summary [ 0.123s] N tests run: X passed[, Y failed], Z skipped"
|
|
# (older nextest uses "Finished", newer uses "Summary" — match both)
|
|
SUMMARY=$(grep -E "^\s*(Summary|Finished)" "$TMPOUT" | tail -1 || true)
|
|
|
|
_extract_num() {
|
|
local haystack="$1" pattern="$2"
|
|
echo "$haystack" | grep -oE "[0-9]+ $pattern" | grep -oE '^[0-9]+' || echo 0
|
|
}
|
|
|
|
TOTAL=0; PASSED=0; FAILED=0
|
|
if [[ -n "$SUMMARY" ]]; then
|
|
TOTAL=$(_extract_num "$SUMMARY" "tests? run")
|
|
PASSED=$(_extract_num "$SUMMARY" "passed")
|
|
FAILED=$(_extract_num "$SUMMARY" "failed")
|
|
fi
|
|
|
|
rm -f "$TMPOUT"
|
|
printf '{"suite":"rust","total":%d,"passed":%d,"failed":%d,"duration_ms":%d}\n' \
|
|
"${TOTAL:-0}" "${PASSED:-0}" "${FAILED:-0}" "$DURATION_MS"
|
|
exit $EXIT_CODE
|