mirror of
https://github.com/theupriser/steamify-cachyos-dev.git
synced 2026-10-05 12:45:56 +02:00
test: golden status and plan output of the bash backend in a bubblewrap sandbox
This commit is contained in:
1 parent
2ac2b0d5ca
commit
2659009a49
45 files changed
+146
No files matched your search
Executable
+31
@@ -0,0 +1,31 @@
|
||||
#!/bin/bash
|
||||
# Record what the bash backend (steamify.sh in $REPO) prints, per fixture, into share/golden/expected/.
|
||||
# share/golden/record.sh record all | share/golden/record.sh check compare with the recorded files
|
||||
set -uo pipefail
|
||||
here="$(cd "$(dirname "$0")" && pwd)"
|
||||
export REPO="${REPO:-$here/../../../steamify-cachyos}"; REPO="$(cd "$REPO" && pwd)"
|
||||
backend="${BACKEND:-bash $REPO/steamify.sh}"
|
||||
mode="${1:-record}"; failures=0
|
||||
# case name -> backend arguments
|
||||
# status: the whole output. plan-*: only the first line of the apply stream (the plan event, where the rules live);
|
||||
# the steps after it need the real system (the VM suite), they are not stable with a fake sudo.
|
||||
cases=("status:--backend status"
|
||||
"plan-gaming:--backend apply gaming"
|
||||
"plan-gaming-desktop:--backend apply --boot desktop gaming boot"
|
||||
"plan-single:--backend apply single"
|
||||
"plan-poweroff:--backend apply poweroff"
|
||||
"plan-nothing:--backend apply"
|
||||
"plan-nvidia:--backend apply nvidia bigpicture")
|
||||
for fixture in "$here"/fixtures/*/; do
|
||||
name="$(basename "$fixture")"
|
||||
for entry in "${cases[@]}"; do
|
||||
label="${entry%%:*}"; arguments="${entry#*:}"
|
||||
expected="$here/expected/$name.$label.json"; mkdir -p "$here/expected"
|
||||
actual="$("$here/sandbox.sh" "$fixture" $backend $arguments 2>&1)"
|
||||
[[ "$label" == plan-* ]] && actual="$(head -n 1 <<<"$actual")"
|
||||
if [[ "$mode" == record ]]; then printf '%s\n' "$actual" > "$expected"; echo "recorded $expected"
|
||||
elif ! diff -u "$expected" <(printf '%s\n' "$actual"); then echo "FAIL $name $label"; failures=$((failures+1))
|
||||
else echo "PASS $name $label"; fi
|
||||
done
|
||||
done
|
||||
exit $failures
|
||||
Reference in new issue
Block a user