#!/usr/bin/env bash
cd /c/Users/decid/Documents/projects/spt-core/.worktrees/gate-ns23-w1 || exit 1
reap() {
  n=0
  for p in $(powershell -NoProfile -Command "Get-CimInstance Win32_Process -Filter \"Name='spt.exe'\" | Where-Object {\$_.ExecutablePath -like '*gate-ns23-w1*'} | Select-Object -ExpandProperty ProcessId" 2>/dev/null); do
    powershell -NoProfile -Command "Stop-Process -Id $p -Force" 2>/dev/null; n=$((n+1))
  done
  echo "reap-by-path count=$n"
}
reap
env -u OWL_SESSION_ID -u SPT_AGENT_ID -u SPT_ENDPOINT_ID -u SPT_HOME cargo clippy --workspace --all-targets -- -D warnings > G_clippy.raw 2>&1; echo $? > G_clippy.exit
env -u OWL_SESSION_ID -u SPT_AGENT_ID -u SPT_ENDPOINT_ID -u SPT_HOME traceable-reqs check > G_treqs.raw 2>&1; echo $? > G_treqs.exit
env -u OWL_SESSION_ID -u SPT_AGENT_ID -u SPT_ENDPOINT_ID -u SPT_HOME cargo run -p xtask -- check > G_xtask.raw 2>&1; echo $? > G_xtask.exit
env -u OWL_SESSION_ID -u SPT_AGENT_ID -u SPT_ENDPOINT_ID -u SPT_HOME cargo nextest run -p spt --bins > G_spt_bins.raw 2>&1; echo $? > G_spt_bins.exit
reap
echo DRIVER_COMPLETE
