Commit Graph

16 Commits

Author SHA1 Message Date
bf65aa4505 scripts: red_green.py skips a folder it cannot list, stops with the tree put back on a __pycache__ it cannot remove, and four smaller fixes (review)
drop_bytecode skips a folder it may not list (Python cannot import from it either). A __pycache__ it cannot remove is now a usage error naming it (exit 2), and any such error during a run puts the tree back on the base, where before the undone hunk stayed. --mutate-timeout must also be finite. In a mutated run, a Python test stopped while running outweighs a cargo build that was stopped. job_of says once on stderr when it has no job object. docs/testing.md: one line rewrapped.
2026-12-02 05:19:44 +01:00
673ac44a1b tests: red_green.py checks that the process a mutated run leaves behind is stopped, not only that it does not hold the run (review)
With the output in a file the run no longer waits for such a process, so only a mark it would write later shows that the job (the process group elsewhere) stopped it. drop_bytecode reads a folder's attributes only for folders.
2026-12-02 05:19:44 +01:00
5660cff104 tests: red_green.py --mutate on code that sits only in added files has nothing to undo in the files it modifies (review) 2026-12-02 05:19:44 +01:00
0ab167f754 scripts: red_green.py refuses --mutate-max below 1, a --mutate-timeout that is not above 0, and both without --mutate (review) 2026-12-02 05:19:44 +01:00
fc0ce37ac4 scripts: red_green.py reports a cargo run stopped before any test ran as timed out building, not caught (review)
A mutated cargo run that times out before its first Running line was still a build: it says nothing about the tests, so it is no longer counted as caught by timeout. A stub cargo that hangs in its build or in a test binary now covers the cargo timeout path, which no test reached before.
2026-12-02 05:19:44 +01:00
4a0aa701d0 scripts: red_green.py lists the hunks --mutate-max leaves out (review)
With more code hunks than --mutate-max, the report read as if every hunk was tried. The hunks left out are now in --json (mutations_skipped, file and line) and in the text (not tried, past --mutate-max).
2026-12-02 05:19:44 +01:00
0d2dea6c70 scripts: red_green.py tells a hunk of test code only with one rule, for the red side and for the mutations (review)
code_hunks looked only at the lines a hunk adds, so a hunk that deletes an obsolete test inside a #[cfg(test)] module was mutated and read as not caught, while the red side took it as a test hunk. Both now use test_hunk_flags: every removed or added line is test code, blank or a comment, and one at least is test code.
2026-12-02 05:19:44 +01:00
29712017c4 scripts: red_green.py starts each mutation from a commit of the green merge, reset and cleaned (review)
A put-back that applies did not prove the tree green again: a test that wrote into a tracked file changed the result of the next hunk. The green merge is now committed with the tool's identity before its tests run, and each mutation resets the tree to it and cleans it before undoing its hunk. A hunk can no longer fail to go back, so mutations_stopped and its test are gone; a test that dirties the tree now has its own.
2026-12-02 05:19:44 +01:00
312bf7c892 scripts: red_green.py stops what a mutated run leaves behind, so an orphan holding its output does not hold the run (review)
taskkill /T on a command that has already ended finds no tree: a child it left behind kept the output pipe open, the run waited for the timeout and a real caught read caught by timeout. A mutated run now writes its output to a temporary file and, on Windows, runs in a job object (kill on close) that its children join; once the command ends or times out, the job (the process group elsewhere) is stopped.
2026-12-02 05:19:44 +01:00
a7a22ff874 scripts: red_green.py removes only the work tree's own __pycache__ folders, never through a link or junction (review)
Path.rglob follows directory junctions on Windows, so a junction in the tree to an outside folder had that folder's __pycache__ deleted, and a link itself named __pycache__ made shutil.rmtree raise. The walk now skips symbolic links and every reparse point (junctions included).
2026-12-02 05:19:44 +01:00
89274bac6e scripts: red_green.py --mutate says when it stopped, why nothing was undone, and which added files it does not mutate (review)
A hunk that cannot be put back no longer drops the whole mutations section: the report and --json (mutations_stopped) name the hunk, the reason and how many hunks were not tried. With --mutate, mutations is always a list and mutations_not_run says why none was undone: nothing to undo (a test-only pull request), or no test went red then green. Files the pull request adds stay unmutated, and the report and --json (added_not_mutated) now list them. Verdicts and exit codes are unchanged.
2026-12-02 05:19:44 +01:00
745808fc3b scripts: red_green.py --mutate-timeout stops a mutated run that hangs and reports it as caught by timeout (review)
Each command of a mutated run (cargo test, one Python test file) is stopped after --mutate-timeout seconds (600) together with the processes it started (taskkill /T on Windows, the process group elsewhere): a test binary or a process a test starts would otherwise keep the output pipe open. The hunk is then 'caught by timeout', apart from 'caught'. The red and green sides have no timeout, as before.
2026-12-02 05:19:44 +01:00
de6db4b733 scripts: red_green.py removes the work tree's __pycache__ before each Python run, so no test runs stale bytecode (review)
-B only stops writing bytecode. An ignored .pyc left in the work tree (git clean keeps it) ran instead of the reverted source: red passed and an undone hunk was not caught. -X pycache_prefix would cover the unittest process only, not the processes its tests start; removing the folders covers both.
2026-12-02 05:19:44 +01:00
dc63e371ce scripts: red_green.py --mutate checks that the tests catch the change 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.
2026-12-02 05:19:44 +01:00
f442c3dfba scripts: red_green.py tells a crashed compiler from a build error (TEST-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.
2026-12-01 01:49:41 +01:00
1f08a8abb1 scripts: red_green.py checks a pull request red and green locally (TEST-RED-GREEN-LOCAL)
Green is current main with the pull request merged. Red is current main plus only the pull request's
tests: its test files, and the hunks of other Rust files that change only #[cfg(test)] items,
committed on the merge base and cherry-picked with a 3-way merge. It runs the touched D3D12 crates'
cargo test and the changed tests/**/test*.py on both sides, in one worktree and one target dir under
the git common dir, and prints per test: red then green, pass on red and fail on green, fail on both,
on one side only, with a verdict and an exit code. docs/testing.md has it next to the fork-CI recipe.
2026-11-30 21:52:48 +01:00