aboutsummaryrefslogtreecommitdiff
path: root/scripts/testing/run-maint-scenarios.sh
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-07-25 15:00:44 -0500
committerCraig Jennings <c@cjennings.net>2026-07-25 15:00:44 -0500
commitd52da959bc416e09bc0f3e54994563bd80e19c64 (patch)
treeadaf2ce086e87c548c695e5b4a82eb63f7c926c8 /scripts/testing/run-maint-scenarios.sh
parentd25711a61172ffb7b622a6a834ed17fdf52a54de (diff)
downloadarchsetup-d52da959bc416e09bc0f3e54994563bd80e19c64.tar.gz
archsetup-d52da959bc416e09bc0f3e54994563bd80e19c64.zip
refactor(test): share runner and scenario contracts
Diffstat (limited to 'scripts/testing/run-maint-scenarios.sh')
-rw-r--r--scripts/testing/run-maint-scenarios.sh65
1 files changed, 1 insertions, 64 deletions
diff --git a/scripts/testing/run-maint-scenarios.sh b/scripts/testing/run-maint-scenarios.sh
index 448f6d9..17481e9 100644
--- a/scripts/testing/run-maint-scenarios.sh
+++ b/scripts/testing/run-maint-scenarios.sh
@@ -35,6 +35,7 @@ PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
source "$SCRIPT_DIR/lib/logging.sh"
source "$SCRIPT_DIR/lib/vm-utils.sh"
+source "$SCRIPT_DIR/lib/maint-scenario.sh"
SCENARIO_DIR="${MAINT_SCENARIO_DIR:-$SCRIPT_DIR/maint-scenarios}"
MAINT_SRC="${MAINT_SRC:-$HOME/.dotfiles/maint/src/maint}"
@@ -72,32 +73,6 @@ S_FILES=() S_NAMES=() S_DESCS=() S_GROUPS=()
# Groups in first-appearance order.
GROUP_ORDER=()
-# Extract one declared var from a scenario file by sourcing it in a clean
-# subshell. Scenario files must only define vars + functions; any top-level
-# command fails here (no helpers exist), which is the contract.
-_scenario_var() { # <file> <varname>
- bash -c 'set -eu; source "$1" || exit 9; eval "printf %s \"\${$2-}\""' \
- _probe "$1" "$2" 2>/dev/null
-}
-
-_validate_scenario() { # <file> -> fatal on contract violation
- local f="$1" base probe_err
- base=$(basename "$f")
- probe_err=$(bash -c 'set -eu; source "$1"
- : "${SCENARIO_DESC:?missing SCENARIO_DESC}"
- : "${SCENARIO_GROUP:?missing SCENARIO_GROUP}"
- : "${SCENARIO_PROFILES:?missing SCENARIO_PROFILES}"
- for p in $SCENARIO_PROFILES; do
- case "$p" in btrfs|zfs|any) ;; *)
- echo "bad profile token: $p" >&2; exit 1 ;;
- esac
- done
- declare -f scenario_break scenario_fix scenario_assert >/dev/null \
- || { echo "missing scenario_break/fix/assert" >&2; exit 1; }' \
- _probe "$f" 2>&1 >/dev/null) \
- || fatal "scenario contract violation in $base: $probe_err"
-}
-
_profile_matches() { # <profiles> -> 0 if scenario runs under $FS_PROFILE
local p
for p in $1; do
@@ -283,44 +258,6 @@ import json; print(len(json.load(open('$RESULTS_DIR/bootstrap-status.json'))['me
PASS=() FAIL=()
-run_scenario() { # <index>
- local i="$1" name="${S_NAMES[$1]}" f="${S_FILES[$1]}"
- section "Scenario: $name — ${S_DESCS[$1]}"
- # Sourced in the runner's shell so break/fix/assert see the helpers;
- # unset afterwards so the next scenario can't inherit stale functions.
- # shellcheck disable=SC1090
- source "$f"
- local ok=true
- step "break"
- if ! scenario_break; then
- error "$name: break step failed"
- ok=false
- fi
- if [ "$ok" = "true" ]; then
- step "fix"
- if ! scenario_fix; then
- error "$name: fix step failed"
- ok=false
- fi
- fi
- if [ "$ok" = "true" ]; then
- step "assert"
- if ! scenario_assert; then
- error "$name: post-state assertion failed"
- ok=false
- fi
- fi
- unset -f scenario_break scenario_fix scenario_assert
- unset SCENARIO_DESC SCENARIO_GROUP SCENARIO_PROFILES
- if [ "$ok" = "true" ]; then
- success "PASS: $name"
- PASS+=("$name")
- else
- error "FAIL: $name"
- FAIL+=("$name")
- fi
-}
-
section "Preparing VM"
stop_qemu 2>/dev/null || true
step "Restoring clean-install snapshot"