-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtest.sh
More file actions
57 lines (49 loc) · 1.16 KB
/
test.sh
File metadata and controls
57 lines (49 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env bash
# Runs all test suites in parallel.
# Spawns a shared API server for suites that need one.
#
# Usage:
# bash test.sh
set -euo pipefail
REPO_ROOT="$(cd "$(dirname "$0")" && pwd)"
LOG_DIR="$REPO_ROOT/.logs/test"
SERVER_LOG="$LOG_DIR/server.txt"
mkdir -p "$LOG_DIR"
# Spawn shared API server, capturing all output
SERVER_PID=""
cleanup() {
if [ -n "$SERVER_PID" ]; then
kill "$SERVER_PID" 2>/dev/null || true
wait "$SERVER_PID" 2>/dev/null || true
fi
}
trap cleanup EXIT
read -r PORT SERVER_PID < <(bash "$REPO_ROOT/test-spawn-api-server.sh" 2>"$SERVER_LOG") || {
echo "Failed to spawn API server. Log:" >&2
cat "$SERVER_LOG" >&2
exit 1
}
export OBJECTIVEAI_TEST_PORT="$PORT"
# Run all test suites in parallel.
# Each script prints exactly one line: "$MODULE: PASS N/N" or "$MODULE: FAIL N/N".
PIDS=()
for suite in \
objectiveai-rs \
objectiveai-api \
objectiveai-json-schema \
objectiveai-js \
objectiveai-py \
; do
bash "$REPO_ROOT/$suite/test.sh" &
PIDS+=($!)
done
# Wait for all suites, collect exit codes
FAILED=false
for pid in "${PIDS[@]}"; do
if ! wait "$pid"; then
FAILED=true
fi
done
if $FAILED; then
exit 1
fi