Skip to content

loopguard: read a test run spelled the Windows way, or through the py launcher - #339

Open
Lanre Shittu (Shizoqua) wants to merge 2 commits into
microsoft:mainfrom
Shizoqua:fix-loopguard-windows-test-runs
Open

Lanre Shittu (Shizoqua) wants to merge 2 commits into
microsoft:mainfrom
Shizoqua:fix-loopguard-windows-test-runs

Conversation

@Shizoqua

Copy link
Copy Markdown
Contributor

On Windows a runner is named with backslashes, a drive letter and .exe: C:\repo\.venv\Scripts\python.exe -m pytest, .venv\Scripts\pytest.exe, python.exe -m pytest, as Claude Code's PowerShell tool records it. It may also be started through the py launcher: py -m pytest, py -3.12 -m pytest. The micro-skills observer reads the first forms as test runs (test_a_windows_interpreter_path_is_the_interpreter, from #268), but the loop guard's verification pattern read none of these, so a failing one after the last edit left the turn counted as ended green.

Fix: each command is matched as it reads with forward slashes, no drive letter and no .exe, and with the py launcher (by name or path, with its -V:<tag> or -3.x option, per CPython's "Using Python on Windows") read as python (_as_run, in status_of_tests). The patterns themselves are unchanged, so the lines other open PRs edit (_PYTHON, VERIFY_RE, _PREFIX_RE, _NOT_A_RUN_RE) are untouched. python.exe repro.py, py -m pip install pytest, py -3.12 --version, pyright and pytest.exe --collect-only are still not test runs, and py.test is pytest's own name as before. Over the 5,256 strings in the test suites, only Windows-spelled runs read differently.

The companion change for micro-skills, reading py as the interpreter there too, is a separate PR.

Tests, in a new tests/test_loopguard_windows_runs.py:

  • 9 runs spelled the Windows way, each a verification, and a failing run after an edit is not ended green (all fail on main);
  • 6 runs through the py launcher (all fail on main);
  • the observer and the loop guard agree on 7 Windows-spelled runs (fail on main);
  • 9 Windows commands that run no tests stay non-runs.
python -m pytest tests -n 4 --dist worksteal -rfEs --tb=line
1598 passed, 41 skipped

The skips need Windows, a real agent CLI (Codex, Hermes, opencode) or aider, or a non-root user.

Fixes #338

On Windows a runner is named with backslashes, a drive letter and `.exe`:
`C:\repo\.venv\Scripts\python.exe -m pytest`, `.venv\Scripts\pytest.exe`, `python.exe -m pytest`,
as Claude Code's PowerShell tool records it. The micro-skills observer reads these as test runs
(`test_a_windows_interpreter_path_is_the_interpreter`), but the loop guard's verification pattern
did not, so a failing one after the last edit left the turn counted as ended green.

Each command is now matched as it reads with forward slashes, no drive letter and no `.exe`
(`_posix_spelling`); the patterns themselves are unchanged. `python.exe repro.py`,
`.venv\Scripts\python.exe -m pip install x` and `pytest.exe --collect-only` are still not test
runs. Over the 5,107 strings in the test suites, only Windows-spelled runs read differently.
`py -m pytest`, `py -3.12 -m pytest` and `py -V:3.12 -m pytest` run the tests through the Windows
`py` launcher, which starts the default Python or the one a `-V:<tag>` or `-3.x` option chooses
(CPython's "Using Python on Windows"). The loop guard read none of them as a test run.

The launcher, by name or path and with its version option, is now read as `python`.
`py repro.py`, `py -m pip install pytest`, `py -3.12 --version` and `pyright` are still not test
runs, and `py.test` is pytest's own name as before.
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.

loopguard: a test run spelled the Windows way, or through py, is not counted as a verification

1 participant