Skip to content

test(tools): fix Windows compat in test_search_hidden_dirs - #41135

Closed
Thorx373 wants to merge 1 commit into
NousResearch:mainfrom
Thorx373:fix/use-shutil-which-in-search-hidden-dirs-test
Closed

test(tools): fix Windows compat in test_search_hidden_dirs#41135
Thorx373 wants to merge 1 commit into
NousResearch:mainfrom
Thorx373:fix/use-shutil-which-in-search-hidden-dirs-test

Conversation

@Thorx373

@Thorx373 Thorx373 commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

Problem

tests/tools/test_search_hidden_dirs.py fails at collection on Windows with FileNotFoundError: [WinError 2], aborting the pytest run. Once that's resolved, two further tests fail on Windows because they shell out to Unix-only find/grep.

Root Cause

  1. Two @pytest.mark.skipif decorators ran subprocess.run(["which", "rg"], ...) at collection time. which doesn't exist on Windows (it uses where), so the call raised FileNotFoundError during import, before any test ran.
  2. test_find_still_returns_visible_files and test_grep_still_finds_visible_content invoke Unix find/grep directly. On Windows, find.exe is a different command (FIND: Parameter format not correct) and grep isn't present.

Fix

  1. Replace the subprocess.run(["which", "rg"]) checks with cross-platform shutil.which("rg") is None. The ripgrep tests now run and pass on Windows.
  2. Mark the two find/grep tests skipif(sys.platform == "win32") — they depend on Unix coreutils with no Windows equivalent, so a platform skip is correct rather than a rewrite. Behavior on macOS/Linux/CI is unchanged.

Testing

Before: FileNotFoundError at collection (entire file errors).
After: file collects; ripgrep tests pass, Unix-coreutils tests skip on Windows.

   pytest tests/tools/test_search_hidden_dirs.py -v
   7 passed, 2 skipped

Tested on Windows 11, Python 3.11.9.

@alt-glitch alt-glitch added type/test Test coverage or test infrastructure tool/file File tools (read, write, patch, search) P3 Low — cosmetic, nice to have labels Jun 7, 2026
@Thorx373 Thorx373 closed this Jun 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P3 Low — cosmetic, nice to have tool/file File tools (read, write, patch, search) type/test Test coverage or test infrastructure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants