test(19.4): gate additivity stage accepts both pre-phase user plugin commits

The userplugin stage compared against c077029 only; the merge of
origin/master brought in 24b16b1's pre-phase console signature change.
A declaration now counts as removed only when removed against every base.
This commit is contained in:
2026-10-20 00:33:15 +02:00
parent ee22bcd139
commit d9f7bfa6d1

View File

@@ -50,7 +50,8 @@
# Environment overrides (default: the sibling checkouts next to this
# repository): PHASE194_ROOT (this repository), OAUTHSERVER_PLUGIN,
# USER_PLUGIN, FONOTEKA (the application workspace), PHASE194_USER_BASE
# (the user plugin commit the additive check compares against).
# (the space-separated user plugin commits the additive check compares
# against).
set -euo pipefail
unset FORCE_COLOR
@@ -60,8 +61,9 @@ ROOT="${PHASE194_ROOT:-$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)}"
OAUTHSERVER_PLUGIN="${OAUTHSERVER_PLUGIN:-$ROOT/../sm-oauthserver-plugin}"
FONOTEKA="${FONOTEKA:-$ROOT/../fono""teka.go}"
USER_PLUGIN="${USER_PLUGIN:-$FONOTEKA/plugins/golem15/user}"
# The user plugin's last commit before this phase (19-04).
USER_BASE="${PHASE194_USER_BASE:-c077029}"
# The user plugin's commits before this phase: the local tip (19-04) and
# origin's tip, which a later merge joined.
USER_BASE="${PHASE194_USER_BASE:-c077029 24b16b1}"
# ---------------------------------------------------------------------------
# Required test names. Each list runs with -run '^(a|b|...)$' and every name
@@ -446,21 +448,33 @@ run_userplugin() {
go_named "$FONOTEKA" ./plugins/golem15/user -short "${USER_ROOT_TESTS[@]}"
# D-05: additive only. git's status is captured before any filtering, so
# an unknown base or a broken checkout fails here instead of reading as
# an empty diff.
local diff rc=0 removed
diff="$(git -C "$USER_PLUGIN" diff "$USER_BASE" -- '*.go' ':(exclude)*_test.go' 2>&1)" || rc=$?
if [[ "$rc" -ne 0 ]]; then
printf '%s\n' "$diff" | tail -n 5 >&2
echo "refuse: git diff $USER_BASE in $USER_PLUGIN failed (exit $rc)" >&2
return 1
fi
removed="$(removed_exports <<<"$diff")"
# an empty diff. A declaration counts as removed only when it is removed
# against every base (origin's pre-phase commit changed signatures the
# local tip still had, and the merge carries that change).
local base diff rc removed="" found first=1 added=0
for base in $USER_BASE; do
rc=0
diff="$(git -C "$USER_PLUGIN" diff "$base" -- '*.go' ':(exclude)*_test.go' 2>&1)" || rc=$?
if [[ "$rc" -ne 0 ]]; then
printf '%s\n' "$diff" | tail -n 5 >&2
echo "refuse: git diff $base in $USER_PLUGIN failed (exit $rc)" >&2
return 1
fi
found="$(removed_exports <<<"$diff")"
if [[ "$first" -eq 1 ]]; then
removed="$found"
added="$(grep -cE '^\+(func|type) ' <<<"$diff" || true)"
first=0
elif [[ -n "$removed" ]]; then
removed="$(grep -Fxf <(printf '%s\n' "$found") <<<"$removed" || true)"
fi
done
if [[ -n "$removed" ]]; then
printf '%s\n' "$removed" >&2
echo "refuse: the user plugin removed or changed exported declarations since $USER_BASE (D-05: additive only)" >&2
return 1
fi
echo "additive: no exported func, method or type removed from the user plugin since $USER_BASE ($(grep -cE '^\+(func|type) ' <<<"$diff" || true) declarations added)"
echo "additive: no exported func, method or type removed from the user plugin since $USER_BASE ($added declarations added)"
echo "phase19.4 userplugin passed"
}