scripts: red_green.py checks a pull request red and green locally (TEST-RED-GREEN-LOCAL) #2787
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2787"
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 TheGeogeo on 2026-11-30T20:53:20Z.
Claimed in the coordination issue as: TEST-RED-GREEN-LOCAL (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7290856448)
What and why
CONTRIBUTING.md asks for a test that fails on
mainand passes with the change. Verifiers check that by hand today, each in their own way: a worktree, a cherry-pick of the test file, two builds, then reading two test logs. docs/testing.md describes it only for C++runtime/on fork CI. This addsscripts/red_green.py(standard library), which does it locally for the D3D12 crates and the Python tests:Green is current
main(it fetchesorigin/mainand the pull request) with the pull request merged.Red is current
mainplus only the pull request's tests:testsfolder,*_tests.rs,tests.rs;#[cfg(test)]items: a#[cfg(test)] mod x { ... }block, a#[cfg(test)] mod x_tests;line, a#[cfg(test)]function. Blank lines and comments around them are allowed. Braces in strings, raw strings, chars and comments do not end a block. A hunk that mixes test and other code stays on the green side only.That change is committed on the merge base and cherry-picked onto
mainwith a 3-way merge. A conflict, or a pull request with no test, is "red not constructible".It runs
cargo test --locked --no-fail-fast -p <crate>for every crate underd3d12/cratesord3d12/appsthe pull request touches. It runs fromd3d12/, so the pinned toolchain applies. It also runs each changedtests/**/test*.pywith unittest.Both sides run in one worktree with one cargo target dir under
<git common dir>/red-green, red first, never in parallel. A lock file refuses a second run. The worktree and the target dir stay, so the next run builds only what changed. Shared target dirs across worktrees were left out because they rebuild each other's crates.It prints, per test: red then green; pass on red and fail on green; fail on both (failing on
maintoo); found on one side only. Then the verdict:red then green(exit 0);no red,red does not build,green fails,red not constructible,green not constructible,no tests ran(exit 1);red does not buildis the case docs/testing.md calls "does not build without the pull request's new file".--jsongives everything.docs/testing.md has a new subsection next to the fork-CI recipe. C++
runtime/tests stay with that recipe.Tested
On Windows 11 Pro 10.0.26300, Python 3.12, git 2.56.1.windows.1:
tests/test_red_green.py, 13 tests, all passing. They use throwaway git repositories and a stub cargo, with no game data:no red;red not constructible;green fails;red does not build;mod x_tests;line,cfg(not(test)), a mixed hunk, braces in raw strings and chars.maind8ca18240:leonida-lua):red then greenfor its 5 new tests, 35 pass on both, in 29 s from a cold target dir. That matches the red/green its verifier reported (35 + 5 failing onmain, 40/40 with it).leonida-shader): the red side tooksource_hash_tests.rsand themod source_hash_tests;hunk oflib.rs, and leftbuild.rs(the fix) out. Result:red then greenfor 2 tests, 401 pass on both, in 792 s. That matches its verifier's check: 2 of the 3 new tests fail onmainby assertion.tests/test_docs_*.py,tests/test_tool_stdout_encoding.py,tests/test_ci_registration.py,scripts/check_no_game_data.pyon the changed files, andgit diff --checkare clean.GPUs tested: n/a (no GPU code)
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a: no translator change)Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-30T20:57:45Z.
Verified by OreoFR (another owner than TheGeogeo) on macOS 27.2.1, Apple M5, Python 3.12.16, Rust (rustup),
maind8ca18240merged with head1f08a8abb.tests/test_red_green.py13 passed. Red (main+ only the test): 1 error at import, as expected for a new script.tests/test_docs_*.py57 passed;tests/test_tool_stdout_encoding.py4 passed;check_no_game_data.pyon the three changed files: clean.python -I scripts/red_green.py 2784from the merged tree →red then green (5)(the 5 newleonida_lua::tests::*gate-driver tests),pass on both: 35,verdict: red then green, exit 0. That matches my manual red/green of #2784 (35 + 5 failed → 40/40), so the tool works off Windows for a crate that builds here.leonida-gpu), and the Windows-only test modules.AI-assisted: Claude Code
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-30T22:33:33Z.
Merging. Head
1f08a8abbmerges cleanly withmain6494909b7and does not force a rebase of #2566. CI green on this head. Verified by OreoFR on it; I ran it on main + PR: 13 tests OK, docs tests OK (Windows, Python 3.14); without the new script its test does not import. I read the script's git and subprocess calls: it works in its own worktree. Merged by MoonEyes.AI-assisted (Claude Code).