Files
coredesktop/tests/sibling.bats
T
davidandClaude Opus 5.5 ee7451600b
shellcheck / shellcheck (push) Failing after 19s
Show sibling projects' versions, and let version update them
A sibling's version is its latest git tag (v1.4.0, or v1.4.0+3 for commits
after it), or, without tags, its commit's date and short hash, like
CoreDesktop's own. The version shown as available is that of the newest
commit on the default branch, which is what update installs.

sibling list shows each sibling's version. sibling check fetches every
sibling at once and shows which have a newer version, and sibling update
[name...] updates the named siblings or all of them. 71-siblings.sh now
runs sibling update, so update and version share one way of updating.

version lists the installed siblings with any newer version and, when run
in a terminal, asks for each one whether to update it now. version --check
and the update notification still only look at CoreDesktop.

The sibling skill docs describe how to release a version by tagging it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 10:26:51 -07:00

115 lines
3.2 KiB
Bash

#!/usr/bin/env bats
load test_helper
# sibling runs against real git repositories: each sibling is a clone of a
# repo in $ORIGINS, which a test can add commits and tags to.
setup() {
common_setup
export GIT_AUTHOR_NAME=Test GIT_AUTHOR_EMAIL=test@example.com
export GIT_COMMITTER_NAME=Test GIT_COMMITTER_EMAIL=test@example.com
ORIGINS="$BATS_TEST_TMPDIR/origins"
SIBLINGS="$HOME/.local/share/siblings"
mkdir -p "$ORIGINS" "$SIBLINGS"
}
# origin NAME: make a repo with one commit, and clone it as a sibling
origin() {
git init -q -b main "$ORIGINS/$1"
commit "$1" first
git clone -q "$ORIGINS/$1" "$SIBLINGS/$1"
}
# commit NAME MESSAGE: add a commit to NAME's origin
commit() {
echo "$2" >> "$ORIGINS/$1/log"
git -C "$ORIGINS/$1" add -A
git -C "$ORIGINS/$1" commit -qm "$2"
}
@test "sibling list shows a tagged sibling's tag, and an untagged one's date and hash" {
origin tagged
git -C "$ORIGINS/tagged" tag v1.0.0
git -C "$SIBLINGS/tagged" pull -q
origin plain
run bash "$REPO/sibling" list
[ "$status" -eq 0 ]
[[ "$output" == *"tagged v1.0.0 "*"$ORIGINS/tagged"* ]]
[[ "$output" =~ plain\ +[0-9]{4}\.[0-9]{2}\.[0-9]{2}\ \([0-9a-f]+\) ]]
}
@test "sibling list counts the commits since the latest tag" {
origin tools
git -C "$ORIGINS/tools" tag v1.0.0
commit tools second
commit tools third
git -C "$SIBLINGS/tools" pull -q
run bash "$REPO/sibling" list
[[ "$output" == *"tools v1.0.0+2 "* ]]
}
@test "sibling check shows what's newer, what's up to date, and what it couldn't reach" {
origin newer
git -C "$ORIGINS/newer" tag v1.0.0
git -C "$SIBLINGS/newer" pull -q
commit newer second
git -C "$ORIGINS/newer" tag v1.1.0
origin current
origin gone
rm -rf "$ORIGINS/gone"
run bash "$REPO/sibling" check
[ "$status" -eq 0 ]
[[ "$output" == *"newer v1.0.0"*"v1.1.0 is available"* ]]
[[ "$output" == *"current "*"up to date"* ]]
[[ "$output" == *"gone "*"couldn't check"* ]]
run bash "$REPO/sibling" check --porcelain
[[ "$output" == *$'newer\tv1.0.0\tv1.1.0'* ]]
[[ "$output" == *$'gone\t'*$'\t?'* ]]
}
@test "sibling check exits 1 when nothing is newer" {
origin current
run bash "$REPO/sibling" check
[ "$status" -eq 1 ]
[[ "$output" == *"up to date"* ]]
}
@test "sibling update updates only the siblings named" {
origin one
origin two
echo 'echo ran >> "$HOME/one-updated"' > "$ORIGINS/one/update.sh"
commit one second
git -C "$ORIGINS/one" tag v2.0.0
commit two second
run bash "$REPO/sibling" update one
[ "$status" -eq 0 ]
[[ "$output" == *"one is at v2.0.0."* ]]
[ "$(cat "$HOME/one-updated")" = ran ]
[ "$(git -C "$SIBLINGS/two" rev-list --count HEAD)" -eq 1 ]
}
@test "sibling update with no names updates them all, and reports a failing update.sh" {
origin one
origin two
echo 'exit 1' > "$ORIGINS/one/update.sh"
commit one second
commit two second
run bash "$REPO/sibling" update
[ "$status" -eq 1 ]
[[ "$output" == *"one's update.sh failed"* ]]
[ "$(git -C "$SIBLINGS/two" rev-list --count HEAD)" -eq 2 ]
}
@test "sibling update refuses a sibling that isn't installed" {
run bash "$REPO/sibling" update nope
[ "$status" -eq 1 ]
[[ "$output" == *"No sibling named 'nope' is installed."* ]]
}