Repository navigation
Lint: flag path-dependent negative greps in test scripts - #2348
Merged
Merged
Conversation
A test that runs `! grep` for a path-segment word (worktrees, home, tmp, ...)
over a log holding absolute paths passes in CI but fails in a lane worktree,
because the checkout path contains the word. path_hermetic_lint.py flags that
in scripts/test-*.sh.
Each line is split on ; && || | outside quotes. In every segment starting with
`! grep`, any listed word appearing as a whole word in the literal (non-$var)
text is a hit, so a second grep on a line, unbalanced quotes, -e/-eX/--regexp=,
and -m N/-A N all flag. A hit is exempt only when the grep's input file (its
last arg) is written on that line or the previous one by a sed/replace that
uses $ROOT/$PWD; the strip may sit in a loop body (`while read ...; do
${l//"$ROOT"/}; done >f`), but a strip that writes a different file does not
count. The baseline is keyed on `path<TAB>stripped line text` and
messages print path:line, so a new offender in a baselined file fails. Two
reviewed offenders are baselined. Regression test covers each reviewer case.
Tests: 25/25 (6 path-hermetic lint unit tests, incl. loop-body strip and
strip-into-other-file cases, + 19 scan-summary checks); path_hermetic_lint over repo clean, no stale rows
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Supersedes #2327, which conflicted with main. It also carried #2326's commit, and #2336 has since landed that change.
This is one squashed commit on current main. The lint now exempts the while-read strip that #2336 put in test-review-checks-scan-summary.sh: the strip may sit in a loop body when the redirect follows
done. A strip that writes a different file still does not count. Before the fix, the new lint flagged main's own test.Tests: 25/25 (6 lint unit tests, including the loop-body and strip-into-other-file cases, plus 19 scan-summary checks). The lint is clean over the repo. On the old lint, 2 of the 6 tests fail.
🤖 Generated with Claude Code