ktg-plugin-marketplace/plugins/ms-ai-architect/tests/test-kb-update.sh
Kjell Tore Guttormsen 97d1101e91 feat(ms-ai-architect): wire kb-update test suite into run-e2e dispatch [skip-docs]
Step 12 — adds --kb-update flag to tests/run-e2e.sh and a Bash 3.2-compatible
shim test-kb-update.sh that runs `node --test tests/kb-update/*.test.mjs`
(shell-glob form; Node 25 rejects directory-form arguments). Shim translates
node --test exit code + parsed pass/fail counts into the e2e-helpers.sh
suite counters (init_suite/print_summary).

Verification:
- Playground baseline 271 PASS unchanged before/after edit
- bash tests/run-e2e.sh --kb-update: exits 0, 110/110 inner tests pass
- bash tests/run-e2e.sh --all: kb-update suite included
- Pre-existing ROS-fixture absence (tests/fixtures/ros-analysis/) is
  unrelated to this change and remains for separate handling

Wave 5 of 7 in v1.12.0 auto-KB-update plan.
Plan: .claude/projects/2026-05-04-kb-update-fork-and-own/plan.md (Step 12)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-05 11:32:47 +02:00

44 lines
1.6 KiB
Bash
Executable file

#!/bin/bash
# test-kb-update.sh — Run KB-update node:test suite via the E2E harness.
# Bash 3.2-compatible. Sources lib/e2e-helpers.sh, runs node --test against
# the kb-update glob (Node 25 rejects directory-form arguments to --test),
# and translates the result into the suite's pass/fail counters.
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
PLUGIN_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
source "$SCRIPT_DIR/lib/e2e-helpers.sh"
init_suite "KB Update"
cd "$PLUGIN_ROOT"
if ! compgen -G "tests/kb-update/*.test.mjs" >/dev/null 2>&1; then
fail "No test files matched tests/kb-update/*.test.mjs"
print_summary
exit 1
fi
TEST_LOG="$(mktemp -t kb-update-suite.XXXXXX)"
trap 'rm -f "$TEST_LOG"' EXIT
NODE_EXIT=0
node --test tests/kb-update/*.test.mjs >"$TEST_LOG" 2>&1 || NODE_EXIT=$?
cat "$TEST_LOG"
PASS_COUNT="$(awk '/^[^[:alnum:]]*pass[[:space:]]+[0-9]+/ { for (i=1;i<=NF;i++) if ($i=="pass") { print $(i+1); exit } }' "$TEST_LOG")"
FAIL_COUNT="$(awk '/^[^[:alnum:]]*fail[[:space:]]+[0-9]+/ { for (i=1;i<=NF;i++) if ($i=="fail") { print $(i+1); exit } }' "$TEST_LOG")"
TESTS_COUNT="$(awk '/^[^[:alnum:]]*tests[[:space:]]+[0-9]+/ { for (i=1;i<=NF;i++) if ($i=="tests") { print $(i+1); exit } }' "$TEST_LOG")"
PASS_COUNT="${PASS_COUNT:-0}"
FAIL_COUNT="${FAIL_COUNT:-0}"
TESTS_COUNT="${TESTS_COUNT:-0}"
if [ "$NODE_EXIT" -eq 0 ] && [ "$FAIL_COUNT" -eq 0 ]; then
pass "node --test tests/kb-update/*.test.mjs ($PASS_COUNT/$TESTS_COUNT pass)"
else
fail "node --test failed (pass=$PASS_COUNT, fail=$FAIL_COUNT, tests=$TESTS_COUNT, exit=$NODE_EXIT)"
fi
print_summary