Smoketest sibling projects on top of CoreDesktop

The scenario helpers now take a chain of projects from the driver
(SMOKETEST_CHAIN_FILE): CoreDesktop, then sibling projects such as HamPack.
Each gets a fake upstream in the VM; upstream_set and upstream_commit take
an optional project name; smoketest_prepare updates every project in the
installed image; and the new smoketest_build_layer, sibling_add and
install_chain install them. health also runs each installed sibling's
smoketest/health, and a sibling's smoketest/setup runs before each scenario.

Without a chain file, everything works as before, so older drivers and
CoreDesktop's own scenarios are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-26 10:15:10 -07:00
co-authored by Claude Opus 5.5
parent 4fb35397ee
commit 4f1e18200c
3 changed files with 439 additions and 52 deletions
+143
View File
@@ -238,3 +238,146 @@ upstream_main() {
git -C "$REPO" rev-parse --verify --quiet "$ref^{commit}" > /dev/null || { echo "unknown: $ref"; exit 1; }
done
}
# --- Sibling projects ---
# A sibling project, HamPack, with two commits, and a chain file with
# CoreDesktop and it: CoreDesktop at V1 in the image and V2 under test,
# HamPack likewise at S1 and S2
chain_with_sibling() {
SIB="$BATS_TEST_TMPDIR/HamPack"
git init -q "$SIB"
echo s1 > "$SIB/version"
git -C "$SIB" add version
git -C "$SIB" commit -qm s1
S1="$(git -C "$SIB" rev-parse HEAD)"
echo s2 > "$SIB/version"
git -C "$SIB" commit -qam s2
S2="$(git -C "$SIB" rev-parse HEAD)"
export SMOKETEST_CHAIN_FILE="$BATS_TEST_TMPDIR/chain"
printf 'CoreDesktop\t%s\t%s\t%s\t\n' "$SMOKETEST_REPO" "$V2" "$V1" > "$SMOKETEST_CHAIN_FILE"
printf 'HamPack\t%s\t%s\t%s\t%s\n' "$SIB" "$S2" "$S1" \
"https://example.com/david/HamPack.git https://example.org/HamPack.git" >> "$SMOKETEST_CHAIN_FILE"
SIB_UPSTREAM="$SMOKETEST_VM_DIR/HamPack.git"
# A fake `sibling add`, which clones like the real one, and update and reboot
mkdir -p "$HOME/.local/bin"
printf '%s\n' '#!/bin/bash' 'echo "sibling $*" >> ~/vm.log' \
'git clone -q "$2" ~/.local/share/siblings/"$(basename "${2%.git}")"' > "$HOME/.local/bin/sibling"
printf '%s\n' '#!/bin/bash' 'echo update >> ~/vm.log' > "$HOME/.local/bin/update"
chmod +x "$HOME/.local/bin/sibling" "$HOME/.local/bin/update"
vm_reboot() { echo reboot >> "$HOME/vm.log"; }
}
@test "without a chain file, the chain is CoreDesktop at the commit under test" {
[ "$(chain_names)" = CoreDesktop ]
[ "$(project_sha CoreDesktop)" = "$V2" ]
[ -z "$(chain_siblings)" ]
}
@test "prepare makes a fake upstream for each project, and sends its URLs there" {
chain_with_sibling
smoketest_prepare
[ "$(upstream_main)" = "$V2" ]
[ "$(git --git-dir="$SIB_UPSTREAM" rev-parse main)" = "$S2" ]
for url in https://example.com/david/HamPack.git https://example.com/david/HamPack https://example.org/HamPack.git; do
git clone -q "$url" "$BATS_TEST_TMPDIR/clone"
[ "$(cat "$BATS_TEST_TMPDIR/clone/version")" = s2 ]
rm -rf "$BATS_TEST_TMPDIR/clone"
done
}
@test "prepare on the installed image checks every project's image commit, then updates once" {
chain_with_sibling
export IMAGE=installed
run smoketest_prepare
[ "$status" -eq 0 ]
[ "$(cat "$HOME/vm.log")" = update ]
printf 'HamPack\t%s\t%s\t%s\t%s\n' "$SIB" "$S1" "$S2" https://example.com/HamPack.git \
> "$BATS_TEST_TMPDIR/hampack-line"
sed -i '2d' "$SMOKETEST_CHAIN_FILE"
cat "$BATS_TEST_TMPDIR/hampack-line" >> "$SMOKETEST_CHAIN_FILE"
run smoketest_prepare
[ "$status" -eq 1 ]
[[ "$output" == *"the installed image has HamPack at $S2, which isn't in the history"* ]]
}
@test "upstream_set and upstream_commit take a project's name" {
chain_with_sibling
smoketest_prepare
upstream_set HamPack "$S1"
[ "$(git --git-dir="$SIB_UPSTREAM" rev-parse main)" = "$S1" ]
[ "$(upstream_main)" = "$V2" ]
upstream_commit HamPack "Bump" 'echo s3 > version'
[ "$(git --git-dir="$SIB_UPSTREAM" show main:version)" = s3 ]
[ "$(upstream_main)" = "$V2" ]
run upstream_set HamPack nosuchcommit
[[ "$output" == *"no such commit in HamPack: nosuchcommit"* ]]
run upstream_commit Nope "x" true
[ "$status" -eq 1 ]
[[ "$output" == *"Nope isn't in this run's chain"* ]]
}
@test "building a sibling's layer adds it at its commit, over the others at their image's, and reboots" {
chain_with_sibling
smoketest_build_layer HamPack "$S2"
[ "$(upstream_main)" = "$V1" ]
[ "$(cat "$HOME/.local/share/siblings/HamPack/version")" = s2 ]
[ "$(cat "$HOME/vm.log")" = "$(printf 'sibling add https://example.com/david/HamPack.git\nreboot')" ]
}
@test "building CoreDesktop's layer runs install.sh at its commit" {
vm_reboot() { echo reboot >> "$HOME/vm.log"; }
smoketest_build_layer CoreDesktop "$V1"
[ "$(cat "$HOME/vm.log")" = reboot ]
[ "$(head -n 1 "$HOME/installed")" = v1 ]
}
@test "install_chain installs CoreDesktop, reboots, adds each sibling and reboots again" {
chain_with_sibling
smoketest_prepare
install_chain
[ "$(cat "$HOME/vm.log")" = "$(printf 'reboot\nsibling add https://example.com/david/HamPack.git\nreboot')" ]
[ "$(head -n 1 "$HOME/installed")" = v2 ]
}
@test "a project's setup script runs in the VM before the scenario" {
chain_with_sibling
mkdir -p "$SIB/smoketest"
echo 'echo set up > ~/setup-ran' > "$SIB/smoketest/setup"
smoketest_prepare
[ "$(cat "$HOME/setup-ran")" = "set up" ]
echo 'exit 1' > "$SIB/smoketest/setup"
run smoketest_prepare
[ "$status" -eq 1 ]
[[ "$output" == *"setup-HamPack exited 1"* ]]
}
@test "health checks CoreDesktop, and each sibling that's installed and has health checks" {
chain_with_sibling
mkdir -p "$SIB/smoketest"
echo 'echo hampack healthy' > "$SIB/smoketest/health"
SMOKETEST_DIR="$BATS_TEST_TMPDIR/cd-smoketest"
mkdir -p "$SMOKETEST_DIR"
echo 'echo coredesktop healthy' > "$SMOKETEST_DIR/health"
run health
[ "$status" -eq 0 ]
[[ "$output" == *"coredesktop healthy"* ]]
[[ "$output" != *"hampack healthy"* ]]
mkdir -p "$HOME/.local/share/siblings/HamPack"
run health
[[ "$output" == *"coredesktop healthy"*"hampack healthy"* ]]
echo 'exit 1' > "$SIB/smoketest/health"
run health
[ "$status" -eq 1 ]
[[ "$output" == *"the health checks failed for: HamPack"* ]]
run health CoreDesktop
[ "$status" -eq 0 ]
}