first commit

This commit is contained in:
2026-06-09 17:31:10 -07:00
commit babfcb8666
7 changed files with 3298 additions and 0 deletions
+99
View File
@@ -0,0 +1,99 @@
#!/usr/bin/env bash
set -uo pipefail
require_env() {
local name="$1"
if [[ -z "${!name:-}" ]]; then
echo "ERROR: $name is required" >&2
exit 1
fi
}
strip_query_fragment() {
local s="$1"
s="${s%%\#*}"
s="${s%%\?*}"
printf '%s' "$s"
}
derive_wrapper_urls() {
local src clean base
src="$1"
clean="$(strip_query_fragment "$src")"
case "$clean" in
*/wrapper.sh) base="${clean%/wrapper.sh}" ;;
*/wrapper.bash) base="${clean%/wrapper.bash}" ;;
*/wrapper.ps1) base="${clean%/wrapper.ps1}" ;;
*/) base="${clean%/}" ;;
*) base="${clean%/*}" ;;
esac
WRAPPER_SH_URL="$base/wrapper.sh"
WRAPPER_BASH_URL="$base/wrapper.bash"
}
run_case() {
local desc="$1"
shift
printf 'Test: %-46s' "$desc"
if "$@"; then
echo "✅ PASS"
else
local rc=$?
echo "❌ FAIL (rc=$rc)"
return "$rc"
fi
}
exercise_wrapper() {
local label="$1"
local src_url="$2"
(
set +u
eval "$(curl -fsSL "$src_url")" || exit 90
command -v mon >/dev/null || exit 91
command -v mon_detail >/dev/null || exit 92
command -v mon_complete >/dev/null || exit 93
command -v mon_error >/dev/null || exit 94
mon_detail "flare-summary" '{"source":"src_test","wrapper":"'"$label"'","phase":"bootstrap"}' || exit 100
sleep 0.2
mon "${label}: starting" || exit 101
sleep 0.2
mon_detail "${label}: detail blob" '{"nginx":"1.18.0","openssl":"3.0.2"}' || exit 102
sleep 0.2
mon_complete "${label}: completed task" || exit 103
sleep 0.2
mon_error "${label}: error case" || exit 104
sleep 0.2
mon "${label}: manual title" || exit 105
)
}
main() {
require_env "__FLARE_SRC"
derive_wrapper_urls "$__FLARE_SRC"
echo "Using source seed : $__FLARE_SRC"
echo "Derived wrapper.sh : $WRAPPER_SH_URL"
echo "Derived wrapper.bash: $WRAPPER_BASH_URL"
echo
local failures=0
run_case "source wrapper.sh then use functions" exercise_wrapper "wrapper.sh" "$WRAPPER_SH_URL" || ((failures+=1))
run_case "source wrapper.bash then use functions" exercise_wrapper "wrapper.bash" "$WRAPPER_BASH_URL" || ((failures+=1))
echo
if (( failures == 0 )); then
echo "🏁 All wrapper-source tests passed."
else
echo "🏁 Completed with $failures failing test group(s)."
exit 1
fi
}
main "$@"