(exe: string, dir: string, n: number)
| 78 | // single parseable summary line. Unix (linux+macos) flavor; the election logic |
| 79 | // under test is OS-agnostic, the shell around it is not. |
| 80 | const unixWaveScript = (exe: string, dir: string, n: number): string => |
| 81 | [ |
| 82 | "set -u", |
| 83 | `EXE=${exe}`, |
| 84 | `D=${dir}`, |
| 85 | // `timeout` is GNU coreutils: present on Linux, absent on the macOS guest |
| 86 | // (where it would be `gtimeout`). Fall back to no wrapper; the test's own |
| 87 | // 300s budget and `tools search` self-completing are the backstops. |
| 88 | "TO=$(command -v timeout 2>/dev/null || command -v gtimeout 2>/dev/null || true)", |
| 89 | "run_client() {", |
| 90 | ' if [ -n "$TO" ]; then', |
| 91 | ` "$TO" 120 env EXECUTOR_DATA_DIR="$D" EXECUTOR_SCOPE_DIR="$D" "$EXE" tools search "probe-$1" >"$D/out-$1" 2>&1`, |
| 92 | " else", |
| 93 | ` env EXECUTOR_DATA_DIR="$D" EXECUTOR_SCOPE_DIR="$D" "$EXE" tools search "probe-$1" >"$D/out-$1" 2>&1`, |
| 94 | " fi", |
| 95 | ' echo $? >"$D/rc-$1"', |
| 96 | "}", |
| 97 | `i=1; while [ $i -le ${n} ]; do run_client $i & i=$((i+1)); done; wait`, |
| 98 | "ok=0; spawned=0; i=1", |
| 99 | `while [ $i -le ${n} ]; do`, |
| 100 | ' rc=$(cat "$D/rc-$i" 2>/dev/null || echo X); [ "$rc" = "0" ] && ok=$((ok+1))', |
| 101 | ' grep -q "Starting daemon" "$D/out-$i" 2>/dev/null && spawned=$((spawned+1))', |
| 102 | " i=$((i+1)); done", |
| 103 | `manifests=$(ls "$D"/daemon-active-* 2>/dev/null | wc -l | tr -d ' ')`, |
| 104 | `port=$(cat "$D"/daemon-localhost-*.json 2>/dev/null | sed -n 's/.*"port":[ ]*\\([0-9]*\\).*/\\1/p' | head -1)`, |
| 105 | `health=$(curl -s -o /dev/null -w '%{http_code}' --max-time 5 "http://localhost:$port/api/health" 2>/dev/null || echo 000)`, |
| 106 | `echo "PROBE_SUMMARY ok=$ok n=${n} spawned=$spawned manifests=$manifests port=$port health=$health"`, |
| 107 | ].join("\n"); |
| 108 | |
| 109 | const parseSummary = (stdout: string): Record<string, string> => { |
| 110 | const line = stdout.split("\n").find((l) => l.includes("PROBE_SUMMARY")); |
no outgoing calls
no test coverage detected