#!/bin/bash
# usage: run-a-intake.sh <exe> <testfn> <tag> <secret> <outdir>
# Role A on HFENDULEAM, run from the gate worktree at the intake head.
cd /c/Users/decid/Documents/projects/spt-core/.worktrees/gate-9144b8f8
for v in $(env | grep -E '^(OWL_|SPT_)' | cut -d= -f1); do unset $v; done
export SPT_TWO_HOST=1 SPT_TWO_HOST_ROLE=a SPT_TWO_HOST_SECRET="$4" SPT_TWO_HOST_PEER_IP=192.168.1.168
{
  echo "exe=$1 head=$(git rev-parse HEAD) dirty=$(git status --porcelain | wc -l) start=$(date -u +%FT%TZ)"
  ls -la --time-style=full-iso "$1"
} > "$5/$3-a.raw"
S0=$(date +%s%N)
"$1" --nocapture --test-threads 1 --exact "$2" >> "$5/$3-a.raw" 2>&1
RC=$?
echo "rc=$RC wall_ms=$(( ($(date +%s%N) - S0)/1000000 ))" >> "$5/$3-a.raw"
echo $RC > "$5/$3-a.exit"
