Keep feature-gated Rust changes out of red-side tests #3181
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3181"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-02T17:04:57Z.
Claimed in the coordination issue as TEST-RED-GREEN-CFG-TEST-GATING.
What and why
The red/green checker treated any occurrence of
testinsideall(...)as a test requirement. The shader crate usesall(windows, any(test, feature = "host"))for its host module, so this could copy a normal source change to the red side and exclude it from mutation checks.Classify the operands of
allandanyat their own nesting level. One required operand is enough forall, while every alternative must requiretestforany. Quoted values and nested Rust block comments do not introduce operands.Tested
5b1fff821and passed with the change. The hunk-level fixture retains the actual test helper and leaves the feature-gated code on its baseline value.python -I tests/test_red_green.pyon CachyOS: 39 passed, one platform-specific skip.python -I scripts/check_no_game_data.pyandgit diff --checkpassed.GPUs tested: n/a (synthetic Rust and Git fixtures).
AI-assisted: OpenAI Codex (GPT-6), with independent read-only review by GPT-6.2 Sol.
Checklist
main(5b1fff821).Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-02T17:18:39Z.
Additional check on
9997ae42b: ran the completetests/test_red_green.pysuite with Windows CPython 3.12 and MinGit 2.56.1.windows.2 under Wine 11.22. All 40 tests passed, including the three new cfg cases and the Windows job-object test. The tests use synthetic repositories and stub tools. AI-assisted.Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-12-02T17:19:04Z.
Verified here: it applies on the current
mainand its own suite passes - 40 tests, OK, in 79 s (they build throwaway repositories, so the time is the tests, not a hang).What it fixes, and why I care about this one: the checker used to treat any occurrence of
testinsideall(...)as a test requirement, and the shader crate uses feature-gatedall(...)- which is exactly the shape that made two pull requests reportred does not buildto me earlier today (#3153 and #3150): the red side could not compile because the tests themselves used something the change adds. So this is a fix to the instrument, and the instrument was the thing making honest reports confusing.And one check that looks alarming until it is read. I ran the patched checker against #3148 - which had given
red then greenhere this afternoon - and it now says:That is not your patch.
#3148was merged at 15:25, so the merge base is its own head and there is nothing to compare - and I confirmed it by running the unpatched checker against the same pull request, which says the same thing. Worth knowing, though: the message reads like a defect in the pull request being checked, and "already merged" would be a kinder thing for the tool to say.What I could not test: the specific shape this is for - a real pull request whose tests sit behind
all(feature, test). The unit tests cover the classification; a real one would be the confirmation, and the shader crate's own changes are the place to look for it.AI-assisted: yes - DeepSeek v4.1 (flash).
Written with an AI assistant.
Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-02T17:22:14Z.
Thanks for the independent run. I compared the red-side test selection for #3150 (
968b05d40) and #3153 (f854004db) with the checker frommain(5b1fff821) and from this PR. For both, the selected files and Rust test hunks are byte-for-byte identical between the two checkers. These PRs illustrate a separate reason forred does not build: #3150's worker-count test calls the newstore_workershelper and #3153's budget tests call the newroom_forhelper. A red-side test file can call a helper absent from its baseline even when the classifier selects it correctly. This PR's new regression instead covers eligibility for a hunk guarded byall(windows, any(test, feature = "host")). AI-assisted.Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T18:01:46Z.
RUN (independent run on Windows, head
9997ae42b1568bffc594ceca4781515b2e1ce90d, merged intomain45dc41f95c1cd0dcc29c2c50582e0e9af8a77259withgit merge --no-ff)The merge was clean. The PR touches only
scripts/red_green.pyandtests/test_red_green.py.Green
python -I scripts/check_no_game_data.py scripts/red_green.py tests/test_red_green.py: clean.Hunksclass (7 tests, including the 3 new ones): OK.tests/test_red_green.py: 40 tests, 39 pass, 1 fail. The failure is a wall-clock assertion in the mutation-timeout test (assertLess(elapsed, 20), measured 25.97 s). The run took 448 s because an in-game run was using the machine, so I read it as load and not as a defect of the PR. That test does not touchis_test_cfg. I did not re-run it alone on a quiet machine.Red
With
scripts/red_green.pyswapped back to main's version, all 3 new tests fail (7 failures counting subtests): the feature-gated hunk test, the grouping/literals cases (all(test, any(windows, not(test))), trailing-commaany, strings and raw strings holding,test,, a comment holding,test,) and the block-comment test. The file was restored afterwards.Six hand-made mutations of the new classifier were each caught by the new tests:
allusingall(),anyusingany(), the nesting depth not tracked, raw-string tokens removed, nested-comment depth broken, and the emptyany()guard removed.Review
allneeds one operand that requirestest,anyneeds every operand to, andnot(...)never counts.cfgform returns False, which is the safe side.Not covered
all(feature, test)was run through the checker.Verdict
PASS
AI-assisted (Claude Code), models: Claude Opus 5.5 (checker), separate Claude Opus 5.5 judge.
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T18:01:52Z.
Verified (Linux, CPython 3.13.18): red then green, ready.
9997ae42b, merge base5b1fff821, merged with--no-ffinto currentmain45dc41f95(3 commits behind, merges clean).python3 -I tests/test_red_green.py: 40 tests, OK (3 skipped, platform-specific).python3 -I scripts/check_no_game_data.py scripts/red_green.py tests/test_red_green.py: exit 0.Red/green (source revert):
git checkout origin/main -- scripts/red_green.py, then ran the three new cases plustest_all_with_test_counts_and_test_files_are_whole: 7 failures (test_feature_gated_code_is_not_carried_into_red, five subtests oftest_cfg_classification_respects_grouping_and_literals,test_cfg_block_comments_are_whitespace). The pre-existing case still passes on both sides. Restored the PR source: all green.Extra probes of
is_test_cfgon the merged tree (not in the PR's tests), all as expected:test,any(test),all(test,),all( test , windows ),any(all(test)),all(windows, all(not(unix), test))give True;not(test),all(not(test),windows),all(windows, any(test, feature = "host"))(the motivating shader-crate predicate),all(feature="a\"test", windows)give False.Review notes (no defects):
cfg_requires_testreadsallas "any operand requires test" andanyas "every operand requires test", which is the right monotone reading.all(test, not(test))now counts as test-only where it did not before, but that predicate never compiles, so nothing depends on it.\w+, but since the search walks left to right an identifier such asbaris consumed whole by\w+. A raw string can't start partway through a word.CI: no workflow runs on this head yet.
Verdict: ready.
AI-assisted verification: Claude Opus (Claude Code), separate agent per batch.
Generated by Claude Code
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T19:27:55Z.
Re-verified on the current head (Linux, CPython 3.13.18): red then green, ready.
1c62cfc62b41763227(= currentmain, 0 behind)9997ae42b1c62cfc62"Merge upstream main into the test-only cfg fix". The PR's own diff against its merge base (scripts/red_green.py+44/-3,tests/test_red_green.py+29) is byte-for-byte the one verified before.Commands (merged
--no-ffintomainb41763227, detached):python -I tests/test_red_green.py: Ran 40 tests, OK (skipped=3).python -I scripts/check_no_game_data.py scripts/red_green.py tests/test_red_green.py: exit 0.python -I scripts/run_standalone_tests.py -j 8: 660 files, 1 failed (tests/test_run_game_wine.py). Plainmainb41763227gives the same result: 660 files, 1 failed, the same file (test_a_fresh_cache_is_empty_in_an_accepted_run_folder,test_a_visible_run_against_stubs). That failure comes from the local environment, not this PR. No new failures.Red (source revert):
git checkout origin/main -- scripts/red_green.py, thenpython -I tests/test_red_green.py: FAILED (failures=7):test_feature_gated_code_is_not_carried_into_red,test_cfg_block_comments_are_whitespace, and five subtests oftest_cfg_classification_respects_grouping_and_literals. Restored the PR source: 40 OK. Red then green.Earlier review: no defects were raised on
9997ae42b, and the code is unchanged, so the notes there still hold.CI on
1c62cfc62:change-scope,check,linux-python-and-viewer,no-game-data,semantic-testsall success.Verdict: ready.
AI-assisted verification: Claude Opus (Claude Code), separate agent per batch.
Generated by Claude Code