diff --git a/.github/scripts/test-bootstrap-state.sh b/.github/scripts/test-bootstrap-state.sh new file mode 100755 index 0000000..b961939 --- /dev/null +++ b/.github/scripts/test-bootstrap-state.sh @@ -0,0 +1,115 @@ +#!/usr/bin/env bash +# +# Unit tests for strip_host_hooks() in the devcontainer bootstrap script. +# +# Sources the template (made importable by its exec-guard) and exercises the +# hook-stripping logic on fixture settings.json blobs: gryph/cot commands are +# removed, rtk + user hooks are preserved, emptied events are pruned, the +# transform is idempotent, and malformed/missing input doesn't crash. +# +# Run: .github/scripts/test-bootstrap-state.sh +# CI: wired into .github/workflows/shellcheck.yml +set -euo pipefail + +here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +repo_root="$(cd "$here/../.." && pwd)" +tmpl="$repo_root/templates/devcontainer/scripts/bootstrap-state.sh.tmpl" + +# Source the prod template. Its exec-guard stops the init/sync dispatch from +# firing; we only want the strip_host_hooks() definition. +# shellcheck source=../../../templates/devcontainer/scripts/bootstrap-state.sh.tmpl +# shellcheck disable=SC1090 +source "$tmpl" + +pass=0 +fail=0 +assert_eq() { #