fix(tests): exclude build/ from bats test discovery
Why tests/run-bats.sh's discovery walk already excludes apm_modules/ and .claude/skills/ because those hold apm-installed copies of the same *.bats files one directory level shallower than their plugins/*/.apm/ source, which overshoots the hardcoded six-levels-up REPO_ROOT walk each test's setup() does and fails to find the bats-support helper. build/ was missing the same exclusion: apm pack stages an identical copy under build/<package>-<version>/ before archiving, hitting the exact same failure mode from a different apm subcommand. A stray local `apm pack` run leaves that directory on disk (gitignored, regenerable) and silently doubles the suite (846 tests instead of 423) with 423 of them failing. Implementation Notes Added `-not -path "*/build/*"` to the find walk and the matching git ls-files grep exclusion, mirroring the existing apm_modules/ and .claude/skills/ entries. Extended tests/test-run-bats.sh with a case following the same pattern as the existing exclusion-bug fixtures. Impact Unblocks the run-tests pre-commit/pre-push hook for any checkout that has ever run a bare `apm pack` locally.
This commit is contained in:
@@ -46,6 +46,17 @@ fi
|
||||
# which is ADR-0024 consequence 2 arriving here. Keeping the exclusion now is
|
||||
# what stops that landing as a mystery double-run on the merge that enables it.
|
||||
#
|
||||
# build/ is excluded for the same reason again, one layer further out: `apm
|
||||
# pack` stages a full copy of a package's tree (including its skills' tests/
|
||||
# directories) under build/<package>-<version>/ before archiving it. Those
|
||||
# staged .bats files carry the same six-levels-up REPO_ROOT walk-up as any
|
||||
# other copy, which resolves past this repo's actual root and fails on a
|
||||
# missing bats-support helper -- the same failure mode apm_modules/ and
|
||||
# .claude/skills/ above already guard against, just from a different apm
|
||||
# subcommand. build/ is gitignored and regenerated on demand, so nothing here
|
||||
# depends on its contents; the exclusion only stops a stray local `apm pack`
|
||||
# output from being discovered and double-run.
|
||||
#
|
||||
# The walk runs from inside REPO_ROOT so the exclusions match paths RELATIVE to
|
||||
# it, the same universe the `git ls-files` grep below sees. Matched against
|
||||
# absolute paths, `*/.claude/worktrees/*` excluded every file whenever the
|
||||
@@ -61,6 +72,7 @@ done < <(
|
||||
-not -path "*/.claude/worktrees/*" \
|
||||
-not -path "*/apm_modules/*" \
|
||||
-not -path "*/.claude/skills/*" \
|
||||
-not -path "*/build/*" \
|
||||
| sort
|
||||
)
|
||||
|
||||
@@ -99,7 +111,7 @@ if [[ -n "$GIT_TOPLEVEL" && "$GIT_TOPLEVEL" == "$REPO_ROOT" ]]; then
|
||||
[[ -n "$f" ]] && EXPECTED_FILES+=("$REPO_ROOT/$f")
|
||||
done < <(
|
||||
git -C "$REPO_ROOT" ls-files -- '*.bats' \
|
||||
| grep -Ev '(^|/)tests/bats/|(^|/)test_helper/|(^|/)\.claude/worktrees/|(^|/)apm_modules/|(^|/)\.claude/skills/' \
|
||||
| grep -Ev '(^|/)tests/bats/|(^|/)test_helper/|(^|/)\.claude/worktrees/|(^|/)apm_modules/|(^|/)\.claude/skills/|(^|/)build/' \
|
||||
| sort || true
|
||||
)
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user