Skip to content

test: one source cutter for the checks (tests/srccut.py), 80 checks moved to it - #2914

Open
jordanella wants to merge 24 commits into
NotRexed:mainfrom
jordanella:test/srccut
Open

jordanella wants to merge 24 commits into
NotRexed:mainfrom
jordanella:test/srccut

Conversation

@jordanella

Copy link
Copy Markdown
Contributor

123 checks carry their own copy of a brace counter (def block) to cut a function out of a source file. The copies count braces inside strings, character literals and comments too, and when a function is renamed or reshaped they stop with a bare ValueError or IndexError that doesn't say which source or marker: the trap AGENTS.md warns about ("Tests read the source"). This gives the checks one cutter and moves 80 of them to it, each shown to cut exactly what it cut before. The dev-loop proposal's D2 (#2636).

Change

  • tests/srccut.py (new, standard library):
    • block(text, marker): from the marker to the brace that closes the first { after it, counting braces outside string and character literals (raw strings too, and C++14 digit separators), comments and preprocessor lines;
    • between(text, start, end);
    • a marker that is missing, or that appears twice, stops the check with one message naming the source and the marker (unique=False takes the first on purpose);
    • SRCCUT_CHECK_NAIVE=1 also cuts each block the old way and stops if the two differ: what a migration runs to show it changed nothing.
  • 80 checks import it in place of their copy, one commit per source file they read (vk_menu.cpp, vk_draw.cpp, vk_memory.cpp, vk_texture.cpp, hookshot_env.h, hos_main.c, ...). Only exact copies of the plain counter moved.
  • Not moved:
    • three checks whose block isn't the plain counter (a start offset; positions returned): restored as they were;
    • 13 checks whose marker appears more than once in the source (a declaration before the definition, for example). The old counter took the first one silently, so each needs a look rather than unique=False;
    • 51 checks with other cutters (function, body, between, ...): later, by source file.

Testing

  • Every moved check, against today's main: each run as main has it and as moved with SRCCUT_CHECK_NAIVE=1, with its declared tools (the Builder's clang, the Vulkan headers): 80 of 80 pass both ways, no cut differs.
  • tests/test_srccut.py (new): braces in strings, character literals, raw strings, comments and preprocessor lines; a fixture the old counter cut wrongly; a missing marker and a repeated one name the source; between; an unclosed block; the comparison with the old counter.
  • A follow-up after feat(tests): run_all.py --changed runs the checks that read what changed #2887: run_all.py --changed runs a test helper's importers (srccut's) rather than every check.

See #2636 (D2).

🤖 Generated with Claude Code

jordanella and others added 24 commits November 12, 2026 12:28
…k_menu.cpp readers

123 checks carry their own copy of a brace counter (def block) that
counts braces in strings, character literals and comments too, and
stops with a ValueError or IndexError when a marker is gone.
tests/srccut.py is one cutter for all: block() counts braces outside
literals (raw strings too), comments and preprocessor lines; between();
and a marker that is missing or appears twice stops the check with one
message naming the source and the marker.

The nine checks of gpu/vk/vk_menu.cpp with a copy of the old counter
import it now. Each was run with SRCCUT_CHECK_NAIVE=1, which also cuts
each block the old way and stops if the two differ: the same text in
all nine. The dev-loop proposal's D2 (NotRexed#2636).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Nineteen checks of gpu/vk/vk_draw.cpp drop their copy of the old brace
counter. Each, run with SRCCUT_CHECK_NAIVE=1 against the committed
version: the same text cut and the same result.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
9 checks drop their copy of the old brace counter. Each, run with
SRCCUT_CHECK_NAIVE=1 against the committed version: the same text cut and
the same result (9 run, 0 skipped for a tool this PC lacks).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
8 checks drop their copy of the old brace counter. Each, run with
SRCCUT_CHECK_NAIVE=1 against the committed version: the same text cut and
the same result (8 run, 0 skipped for a tool this PC lacks).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
8 checks drop their copy of the old brace counter. Each, run with
SRCCUT_CHECK_NAIVE=1 against the committed version: the same text cut and
the same result (8 run, 0 skipped for a tool this PC lacks).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
4 checks drop their copy of the old brace counter. Each, run with
SRCCUT_CHECK_NAIVE=1 against the committed version: the same text cut and
the same result (3 run, 1 skipped for a tool this PC lacks).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
3 checks drop their copy of the old brace counter. Each, run with
SRCCUT_CHECK_NAIVE=1 against the committed version: the same text cut and
the same result (3 run, 0 skipped for a tool this PC lacks).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
3 checks drop their copy of the old brace counter. Each, run with
SRCCUT_CHECK_NAIVE=1 against the committed version: the same text cut and
the same result (3 run, 0 skipped for a tool this PC lacks).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2 checks drop their copy of the old brace counter. Each, run with
SRCCUT_CHECK_NAIVE=1 against the committed version: the same text cut and
the same result (2 run, 0 skipped for a tool this PC lacks).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2 checks drop their copy of the old brace counter. Each, run with
SRCCUT_CHECK_NAIVE=1 against the committed version: the same text cut and
the same result (2 run, 0 skipped for a tool this PC lacks).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2 checks drop their copy of the old brace counter. Each, run with
SRCCUT_CHECK_NAIVE=1 against the committed version: the same text cut and
the same result (2 run, 0 skipped for a tool this PC lacks).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2 checks drop their copy of the old brace counter. Each, run with
SRCCUT_CHECK_NAIVE=1 against the committed version: the same text cut and
the same result (2 run, 0 skipped for a tool this PC lacks).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2 checks drop their copy of the old brace counter. Each, run with
SRCCUT_CHECK_NAIVE=1 against the committed version: the same text cut and
the same result (2 run, 0 skipped for a tool this PC lacks).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 checks drop their copy of the old brace counter. Each, run with
SRCCUT_CHECK_NAIVE=1 against the committed version: the same text cut and
the same result (1 run, 0 skipped for a tool this PC lacks).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 checks drop their copy of the old brace counter. Each, run with
SRCCUT_CHECK_NAIVE=1 against the committed version: the same text cut and
the same result (1 run, 0 skipped for a tool this PC lacks).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 checks drop their copy of the old brace counter. Each, run with
SRCCUT_CHECK_NAIVE=1 against the committed version: the same text cut and
the same result (1 run, 0 skipped for a tool this PC lacks).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 checks drop their copy of the old brace counter. Each, run with
SRCCUT_CHECK_NAIVE=1 against the committed version: the same text cut and
the same result (1 run, 0 skipped for a tool this PC lacks).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 checks drop their copy of the old brace counter. Each, run with
SRCCUT_CHECK_NAIVE=1 against the committed version: the same text cut and
the same result (1 run, 0 skipped for a tool this PC lacks).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 checks drop their copy of the old brace counter. Each, run with
SRCCUT_CHECK_NAIVE=1 against the committed version: the same text cut and
the same result (1 run, 0 skipped for a tool this PC lacks).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 checks drop their copy of the old brace counter. Each, run with
SRCCUT_CHECK_NAIVE=1 against the committed version: the same text cut and
the same result (1 run, 0 skipped for a tool this PC lacks).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 checks drop their copy of the old brace counter. Each, run with
SRCCUT_CHECK_NAIVE=1 against the committed version: the same text cut and
the same result (1 run, 0 skipped for a tool this PC lacks).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 checks drop their copy of the old brace counter. Each, run with
SRCCUT_CHECK_NAIVE=1 against the committed version: the same text cut and
the same result (1 run, 0 skipped for a tool this PC lacks).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 checks drop their copy of the old brace counter. Each, run with
SRCCUT_CHECK_NAIVE=1 against the committed version: the same text cut and
the same result (0 run, 1 skipped for a tool this PC lacks).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…counter

test_global_table_loop takes a start offset, and test_mesh_unreachable_outputs
and test_vendor_translation return the block's positions, not its text:
srccut.block is neither. Moved by a detector that looked at the counting
line alone; the last two could not run here (no Vulkan headers), so the
comparison did not catch them. Back as they were.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant