From 7490b4d57189daa4e83157eafa221b6808dee22f Mon Sep 17 00:00:00 2001 From: Bastien Chanot Date: Mon, 6 Jul 2026 19:36:56 +0200 Subject: [PATCH] job4: test toggle-external logical cd (red) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit New lib/tests/toggle-external-repo-resolution.test.sh: sandbox replicating the real ~/.claude/lib -> /lib symlink layout, invokes toggle-external.sh THROUGH the symlinked path and asks `status emil-design-eng` (marked enabled in the physical repo tree). Demonstrates J4-20 (UNTESTABLE + latent bug) against the CURRENT code, on purpose — this commit is RED: reports "missing" instead of "enabled", because toggle-external.sh:34's logical `cd` (no -P) resolves REPO to the symlink's logical parent instead of the physical repo root, so SKILLS_DIR/DISABLED_DIR point at the wrong tree. Same BLK-006 bug class as profile.sh's historical breaks, un-ported here — latent today (no in-repo caller hits direct `~/.claude/lib/...` invocation), but reachable. This intentionally reds `make test`. Next commit fixes it. --- .../toggle-external-repo-resolution.test.sh | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 lib/tests/toggle-external-repo-resolution.test.sh diff --git a/lib/tests/toggle-external-repo-resolution.test.sh b/lib/tests/toggle-external-repo-resolution.test.sh new file mode 100644 index 0000000..8c54109 --- /dev/null +++ b/lib/tests/toggle-external-repo-resolution.test.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +# lib/tests/toggle-external-repo-resolution.test.sh +# +# Regression test for J4-20 (BLK-006 class): toggle-external.sh:34 resolved +# REPO with a LOGICAL `cd` (no -P). Direct invocation via a symlinked path — +# exactly the real ~/.claude/lib -> /lib layout — resolves REPO to the +# SYMLINK's logical parent instead of the physical repo root, so every path +# derived from it (SKILLS_DIR, DISABLED_DIR) points at the wrong tree. +set -u +HELPER_SRC="$(cd "$(dirname "$0")/../.." && pwd)/lib/toggle-external.sh" +pass=0; fail=0 +check() { if [ "$2" = "$3" ]; then pass=$((pass+1)); else fail=$((fail+1)); + printf 'FAIL %s: got[%s] want[%s]\n' "$1" "$2" "$3"; fi; } + +SANDBOX="$(mktemp -d)" +mkdir -p "$SANDBOX/repo/lib" "$SANDBOX/repo/skills-external/emil-design-eng" \ + "$SANDBOX/repo/skills" "$SANDBOX/home/.claude" +cp "$HELPER_SRC" "$SANDBOX/repo/lib/toggle-external.sh" +# mark emil-design-eng ENABLED in the real (physical) repo tree +ln -s "$SANDBOX/repo/skills-external/emil-design-eng" "$SANDBOX/repo/skills/emil-design-eng" +# replicate the real ~/.claude/lib -> /lib symlink +ln -s "$SANDBOX/repo/lib" "$SANDBOX/home/.claude/lib" + +out="$(bash "$SANDBOX/home/.claude/lib/toggle-external.sh" status emil-design-eng)" +check T1-repo-resolves-through-symlink "$out" enabled + +rm -rf "$SANDBOX" +printf 'PASS=%s FAIL=%s\n' "$pass" "$fail"; [ "$fail" -eq 0 ]