diff --git a/test/integration-test.sh b/test/integration-test.sh index 40a4703..87734fa 100755 --- a/test/integration-test.sh +++ b/test/integration-test.sh @@ -4,7 +4,7 @@ set -e . "$(dirname "$0")/test-helper.sh" -IDSTACK_DIR="$(cd "$(dirname "$0")/.." && pwd)" +IDSTACK_DIR="${1:-$(cd "$(dirname "$0")/.." && pwd -P)}" TEST_DIR=$(mktemp -d) # Single-quoted so expansion happens at trap time and a path with spaces survives. trap 'rm -rf "$TEST_DIR"' EXIT diff --git a/test/smoke-test.sh b/test/smoke-test.sh index 490cb9f..c6620e2 100755 --- a/test/smoke-test.sh +++ b/test/smoke-test.sh @@ -272,7 +272,7 @@ fi check "bin/idstack-manifest-merge exists" "[ -f '$IDSTACK_DIR/bin/idstack-manifest-merge' ]" check "bin/idstack-manifest-merge is executable" "[ -x '$IDSTACK_DIR/bin/idstack-manifest-merge' ]" if [ -x "$IDSTACK_DIR/test/test-manifest-merge.sh" ]; then - check "manifest-merge unit tests pass" "'$IDSTACK_DIR/test/test-manifest-merge.sh'" + check "manifest-merge unit tests pass" "'$IDSTACK_DIR/test/test-manifest-merge.sh' '$IDSTACK_DIR'" fi # Version classifier (shared by setup + bin/idstack-doctor) must classify @@ -285,7 +285,7 @@ check "setup sources the shared version classifier" "grep -q 'lib/version-classi check "idstack-doctor sources the shared version classifier" "grep -q 'lib/version-classify.sh' '$IDSTACK_DIR/bin/idstack-doctor'" check "version-classifier test sources the shared classifier" "grep -q 'lib/version-classify.sh' '$IDSTACK_DIR/test/test-version-classifier.sh'" if [ -x "$IDSTACK_DIR/test/test-version-classifier.sh" ]; then - check "version-classifier unit tests pass" "'$IDSTACK_DIR/test/test-version-classifier.sh'" + check "version-classifier unit tests pass" "'$IDSTACK_DIR/test/test-version-classifier.sh' '$IDSTACK_DIR'" fi # `claude plugin list` parsing, also extracted to bin/lib/ so it is testable. @@ -294,16 +294,16 @@ check "bin/lib/plugin-status.sh exists" "[ -f '$IDSTACK_DIR/bin/lib/plugin-statu check "idstack-doctor sources the shared plugin-status parser" "grep -q 'lib/plugin-status.sh' '$IDSTACK_DIR/bin/idstack-doctor'" check "idstack-doctor no longer uses a fixed -A4 window" "! grep -q 'grep -A4' '$IDSTACK_DIR/bin/idstack-doctor'" if [ -x "$IDSTACK_DIR/test/test-plugin-status.sh" ]; then - check "plugin-status unit tests pass" "'$IDSTACK_DIR/test/test-plugin-status.sh'" + check "plugin-status unit tests pass" "'$IDSTACK_DIR/test/test-plugin-status.sh' '$IDSTACK_DIR'" fi # Hooked in here as well as in CI because release.yml's gate runs only # smoke-test.sh — doctor's branches would otherwise be unverified at release. if [ -x "$IDSTACK_DIR/test/test-doctor.sh" ]; then - check "doctor behavioral tests pass" "'$IDSTACK_DIR/test/test-doctor.sh'" + check "doctor behavioral tests pass" "'$IDSTACK_DIR/test/test-doctor.sh' '$IDSTACK_DIR'" fi # --readiness is the pre-export gate; same reasoning as doctor above. if [ -x "$IDSTACK_DIR/test/test-status.sh" ]; then - check "idstack-status behavioral tests pass" "'$IDSTACK_DIR/test/test-status.sh'" + check "idstack-status behavioral tests pass" "'$IDSTACK_DIR/test/test-status.sh' '$IDSTACK_DIR'" fi # ./setup is what a new user runs first; it is exercised against a repo copy @@ -314,7 +314,7 @@ fi # Chrome extension unit and integration tests if [ -x "$IDSTACK_DIR/test/test-extension.sh" ]; then - check "chrome extension tests pass" "'$IDSTACK_DIR/test/test-extension.sh'" + check "chrome extension tests pass" "'$IDSTACK_DIR/test/test-extension.sh' '$IDSTACK_DIR'" fi # Responsive landing page test @@ -346,7 +346,7 @@ check "preamble supports CLAUDE_PLUGIN_ROOT" "grep -q 'CLAUDE_PLUGIN_ROOT' '$IDS # (macOS system python3 is 3.9) — a SyntaxError there dies silently behind # `2>/dev/null || true` in every generated skill. if [ -x "$IDSTACK_DIR/test/test-preamble-python.sh" ]; then - check "preamble embedded-python tests pass" "'$IDSTACK_DIR/test/test-preamble-python.sh'" + check "preamble embedded-python tests pass" "'$IDSTACK_DIR/test/test-preamble-python.sh' '$IDSTACK_DIR'" fi # Migration tests. One tempdir root cleaned by trap; every cp + migrate runs diff --git a/test/test-doctor.sh b/test/test-doctor.sh index 034c12e..41e913b 100755 --- a/test/test-doctor.sh +++ b/test/test-doctor.sh @@ -23,7 +23,7 @@ set -e . "$(dirname "$0")/test-helper.sh" -REPO_DIR="$(cd "$(dirname "$0")/.." && pwd -P)" +REPO_DIR="${1:-$(cd "$(dirname "$0")/.." && pwd -P)}" TEST_ROOT="$(mktemp -d)" trap 'rm -rf "$TEST_ROOT"' EXIT @@ -40,7 +40,7 @@ DOCTOR_CMD="$MOCK_IDSTACK_DIR/bin/idstack-doctor" # mock we drop in. `claude` is absent unless a test installs it. MOCK_BIN="$TEST_ROOT/bin" mkdir -p "$MOCK_BIN" -for _c in bash sh env command dirname echo grep head python3 readlink sed tr awk cat ls rm mkdir ln chmod mktemp printf sort wc basename find touch cp; do +for _c in bash sh env command dirname echo grep head python3 readlink sed tr awk cat ls rm mkdir ln chmod mktemp printf sort wc basename find touch cp cut; do _p=$(command -v "$_c" 2>/dev/null) && ln -sf "$_p" "$MOCK_BIN/$_c" done export PATH="$MOCK_BIN" diff --git a/test/test-extension.sh b/test/test-extension.sh index a5e5f49..9b2135a 100755 --- a/test/test-extension.sh +++ b/test/test-extension.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -euo pipefail -DIR="$(cd "$(dirname "$0")" && pwd)" +DIR="${1:-$(cd "$(dirname "$0")/.." && pwd -P)}/test" echo "==> Running idstack Chrome Extension test suite..." node "$DIR/test-manifest.js" diff --git a/test/test-manifest-merge.sh b/test/test-manifest-merge.sh index 6d39d3b..0fe9b4f 100755 --- a/test/test-manifest-merge.sh +++ b/test/test-manifest-merge.sh @@ -7,7 +7,7 @@ set -e . "$(dirname "$0")/test-helper.sh" -REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)" +REPO_ROOT="${1:-$(cd "$(dirname "$0")/.." && pwd -P)}" MERGE="$REPO_ROOT/bin/idstack-manifest-merge" # Skip the suite if python3 is missing (the tool requires python3). @@ -126,7 +126,7 @@ check "manifest with string root exits 2" "[ $EC -eq 2 ]" # --- idstack-migrate --init: the manifest bootstrap the merge tool depends on --- # Skills running standalone create the manifest with --init before merging; # without it the merge exits 4 and standalone results are never persisted. -MIGRATE="$(cd "$(dirname "$0")/.." && pwd -P)/bin/idstack-migrate" +MIGRATE="$REPO_ROOT/bin/idstack-migrate" INIT_DIR="$WORK/initcase" mkdir -p "$INIT_DIR/.idstack" diff --git a/test/test-plugin-status.sh b/test/test-plugin-status.sh index f85e589..df39305 100755 --- a/test/test-plugin-status.sh +++ b/test/test-plugin-status.sh @@ -14,7 +14,7 @@ set -e . "$(dirname "$0")/test-helper.sh" -IDSTACK_DIR="$(cd "$(dirname "$0")/.." && pwd -P)" +IDSTACK_DIR="${1:-$(cd "$(dirname "$0")/.." && pwd -P)}" . "$IDSTACK_DIR/bin/lib/plugin-status.sh" # Domain-specific shape: feeds a `claude plugin list` listing to diff --git a/test/test-preamble-python.sh b/test/test-preamble-python.sh index 358828a..b4d2704 100755 --- a/test/test-preamble-python.sh +++ b/test/test-preamble-python.sh @@ -11,7 +11,7 @@ set -e . "$(dirname "$0")/test-helper.sh" -IDSTACK_DIR="$(cd "$(dirname "$0")/.." && pwd -P)" +IDSTACK_DIR="${1:-$(cd "$(dirname "$0")/.." && pwd -P)}" echo "test-preamble-python" echo " python3: $(python3 --version 2>&1 || echo 'not found')" diff --git a/test/test-status.sh b/test/test-status.sh index 7e5fb51..6ef7ecf 100755 --- a/test/test-status.sh +++ b/test/test-status.sh @@ -15,7 +15,7 @@ set -e . "$(dirname "$0")/test-helper.sh" -REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd -P)" +REPO_ROOT="${1:-$(cd "$(dirname "$0")/.." && pwd -P)}" STATUS="$REPO_ROOT/bin/idstack-status" if ! command -v python3 >/dev/null 2>&1; then diff --git a/test/test-version-classifier.sh b/test/test-version-classifier.sh index cd77c36..11718d9 100755 --- a/test/test-version-classifier.sh +++ b/test/test-version-classifier.sh @@ -22,7 +22,7 @@ set -e . "$(dirname "$0")/test-helper.sh" -IDSTACK_DIR="$(cd "$(dirname "$0")/.." && pwd -P)" +IDSTACK_DIR="${1:-$(cd "$(dirname "$0")/.." && pwd -P)}" . "$IDSTACK_DIR/bin/lib/version-classify.sh" # Domain-specific shape: this compares a version string to an expected