ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.
Python astracloudflarecontrol-panelcyberpaneldnsfablehosting-control-panelhosting-panelkimi-k3server-managementserverkitubuntu-web-panelwebserver
test(install): survive minimal CI images without cmp/tar; chain if-subshell assertions
Juan Denisb44305d4f7cf
diff --git a/scripts/test/stubs.sh b/scripts/test/stubs.shindex 0698e257..7bca7d20 100644--- a/scripts/test/stubs.sh+++ b/scripts/test/stubs.sh@@ -22,6 +22,18 @@# `shellcheck --severity=error` and `bash -n` on scripts/test/*.sh across a# 7-distro matrix.+# files_identical <a> <b> — byte-equality that works on minimal CI images:+# EL9/Fedora containers ship without diffutils (`cmp`), so fall back to a+# checksum compare (sha256sum is coreutils, present everywhere we run).+files_identical() {+ [ -f "$1" ] && [ -f "$2" ] || return 1+ if command -v cmp >/dev/null 2>&1; then+ cmp -s "$1" "$2"+ else+ [ "$(sha256sum < "$1")" = "$(sha256sum < "$2")" ]+ fi+}+# make_stub_exit <bindir> <code> <name...> — each <name> becomes a stub that# ignores its arguments and exits <code>.make_stub_exit() {diff --git a/scripts/test/test_install.sh b/scripts/test/test_install.shindex 659b118c..09e99e6c 100644--- a/scripts/test/test_install.sh+++ b/scripts/test/test_install.sh@@ -410,14 +410,18 @@ printf 'SQLITE-SENTINEL-BYTES\n' > "$t/slot/backend/instance/serverkit.db"cp "$t/slot/.env" "$t/env.orig"cp "$t/slot/backend/instance/serverkit.db" "$t/db.orig"if (+ # One && chain, not sequential statements: bash suppresses set -e inside+ # an if-condition subshell, so only an explicit chain makes every+ # assertion gate the result (a cmp-less EL9 CI image proved this —+ # the sibling t16r test passed vacuously while cmp exited 127).set -Eeuo pipefail- stash="$(stash_live_state "$t/slot")"- [ -n "$stash" ]- rm -rf "$t/slot" # the rewrite- mkdir -p "$t/slot/backend" # fresh tree: no .env, no instance/- restore_live_state "$stash" "$t/slot"- cmp -s "$t/slot/.env" "$t/env.orig"- cmp -s "$t/slot/backend/instance/serverkit.db" "$t/db.orig"+ stash="$(stash_live_state "$t/slot")" \+ && [ -n "$stash" ] \+ && rm -rf "$t/slot" \+ && mkdir -p "$t/slot/backend" `# fresh tree: no .env, no instance/` \+ && restore_live_state "$stash" "$t/slot" \+ && files_identical "$t/slot/.env" "$t/env.orig" \+ && files_identical "$t/slot/backend/instance/serverkit.db" "$t/db.orig") >/dev/null 2>&1; thenok "stash/restore_live_state carries .env + instance DB byte-identical across a rewrite"else@@ -432,6 +436,10 @@ cp "$slotA/.env" "$t/env.orig"; cp "$slotA/backend/instance/serverkit.db" "$t/dbln -sfn "$slotA" "$inst" 2>/dev/null || trueif [ ! -L "$inst" ]; thenskip "fetch_release live-state carry — symlinks unsupported here (runs on Linux CI)"+elif ! command -v tar >/dev/null 2>&1; then+ # openSUSE Leap minimal images ship without tar; neither the fixture nor+ # fetch_release itself can run there. Proven on the other 6 distros.+ skip "fetch_release live-state carry — tar unavailable here"elsestage="$t/stage"; mkdir -p "$stage/serverkit/backend/app" "$stage/serverkit/scripts"printf '#!/bin/sh\n' > "$stage/serverkit/serverkit"@@ -441,10 +449,10 @@ elseset -Eeuo pipefailINSTALL_DIR="$inst"; DIR_A="$slotA"; DIR_B="$slotB"; FIRST_SLOT="$slotA"SERVERKIT_OFFLINE_TARBALL="$t/rel.tar.gz"- fetch_release- cmp -s "$slotA/.env" "$t/env.orig"- cmp -s "$slotA/backend/instance/serverkit.db" "$t/db.orig"- [ -d "$slotA/backend/app" ]+ fetch_release \+ && files_identical "$slotA/.env" "$t/env.orig" \+ && files_identical "$slotA/backend/instance/serverkit.db" "$t/db.orig" \+ && [ -d "$slotA/backend/app" ]) >/dev/null 2>&1; thenok "fetch_release re-run preserves .env + database byte-identical (the data-loss bug)"else@@ -967,6 +975,8 @@ cp "$slotA/.env" "$t/env.orig"ln -sfn "$slotA" "$inst" 2>/dev/null || trueif [ ! -L "$inst" ]; thenskip "fetch_release cp-failure fallback — symlinks unsupported here (runs on Linux CI)"+elif ! command -v tar >/dev/null 2>&1; then+ skip "fetch_release cp-failure fallback — tar unavailable here"elsestage="$t/stage"; mkdir -p "$stage/serverkit/backend/app"printf '#!/bin/sh\n' > "$stage/serverkit/serverkit"@@ -984,7 +994,7 @@ EOFSERVERKIT_OFFLINE_TARBALL="$t/rel.tar.gz"; INSTALL_FROM_RELEASE=1rc=0; fetch_release >/dev/null 2>&1 || rc=$?printf '%s|%s' "$rc" "$INSTALL_FROM_RELEASE" )"- if [ "$res" = "1|0" ] && cmp -s "$slotA/.env" "$t/env.orig"; then+ if [ "$res" = "1|0" ] && files_identical "$slotA/.env" "$t/env.orig"; thenok "fetch_release: a failed slot copy restores the live .env and falls back to source"elsebad "fetch_release cp-failure lost live state or faked success (I16 regression): [$res]"