Repository navigation
loopguard: read python's own options before a test run - #226
Open
Lanre Shittu (Shizoqua) wants to merge 1 commit into
Open
Lanre Shittu (Shizoqua) wants to merge 1 commit into
Lanre Shittu (Shizoqua) wants to merge 1 commit into
Conversation
`python -W error -m pytest`, `python -X dev -m pytest` and `python -u -m unittest` put the interpreter's options between `python` and `-m`. The verification pattern read only `python -m`, so the run was not a verification, and a failing run after the last edit left the turn counted as ended green. The same held for `python -W error manage.py test` and `python -u tests/runtests.py`. Python's flags (`-b`, `-B`, `-E`, `-I`, `-O`, `-u`, ... and `-W`/`-X` with their value) are now passed over, case-sensitively, before what it runs. `python -W error repro.py` and `python -u -m pip install` are still not test runs.
Muhammad Abdullah Butt (1AbdullahButt)
left a comment
Contributor
There was a problem hiding this comment.
Looks correct. Here's what I checked.
_PYTHONis used in both places the pattern names the interpreter. That's the optional launcher prefix (turn.py:42, which coverspython -u tests/runtests.pyandpython -W error manage.py test) and thepython -m pytest|unittestalternative (:43).status_of_testsonly matchesVERIFY_REat the start of each stage after_PREFIX_RE(:166), souv run python -X dev -m pytestandPYTHONWARNINGS=error python -W error -m pytestwork as well.- The scoped
(?-i:...)keeps the flags case-sensitive under the outer(?i), the same way the ruby options do.-mand-caren't in the flag class. Sopython -u -m pip install pytestandpython -W error -c "import pytest"stay non-runs: the match is anchored, so the laterpytestis never reached. - I ran the pattern on edge cases beyond the new tests.
-Wd,-W ignore::DeprecationWarning -m unittest,-OO,-X importtime,-X utf8=1,-s -Eand-x -m pytestall giveown.python -E repro.pygivesNone. A-W/-Xvalue can't start with-, so-Wcan't take the next flag as its value. - No backtracking risk. Each repeated option starts with
\s+-and its value\S*can't cross whitespace, so the*group can only split one way. - I ran
tests/test_live_core.pyandtests/test_cache_write_1h.pyon the branch: 287 passed, 1 skipped.git merge-treeagainstmainis clean.
Out of scope, as the comment above VERIFY_RE says: state.TEST_RUN_RE (state.py:17-19) still only knows python -m unittest. So python -u -m unittest adds to verifications, but not to SpiralState.test_runs (state.py:195). python -W error -m pytest is counted there anyway, through \bpytest\b.
Reviewed with help from Claude Code.
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.
python -W error -m pytest,python -X dev -m pytestandpython -u -m unittestput the interpreter's options betweenpythonand-m.VERIFY_REread onlypython -m, so the run was not a verification, and a failing run after the last edit left the turn counted as ended green.python -W error manage.py testandpython -u tests/runtests.pyhad the same gap.Fix: Python's flags (
-b,-B,-d,-E,-i,-I,-O,-P,-q,-s,-S,-u,-v,-x, and-W/-Xwith their value, attached or not) are passed over before what it runs, case-sensitively, as the ruby options are.python -W error repro.py,python -X dev -c '...'andpython -u -m pip install -e .are still not test runs.Tests, in
tests/test_live_core.pynext to the env/nice ones:test_a_runner_behind_pythons_own_options_counts_as_a_verification: 10 commands. Each is a verification, and a failing run after an edit is not ended green. All 10 fail on main (assert None == 'own') and pass with the fix.test_pythons_own_options_leave_what_it_runs_to_decide: 4 commands that stay non-runs.The skips need a real Codex, Hermes, opencode or aider, Windows, or a non-root user.
Fixes #224