Use tmux for test runner — detachable SSH sessions

Tests now run inside a tmux session so you can disconnect and
reconnect without interrupting multi-hour test runs.

Changes:
- create-vm.sh: cloud-init no longer auto-runs tests, just provisions
  packages and clones the repo. Installs a `darkforge-test` command
  in /usr/local/bin that wraps run-in-vm.sh in tmux.
- run-in-vm.sh: detects when called as `darkforge-test` and re-execs
  inside a tmux session named "darkforge". --tmux flag for internal use.
- README updated with tmux workflow (detach/reattach instructions).

Workflow:
  ssh darkforge@<ip>
  darkforge-test --quick    # starts in tmux
  Ctrl+B D                  # detach, go do other things
  tmux attach -t darkforge  # come back later

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-19 13:59:52 +01:00
parent c464e0eec9
commit c35ba5dc0f
3 changed files with 102 additions and 45 deletions

View File

@@ -18,11 +18,33 @@
# 10. Generates a JSON + text report
#
# Usage:
# bash run-in-vm.sh # full run (2-6 hours depending on hardware)
# bash run-in-vm.sh --quick # skip toolchain/kernel/ISO (30 min)
# bash run-in-vm.sh --no-build # skip toolchain bootstrap (1 hour)
# darkforge-test # runs in tmux (detachable)
# darkforge-test --quick # fast mode in tmux
# bash run-in-vm.sh # direct run (2-6 hours)
# bash run-in-vm.sh --quick # direct, skip toolchain/kernel/ISO (30 min)
# bash run-in-vm.sh --no-build # direct, skip toolchain bootstrap (1 hour)
#
# tmux controls:
# Ctrl+B then D — detach (tests keep running)
# tmux attach -t darkforge — reattach
# ============================================================================
# --- If called as "darkforge-test", wrap in tmux ----------------------------
TMUX_MODE=false
for arg in "$@"; do
[ "$arg" = "--tmux" ] && TMUX_MODE=true
done
if [ "$TMUX_MODE" = false ] && [ "$(basename "$0")" = "darkforge-test" ]; then
# Re-exec ourselves inside a tmux session
ARGS="$*"
exec tmux new-session -d -s darkforge \
"bash $(readlink -f "$0") --tmux ${ARGS}; echo ''; echo 'Tests finished. Press Enter to close.'; read" \; \
attach-session -t darkforge
fi
# Strip --tmux from args for the actual test run
set -- $(echo "$@" | sed 's/--tmux//g')
set -uo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"