mirror of
https://github.com/obra/superpowers.git
synced 2026-07-25 03:34:01 +08:00
fix(systematic-debugging): find-polluter accepts ./-prefixed patterns and matches top-level tests
Follow-up to #2011 (which fixed the ./-prefix mismatch for the documented pattern form): strip a leading ./ from the caller's pattern instead of double-prefixing it into a never-matching ././ form, and also match the pattern with '**/' collapsed, since find -path cannot match '**/' against zero directory levels and silently skipped files directly under the base directory (src/top.test.ts vs src/**/*.test.ts). Adds a deterministic test suite for the script with a stubbed npm.
This commit is contained in:
committed by
Drew Ritter
parent
6015d37fe6
commit
c8921b5156
@@ -18,8 +18,13 @@ echo "🔍 Searching for test that creates: $POLLUTION_CHECK"
|
||||
echo "Test pattern: $TEST_PATTERN"
|
||||
echo ""
|
||||
|
||||
# Get list of test files (find . emits ./-prefixed paths)
|
||||
TEST_FILES=$(find . -path "./$TEST_PATTERN" | sort)
|
||||
# Get list of test files (find . emits ./-prefixed paths, so accept the
|
||||
# pattern written with or without a leading ./)
|
||||
TEST_PATTERN="${TEST_PATTERN#./}"
|
||||
# find -path can't match '**/' against zero directory levels, so a pattern
|
||||
# like src/**/*.test.ts would skip src/top.test.ts; also try the pattern
|
||||
# with '**/' collapsed to cover files directly under the base directory.
|
||||
TEST_FILES=$(find . \( -path "./$TEST_PATTERN" -o -path "./${TEST_PATTERN//\*\*\//}" \) | sort -u)
|
||||
if [ -z "$TEST_FILES" ]; then
|
||||
TOTAL=0
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user