forked from bchanot/claude
fix(floor-guard): word-bound the bare Jasmine skip patterns
skip_kind matched SKIP_SUBSTRINGS as plain substrings, so 'xit(' hit
exit(, SystemExit( and process.exit(, and 'fit(' hit model.fit( and
profit(, flagging FLOOR SKIP on ordinary test-file lines (BLK-023). The
four bare identifiers (xit, fit, xdescribe, fdescribe) now match through
SKIP_IDENT_RE with an identifier-boundary lookbehind; the dotted and
decorator forms stay substrings. Flip-test fixtures cover the false
positive (RED before, GREEN after) and the three focus/skip calls.
This commit is contained in:
+11
-3
@@ -97,9 +97,15 @@ SUPPRESS_SUBSTRINGS = (
|
||||
TS_EXPECT_ERROR = '@ts-expect-error' # floor-guard: allow pattern table
|
||||
|
||||
SKIP_SUBSTRINGS = (
|
||||
'.skip(', '.only(', 'xit(', 'xdescribe(', 'fit(', 'fdescribe(',
|
||||
'it.todo(', '@pytest.mark.skip', '@unittest.skip', 't.Skip(',
|
||||
'.skip(', '.only(', 'it.todo(', '@pytest.mark.skip', '@unittest.skip',
|
||||
't.Skip(',
|
||||
)
|
||||
# bare Jasmine/Jest focus-or-skip calls (xit/fit/xdescribe/fdescribe); the
|
||||
# lookbehind keeps `exit(`, `SystemExit(`, `model.fit(` out (BLK-023).
|
||||
SKIP_IDENT_RE = re.compile(r'(?<![A-Za-z0-9_.])(?:xit|fit|xdescribe|fdescribe)\(')
|
||||
# shortcut: `def fit(` / `function xit(` still match (space before), `xit (`
|
||||
# and `xit.each(` still do not — upgrade path (?<!def )(?<!function ) and
|
||||
# (?:\.each)?\s*\(.
|
||||
|
||||
STUB_SUBSTRINGS = (
|
||||
'not implemented', # floor-guard: allow pattern table
|
||||
@@ -186,7 +192,9 @@ def stub_kind(text):
|
||||
|
||||
|
||||
def skip_kind(text):
|
||||
return 'SKIP' if any(p in text for p in SKIP_SUBSTRINGS) else None
|
||||
if any(p in text for p in SKIP_SUBSTRINGS):
|
||||
return 'SKIP'
|
||||
return 'SKIP' if SKIP_IDENT_RE.search(text) else None
|
||||
|
||||
|
||||
def line_findings(path, lineno, text, test_file):
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
# lib/tests/floor-guard.test.sh — flip-tests for lib/floor-guard.sh: one RED
|
||||
# fixture per KIND, one WAIVED fixture, one CLEAN fixture. Each fixture is a
|
||||
# fresh throwaway repo under $WORK (`make test` exports
|
||||
# fixture per KIND, one WAIVED fixture, one CLEAN fixture, plus boundary
|
||||
# cases for SKIP. Each fixture is a fresh throwaway repo under $WORK
|
||||
# (`make test` exports
|
||||
# GIT_CONFIG_GLOBAL=/dev/null; core.hooksPath is also pinned per-repo so a
|
||||
# machine-wide hook never fires here). This file itself carries the trigger
|
||||
# strings for every kind — the self-run criterion excludes it by pathspec.
|
||||
@@ -54,6 +55,32 @@ echo "it.skip('later', () => {});" >> "$d/sample.test.js"
|
||||
out=$(cd "$d" && bash "$LIB" "$base" 2>&1); rc=$?
|
||||
check_kind SKIP "$rc" 2 "$out" 'FLOOR SKIP'
|
||||
|
||||
# ── SKIP_EXIT_CLEAN ───────────────────────────────────────────────────────
|
||||
d=$(mk_repo skipexit); base=$(git -C "$d" rev-parse HEAD)
|
||||
{
|
||||
echo 'process.exit(1); // sys.exit(1)' # floor-guard: allow flip-test fixture
|
||||
echo 'model.fit(x);' # floor-guard: allow flip-test fixture
|
||||
echo 'const p = profit(1);' # floor-guard: allow flip-test fixture
|
||||
} >> "$d/sample.test.js"
|
||||
out=$(cd "$d" && bash "$LIB" "$base" 2>&1); rc=$?
|
||||
check_kind SKIP_EXIT_CLEAN "$rc" 0 "$out" 'FLOOR GUARD: clean'
|
||||
|
||||
# ── SKIP_XIT_FLAGS / SKIP_FIT_FLAGS / SKIP_FDESCRIBE_FLAGS ────────────────
|
||||
d=$(mk_repo skipxit); base=$(git -C "$d" rev-parse HEAD)
|
||||
echo " xit('skipped', () => {});" >> "$d/sample.test.js" # floor-guard: allow flip-test fixture
|
||||
out=$(cd "$d" && bash "$LIB" "$base" 2>&1); rc=$?
|
||||
check_kind SKIP_XIT_FLAGS "$rc" 2 "$out" 'FLOOR SKIP'
|
||||
|
||||
d=$(mk_repo skipfit); base=$(git -C "$d" rev-parse HEAD)
|
||||
echo "fit('focused', () => {});" >> "$d/sample.test.js" # floor-guard: allow flip-test fixture
|
||||
out=$(cd "$d" && bash "$LIB" "$base" 2>&1); rc=$?
|
||||
check_kind SKIP_FIT_FLAGS "$rc" 2 "$out" 'FLOOR SKIP'
|
||||
|
||||
d=$(mk_repo skipfdescribe); base=$(git -C "$d" rev-parse HEAD)
|
||||
echo "fdescribe('focused', () => {});" >> "$d/sample.test.js" # floor-guard: allow flip-test fixture
|
||||
out=$(cd "$d" && bash "$LIB" "$base" 2>&1); rc=$?
|
||||
check_kind SKIP_FDESCRIBE_FLAGS "$rc" 2 "$out" 'FLOOR SKIP'
|
||||
|
||||
# ── DELETED_TEST ──────────────────────────────────────────────────────────
|
||||
d=$(mk_repo deleted); base=$(git -C "$d" rev-parse HEAD)
|
||||
rm "$d/sample.test.js"
|
||||
|
||||
Reference in New Issue
Block a user