Skip to content

fix(api-runner): pass glob filter on grep fallback and fix glob truncation count - #162

Open
sururu-k wants to merge 1 commit into
mainfrom
fix/api-runner-grep-glob-fallback
Open

sururu-k wants to merge 1 commit into
mainfrom
fix/api-runner-grep-glob-fallback

Conversation

@sururu-k

Copy link
Copy Markdown
Collaborator

Summary

  • In _execute_grep, pass --include={glob_filter} when falling back to grep if rg (ripgrep) is unavailable. Previously, glob_filter was dropped, causing grep to match files of all extensions regardless of the glob argument.
  • In _execute_glob, record the pre-truncation total match count before slicing matches[:500] so the output reflects actual total matches instead of hardcoded 500.

Type of change

  • Bug fix
  • New feature / enhancement
  • Refactor / cleanup (no behavior change)
  • Documentation / benchmarks
  • Pipeline phase change (which phase: ___)
  • CI / tooling

Test plan

  • uv run python3 -m pytest tests/ -v --tb=short passes

Red-before-green evidence (required for Bug fix)

  • The covering test was observed RED on the pre-fix code, then GREEN after the fix (evidence below), OR this PR has no bug-fix behavior change (feature/docs/refactor).
# pre-fix run on host without `rg`:
FAILED tests/test_api_runner.py::TestGrepTool::test_grep_with_glob_filter - AssertionError: assert 'python' not in '/private/var/folders/.../b.py:1:hello python'
assert 'python' not in '/private/var/folders/ky/.../T/pytest-of-hiro/pytest-6/test_grep_with_glob_filter0/b.py:1:hello python'

# post-fix run:
tests/test_api_runner.py::TestGrepTool::test_grep_with_glob_filter PASSED
tests/test_api_runner.py::TestGlobTool::test_glob_truncation PASSED
856 passed, 4 skipped in 54.98s

Schema / contract impact

  • No schema or contract changes
  • Schema changed; affected phases: ___

Related issues / context

  • Discovered while running test suite on environments without ripgrep installed.

Reviewer notes

  • Both GNU grep and BSD grep (default on macOS) support --include=<glob>.

…ation count

- In `_execute_grep`, pass `--include={glob_filter}` when falling back to `grep` if `rg` is unavailable. Previously, `glob` was dropped, causing grep to match files of all extensions.
- In `_execute_glob`, capture the pre-truncation total count before slicing `matches = matches[:500]` so the truncation message reflects actual total matches.
- Add `test_glob_truncation` and verify `test_grep_with_glob_filter` passes on systems without `rg`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant