Skip to content

test(windows): use shutil.which for mm entry-point lookup (#643)#723

Merged
memtomem merged 1 commit intomainfrom
test/win-mm-binary-shutil-which
May 2, 2026
Merged

test(windows): use shutil.which for mm entry-point lookup (#643)#723
memtomem merged 1 commit intomainfrom
test/win-mm-binary-shutil-which

Conversation

@memtomem
Copy link
Copy Markdown
Owner

@memtomem memtomem commented May 2, 2026

Summary

  • Cluster F of the Windows: replace POSIX path-separator assertions in tests (/ vs \\) #643 Windows sweep (1 test).
  • TestFreshNoopIndexSubprocess::test_init_index_search_via_subprocess errored out on Windows with mm binary not found at D:\a\memtomem\memtomem\.venv\Scripts\mm because the test built the path with a hardcoded "mm" name and os.path.exists check. On Windows the uv-installed entry point is mm.exe, not mm.
  • Switch to shutil.which("mm", path=bin_dir) — that helper is PATHEXT-aware on Windows (tries .exe, .cmd, .bat) and no-extension on POSIX, returning the platform-correct full path ready to hand to subprocess.run.

Diff

+8 / -3 — adds import shutil, replaces the path construction + os.path.exists check with shutil.which + is None check, and updates the error message to say "not found in <bin_dir>" since the binary suffix is now platform-determined.

Test plan

  • macOS: uv run pytest packages/memtomem/tests/test_cli_index_noop_e2e.py — 2/2 pass (resolves to .venv/bin/mm).
  • Lint: ruff check + ruff format --check clean.
  • Windows CI: should resolve to .venv\Scripts\mm.exe and run the subprocess.

Out of scope

The remaining 26 Windows failures cluster into ~6 separate root causes — each will get its own PR per feedback_one_change_per_pr.md. Cluster B (memory_dir prefix) intentionally skipped — parallel work in flight on fix/647-windows-memory-dir-prefix and fix/720-source-filter-windows.

🤖 Generated with Claude Code

`TestFreshNoopIndexSubprocess::test_init_index_search_via_subprocess`
constructed the path to the `mm` script as
`os.path.join(os.path.dirname(sys.executable), "mm")` and then checked
`os.path.exists(mm_bin)`. On Windows the entry point installed by
`uv pip install -e` is `.venv/Scripts/mm.exe`, not `mm` — so the
existence check failed and the test errored out with `mm binary not
found at D:\a\memtomem\memtomem\.venv\Scripts\mm`.

`shutil.which("mm", path=bin_dir)` does the lookup the way Python
itself does it: PATHEXT-aware on Windows (tries `.exe`, `.cmd`, `.bat`),
no-extension on POSIX. The returned path is the full executable path
ready to hand to `subprocess.run`, which is exactly what the test
already does on the next line. The error message changes from "not
found at <path-with-name>" to "not found in <bin_dir>" since the
suffix is now platform-determined.

Cluster F of the #643 sweep — single test, single root cause. Production
code is unchanged.

Co-Authored-By: Claude <[email protected]>
@memtomem memtomem merged commit 3fe9b8d into main May 2, 2026
8 of 9 checks passed
@memtomem memtomem deleted the test/win-mm-binary-shutil-which branch May 2, 2026 07:31
@github-actions github-actions Bot locked and limited conversation to collaborators May 2, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants