Repository navigation
Conversation
…ST-RED-GREEN-COMPILER-CRASH) A verification's only trial said "red does not build" while rustc had crashed (0xC0000005). A side whose cargo output shows rustc or a build script ending with a Windows crash status, an internal compiler error or a failed allocation now builds again once, and the report says so; a second crash gives the verdict `compiler crashed` (exit 1), not `red does not build`. A test binary that crashes stays a test result.
… itself (TEST-RED-GREEN-MUTATION) Verifiers remove a line of the fix by hand on nearly every test pull request to see the new test fail. --mutate does it for each hunk of the pull request's code outside its tests (Rust and Python files it changes; hunks taken without context, so a test changed next to the code stays out): after the green side, it undoes that hunk alone, runs the tests again and reports it as caught (a test that went red then green fails), not caught, does not build or does not apply, up to --mutate-max hunks (10); the hunk is put back after each run. Python tests now run with -B: an undone change of the same size within the same second would otherwise run the stale bytecode.
|
Verified with its own tests in both directions, and then used it on a real pull request, where it did exactly what it should - and showed me one thing it cannot do. The tests, at each head on Then the tool, on a pull request that is not mine: That verdict is correct and the pull request is fine: #2803 only adds a test, so there is nothing in its diff to mutate. I then found the mutation by hand - removing Where that leaves
Neither is a complaint about what is here - the red/green split is exactly the right frame and the JSON output is going to be usable from a script. I am writing this because I did the same job by hand for eleven hours tonight, and I would have used AI-assisted: yes - DeepSeek v4.1 (flash), which also ran it. Written with an AI assistant. |
|
Verified by OreoFR on macOS 27.2.1, Apple M5, Python 3.12, head MEASURED
Small note: AI-assisted: Claude Code |
KelboLive
left a comment
There was a problem hiding this comment.
Reproduced on Windows / Python 3.12, and the mechanism is sound — this is not "any nonzero exit counts as caught":
python -I tests/test_red_green.py 19 tests, OK, 26 s
python -I scripts/red_green.py 2810 --no-cargo --mutate --work-dir … red then green (2), 21 pass both arms,
6 hunks: 5 caught, 1 not caught (game_gate.py:72), 21 s
git status --porcelain --ignored afterwards empty (no __pycache__, no stray files)
Your numbers and the clean-tree claim reproduce exactly. I also checked the three outcomes by hand in throwaway repos with a stub cargo: undoing a hunk so the module raises at import reports does not build, an untested new function reports not caught, a tested change reports caught.
Two things need fixing:
- Added files are silently never mutated.
scripts/red_green.py:541uses--diff-filter=M, so a fix whose logic lives in a new module never has its hunks mutated, while the summary still reads as full coverage. Reproduced: a fix that addstools/helper.py(holding the change) and edits an existing module to call it reports "2 hunks … 2 caught" and never toucheshelper.py. Either includeA(and define what undoing an addition means) or state the limitation indocs/testing.mdand in the report itself. - The
-Bcomment atscripts/red_green.py:329is wrong.-Bstops writing bytecode, not reading it. With a stale__pycache__/*.pycfrom an earlier run (checkout()usesgit clean -fdqat :249, which does not touch ignored paths, and__pycache__/is ignored), a reverted module still reportsok; I gotnot caughtthat way. Use-X pycache_prefix=<fresh temp dir>per run, or remove__pycache__(orgit clean -fdxq).
Minor: when a hunk cannot be restored, mutate returns None and report() drops the whole mutations section, so --mutate silently shows nothing (and in --json it is indistinguishable from "not requested"). There is also no per-run timeout, so --mutate multiplies any hang by up to --mutate-max.
|
Thanks @KelboLive. Confirmed: when a hunk cannot be restored, To keep this verified head unchanged, I will fix both in a follow-up pull request after the merge: the report will say the mutations stopped and why, and each mutated run will have a timeout that counts as caught when it expires. Each change will come with a test. |
VERIFY-2817 — Linux, Python 3.15, no GPU device, no game filesVerdict: PASS — the change does what it says, and the part that is new (the mutation check) reports a known answer correctly. Head 1. Its own suite, and the three rows
Row B's failures are assertions, not load errors — the test file runs on The other failure and the four errors are the same cause: 2. Discrimination: does the new test look at the changed code?A test that passes with the fix and without it proves nothing, so I undid the pull request's production change alone on the green tree and ran the new tests:
3.
|
| sample | expected | reported |
|---|---|---|
one code hunk (return 1 → return 2), the test asserts the new value |
caught |
tools/bar.py line 2 caught |
| two hunks: the fix, plus a change to a second function no test looks at | caught + not caught |
tools/bar.py line 2 caught, line 16 not caught |
| the verdict | unchanged by a not caught hunk |
red then green, exit 0 |
The not caught row is the point of the option: it names code that no new test looks at, which is exactly what a verifier does by hand. It does not change the verdict, so a pull request with an untested hunk is still red then green.
One note on reading the output, in case it catches someone else: --mutate counts hunks, and git diff -U0 merges two edits that are close together into one hunk. My first sample put the two edits two lines apart and got one hunk, which is git's behaviour and not the tool's; with the edits far enough apart it reports two. The tool's own test puts ten padding lines between the two changes for the same reason.
4. What I did not check
- The
#[cfg(test)]exclusion and the "a hunk that only adds test code" rule are read in the code, not measured against a real pull request with a Rust#[cfg(test)]hunk next to the fix. - The Windows crash statuses (
0xC0000005and the rest) are matched by the tool's own tests with the text cargo prints; I did not see a real Windows rustc crash. - The cargo path (
cargo_once,cargo_tests) is exercised only through the stub cargo the tests use; I did not run a realcargo teston a D3D12 crate.
5. Neighbours
tests/test_red_green.py is the only test file this touches. On the PR head the file's 19 tests pass, and the rest of the standalone Python suite is unaffected by this change (it adds a flag to a script; it does not change what the script does without the flag).
AI-assisted: MiniMax M3.1 Flash.
6. The whole standalone suite, against the same runner on a clean treeTo check that the change costs nothing elsewhere, I ran the repository's standalone test runner over the pull request's head and over a clean
The two failures are the same two files on both trees, and neither is this change's:
So the pull request adds its 19 tests and changes nothing else in the suite. AI-assisted: MiniMax M3.1 Flash. |
7. Two cases I did not reach, so the report does not read as covering them@TheGeogeo noted two things about this head, and I did not exercise either, so they are untested by me:
My samples always restored their hunks, so I saw neither. The author says both are fixed in a follow-up pull request after the merge. AI-assisted: MiniMax M3.1 Flash. |
A note on this machine's graphics, so "no GPU device" is not misreadI said above that this host has no GPU device. That is true of the Vulkan device, and I should be precise about which path I mean, because the two paths differ here and a reader could otherwise take my wording the wrong way. What this machine is. A VMware Workstation guest (Fedora 45) on a host with a Radeon 780M. There is no PCI passthrough: the only display device inside the guest is the virtual There is no Vulkan hardware device here. mesa's svga driver has no Vulkan backend, so the loader enumerates nothing by default; with The OpenGL path is hardware-accelerated, though. The guest's SVGA3D calls are forwarded by the host-side VMware renderer to the host's Radeon 780M. The evidence I measured, comparing the default path with
What follows for the verification above. Anything that needs a real GPU device or driver is invalid on this host, and none of my conclusions rest on one: the tests I ran are CPU-only, and the tool they measure is a Python script. Where a measured number came from this machine's GPU stack, it says so. Two things I checked that a reader might otherwise assume. AI-assisted: MiniMax M3.1 Flash. |
Correction to my note above: the frame-rate comparison was not controlledMy note above said that on this host the software path measured faster than SVGA3D (713 vs 1061 draws/s in an off-screen rasterisation loop; 88 vs 308-692 FPS in With the window size and the swap interval fixed,
The two figures I quoted before were the default window with the default swap interval, which is the one combination that happens to favour the software path. So:
One difference worth recording so the numbers are not read as a reproduction: in the vsync-on row my llvmpipe run reached 546 FPS where the other run on this host reached 89 FPS for the same setting. This is a Wayland session and the swap interval is not honoured identically on the two paths, so the vsync-on row is not a like-for-like comparison between them; the two vsync-off rows are. AI-assisted: MiniMax M3.1 Flash. |
Claimed in the coordination issue as: TEST-RED-GREEN-MUTATION (#2570 (comment))
Depends on: #2814 (this branch holds its commit and will be rebased on
mainonce it is merged)What and why
A red side that fails shows that the new test needs the pull request. It does not show that the test catches the change itself. Verifiers check that by hand, on nearly every test pull request: they remove a line of the fix and see whether the new test fails.
scripts/red_green.py --mutatedoes it for every hunk of the fix:After the green side,
--mutatetakes each hunk of the pull request's code: Rust and Python files it changes, outside its tests and its#[cfg(test)]code.It undoes that hunk alone on the green tree and runs the tests again. Each hunk is reported as one of:
caught: a test that went red then green now fails;not caught: they all still pass, so no new test looks at that code;does not build;does not apply:mainmoved those lines since.It puts the hunk back after each run, and tries at most
--mutate-maxhunks (10).The verdict and the exit code do not change.
--jsongives each hunk's file, line and result.Python tests now run with
-B. Otherwise an undone change of the same size, written within the same second, would run the stale bytecode (seen while writing the tests).docs/testing.mddescribes the option.Tested
On Windows 11 Pro 10.0, Python 3.12:
tests/test_red_green.py: 19 tests OK. The three new ones fail with scripts: red_green.py tells a crashed compiler from a build error (TEST-RED-GREEN-COMPILER-CRASH) #2814'sred_green.py:caughtat line 2 andnot caughtat line 17. The worktree is clean afterwards.caught;--mutatethere is no mutation.python -I scripts/red_green.py 2810 --no-cargo --mutateonmaind920d85 took 28 s. The verdict isred then greenfor its 2 new tests, with 21 passing on both sides.tools/game_gate.py'sSOURCES. Only the contract test reads it, and that test passes on both sides, so it is not one of the targets. That is the kind of result this is meant to show.test_tool_stdout_encoding.pyandscripts/check_no_game_data.pyon the changed files are clean.GPUs tested: n/a
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)