scripts: tests_for.py names the tests that exercise a change (TESTS-FOR-CHANGE) #2390
Closed
leonida/mandy
syfyra wants to merge 0 commits from
feat/tests-for-change into main
pull from: feat/tests-for-change
merge into: leonida:main
leonida:main
leonida:github-pr/3295
leonida:beta
leonida:docs/changelog-3483-3500
leonida:github-pr/3294
leonida:github-pr/2975
leonida:github-pr/2815
leonida:feat/gate-driver-start
leonida:feat/skip-pipelines-release
leonida:perf/lazy-compare
leonida:perf/mwaitx-wait
leonida:test/prio-ceiling-main
leonida:fix/ab-cpu-stdout
leonida:fix/gate-old-crashes
leonida:diag/ab-cpu
leonida:test/main-0312
leonida:github-pr/3291
leonida:diag/indirect-clamp-census
leonida:feat/barrier-enhanced
leonida:perf/texture-frame-ceiling
leonida:perf/dstorage-threads
leonida:fix/console-queue-dma-tables
leonida:fix/port-descriptors-record-parts
leonida:fix/frame-waits-fence
leonida:fix/console-sampler-words
leonida:fix/graphics-userdata-spill
leonida:fix/xg-reserved-layout-rotation
leonida:fix/barrier-console-flags
leonida:fix/switches-wait-test-child
leonida:test/list-value-waits
leonida:test/lot-gxdk-0412
leonida:fix/bvh-compacted-size
leonida:docs/i18n-quickstarts
leonida:feat/native-pipeline-slots
leonida:fix/clippy-leonida-gpu
leonida:fix/list-value-producers
leonida:fix/descriptor-page-straddle
leonida:fix/xmem-low-window
leonida:fix/ffx-jitter-never-zero
leonida:fix/run-stdout-closed
leonida:github-pr/2892
leonida:github-pr/2896
leonida:feat/warm-save-every
leonida:github-pr/2980
leonida:github-pr/2994
leonida:github-pr/3005
leonida:github-pr/3010
leonida:github-pr/3136
leonida:github-pr/3303
leonida:github-pr/3220
leonida:github-pr/3143
leonida:github-pr/3330
leonida:github-pr/3226
leonida:github-pr/3187
leonida:carry/3395
leonida:github-pr/2946
leonida:github-pr/2947
leonida:github-pr/2945
leonida:github-pr/2983
leonida:github-pr/3001
leonida:github-pr/3372
leonida:github-pr/3128
leonida:github-pr/3296
leonida:github-pr/2588
leonida:github-pr/3119
leonida:github-pr/3378
leonida:fix/crash-diagnostics
leonida:feat/dlss-mip-bias
leonida:fix/retired-out-of-order
leonida:fix/dxr-postbuild-barrier
leonida:fix/amd-relay-default
leonida:fix/removed-report-wait
leonida:feat/heap-twin
leonida:feat/vram-margin
leonida:github-pr/2472
leonida:github-pr/3123
leonida:github-pr/3088
leonida:assets/annonce-v1
leonida:github-pr/2794
leonida:github-pr/3300
leonida:github-pr/3304
leonida:github-pr/3308
leonida:github-pr/3367
leonida:github-pr/3369
leonida:fix/launcher-dlss-diagnostics
leonida:github-pr/3269
leonida:github-pr/2957
leonida:github-pr/3205
leonida:fix/crash-zero-guard
leonida:github-pr/3185
leonida:github-pr/3099
leonida:github-pr/3104
leonida:github-pr/3348
leonida:github-pr/3379
leonida:github-pr/3377
leonida:perf/darner-title-priority-ceiling
leonida:github-pr/3376
leonida:gh-readonly-queue/main/pr-3311-b5c45b663dbc5a9c3532bb3f307e5f81b32faefa
leonida:gh-readonly-queue/main/pr-3088-af22e7847ff5808f72d1a1881c24be2fafd20b54
leonida:gh-readonly-queue/main/pr-3123-7f3fa026a94c6646e89244f28e1ce22290361867
leonida:github-pr/3373
leonida:github-pr/3368
leonida:github-pr/3198
leonida:gh-readonly-queue/main/pr-3354-637baa0b77ba47222e7280b17c1a59c6a1781d57
leonida:gh-readonly-queue/main/pr-3365-d7a0e0196a43834813014b4bd3aa5502a8263b14
leonida:gh-readonly-queue/main/pr-3361-5dfe8bbd05ed12fb2f2e1718d9af77a7c5f46fd8
leonida:gh-readonly-queue/main/pr-3366-8da9148204e9d12c585efa9ac2b7cc1ab08c7682
leonida:github-pr/3346
leonida:github-pr/3375
leonida:github-pr/2958
leonida:github-pr/3151
leonida:github-pr/3307
leonida:github-pr/3278
leonida:github-pr/3374
leonida:fix/runtime-test-conservative-fixtures
leonida:github-pr/3366
leonida:ci/shard-semantic-linux
leonida:github-pr/3354
leonida:docs/fg-limit-fps-switch
leonida:github-pr/3365
leonida:fix/read-file-hard-link
leonida:github-pr/3364
leonida:fix/book-slot-heap-never-read
leonida:github-pr/3361
leonida:github-pr/3263
leonida:github-pr/3360
leonida:github-pr/3353
leonida:github-pr/3331
leonida:fix/alias-later-queued-submissions
leonida:github-pr/3352
leonida:github-pr/3228
leonida:github-pr/3349
leonida:claude/gallant-sagan-aamatr
leonida:github-pr/3200
leonida:github-pr/3132
leonida:github-pr/3323
leonida:github-pr/3332
leonida:github-pr/3340
leonida:github-pr/3311
leonida:github-pr/3334
leonida:github-pr/3297
leonida:github-pr/3256
leonida:github-pr/2567
leonida:github-pr/2851
leonida:d3d12/agility-sdk-621
leonida:github-pr/3164
leonida:github-pr/3114
leonida:github-pr/3050
leonida:github-pr/3113
leonida:github-pr/3326
leonida:github-pr/3144
leonida:github-pr/2642
leonida:github-pr/3072
leonida:github-pr/2789
leonida:github-pr/2643
leonida:github-pr/3009
leonida:github-pr/3035
leonida:github-pr/3031
leonida:github-pr/2686
leonida:github-pr/2834
leonida:github-pr/3321
leonida:github-pr/3325
leonida:github-pr/3290
leonida:github-pr/3324
leonida:github-pr/3130
leonida:claude/fervent-curie-m19lnr
leonida:github-pr/3309
leonida:github-pr/3305
leonida:github-pr/3306
leonida:github-pr/3302
leonida:github-pr/3301
leonida:github-pr/3345
leonida:github-pr/3211
leonida:github-pr/3027
leonida:github-pr/3286
leonida:github-pr/3235
leonida:github-pr/3265
leonida:github-pr/3275
leonida:codex/skip-no-hit-ray-passes
leonida:github-pr/2823
leonida:github-pr/2911
leonida:github-pr/3262
leonida:github-pr/3125
leonida:github-pr/3206
leonida:github-pr/3250
leonida:github-pr/3238
leonida:github-pr/3188
leonida:github-pr/2952
leonida:github-pr/3217
leonida:github-pr/3168
leonida:t3/preserve-fsr-sdk-restart-path
leonida:t3/propagate-host-failure-hresult
leonida:github-pr/3209
leonida:t3/launcher-custom-parameters
leonida:github-pr/3207
leonida:github-pr/3183
leonida:github-pr/3160
leonida:github-pr/3201
leonida:ci/less-to-run
leonida:github-pr/2930
leonida:github-pr/2797
leonida:github-pr/2999
leonida:perf/native-compute-shader-forms
leonida:github-pr/3191
leonida:github-pr/3011
leonida:github-pr/3019
leonida:github-pr/2996
leonida:gh-readonly-queue/main/pr-2789-45dc41f95c1cd0dcc29c2c50582e0e9af8a77259
leonida:claude/blissful-franklin-ukp7ag
leonida:github-pr/3141
leonida:github-pr/3156
leonida:github-pr/3150
leonida:github-pr/3153
leonida:github-pr/3163
leonida:github-pr/3142
leonida:github-pr/3139
leonida:github-pr/2841
leonida:github-pr/3069
leonida:github-pr/3098
leonida:github-pr/3107
leonida:github-pr/3071
leonida:github-pr/2774
leonida:github-pr/2889
leonida:github-pr/3075
leonida:github-pr/2661
leonida:github-pr/3064
leonida:github-pr/3054
leonida:github-pr/3049
leonida:github-pr/2855
leonida:github-pr/2943
leonida:github-pr/3016
leonida:github-pr/2887
leonida:github-pr/3006
leonida:github-pr/3003
leonida:github-pr/2993
leonida:notes/card-time-and-plant-flicker
leonida:github-pr/2989
leonida:feat/vulkan-rs
leonida:github-pr/2985
leonida:github-pr/2951
leonida:github-pr/2982
leonida:github-pr/752
leonida:github-pr/792
leonida:github-pr/2877
leonida:github-pr/2654
leonida:github-pr/2893
leonida:github-pr/2948
leonida:github-pr/2944
leonida:github-pr/2919
leonida:github-pr/2915
leonida:archive/ci/less-to-run/20261202T1121Z
leonida:github-pr/2800
leonida:github-pr/2822
leonida:github-pr/2833
leonida:github-pr/2840
leonida:github-pr/2831
leonida:github-pr/2832
leonida:github-pr/2801
leonida:github-pr/2890
leonida:github-pr/2891
leonida:github-pr/2664
leonida:github-pr/2807
leonida:rt-call-trace
leonida:github-pr/2755
leonida:perf/ahead-split
leonida:github-pr/2587
leonida:github-pr/2698
leonida:github-pr/2609
leonida:github-pr/3219
leonida:docs/readme-runtime-proposal
leonida:github-pr/2017
leonida:github-pr/1741
leonida:github-pr/1667
leonida:codex/coord-claim-check-20261124-7e48
No reviewers
Assignees
Clear assignees
No assignees
Labels
Clear labels
bug
Something isn't working
dependencies
Pull requests that update a dependency file
documentation
Improvements or additions to documentation
enhancement
New feature or request
missing claim
Needs a claim in #14
needs rebase
Conflicts with the base branch: rebase it on main
needs-triage
Needs maintainer evaluation before the next triage state
question
Further information is requested
ready-for-agent
Fully specified and ready for an AFK agent
submodules
Pull requests that update submodules code
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
Projects
Clear projects
No items
No project
Milestone
Clear milestone
No items
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Reference
leonida/mandy!2390
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/tests-for-change"
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?
Pull request closed
This pull request cannot be reopened because the branch was deleted.
Claimed in the coordination issue as: TESTS-FOR-CHANGE (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7197929842)
Depends on: none. It merges cleanly with the two open pull requests that also edit
CONTRIBUTING.md(#2151 and #2349, in another section), checked with thescripts/pr_overlap.pyof #2349.What and why
The maintainer guide says to run "the pull request's own tests", and AGENTS.md to run one test file while iterating. Which tests those are was guesswork: tests are found by their name, and a helper that many tools import has no test of its name.
tools/world_build.pyis named by seven test files, only two of them calledtest_world_build*, and six more reach it throughsandbox.py,sandbox_scene.pyand the two drawable tools.python -I scripts/tests_for.py [PATH ...]reads the repository and answers for the files or folders named, or with no argument for what the branch changes (committed against the merge base withorigin/main, plus modified and untracked files). For each file it lists the tests undertests/that reach it, with the reason:names it: the test imports the file as a module or names its path, as a quoted path or joined from quoted segments (os.path.join, pathlib/, Node'sjoin);imports: a module the test imports reaches the file through imports, with the module it goes through;folder: the test names the folder the file is in and nothing in it, so it reads what is there; for a Markdown file these aretests/test_docs_*.pyandtests/test_i18n_index.py, the set CI runs for a documentation change;fixture: the file is under afixturesfolder and a test beside that folder quotes its name;ctest: forruntime/, the ctest tests whose program is built from the file according toruntime/CMakeLists.txt: as a source, through a header a source includes, or through a library the program links.foreachloops andset()lists are followed.Then it prints the commands, split the way CI splits the tests:
python -Ifor a standalone file, pytest for a file with CI's pytest markers or no__main__block, the semantic runner,node --test, andctest -Rwith the names. Tests that name the file and changed tests always get a command; the wider reasons do when there are at most 20 of them, or with--all.--jsongives the whole report. It runs no test and writes nothing.On this repository (1,048 test files, 492
add_testentries):tools/world_build.py: 7 tests name it, 6 reach it through imports, 11 name thetoolsfolder.tools/rdna2spirv.py: 341 name it and 273 reach it through imports; the command list is 38 lines with the semantic suite as one of them.runtime/shims/ws2_offline.cpp: 16 ctest tests,ws2_offlineand 15 whose command runs a program that is built from it too (run_tiny_game,run_argv_modesand others).viewer/index.html:tests/test_viewer_streaming.cjsandtests/test_docs_repo_paths.pyname it, andtests/test_viewer_cdn_integrity.pyis one of the two that name the folder.What it cannot see, also said in its docstring: a path that is built at run time, and a ctest program that a CMake function or a generator expression builds. Of the 492
add_testentries, 15 run something it cannot place (gameinput,run_tiny_asyncand others) and one keeps a${...}in its name and is left out, so the ctest list is the least there is to run. Paths are matched in the case they have on disk, so Windows gives the same answer as Linux.CONTRIBUTING.mdgets one bullet under "Working on the code".Tested
Windows 11, Python 3.14.7, git 2.55.0:
python -I tests/test_tests_for.py: 32 tests. 28 run on a synthetic checkout of 62 small files kept as data intests/fixtures/tests_for_checkout.json(its paths would otherwise read as references of the test file to real files, which one of the tests checks), one on a throwaway git repository for the branch mode, and three on this repository.main, where the script does not exist.python -I scripts/tests_for.py tools/world_build.pytakes 1.8 s here.python -Ion the 13tests/test_docs_*.py,tests/test_i18n_index.py,tests/test_tool_stdout_encoding.py,tests/test_text_write_line_endings.pyandtests/test_ci_registration.py;python -I scripts/check_no_game_data.pyon the new files.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. (No translator rule in this change.)🤖 Generated with Claude Code
VERIFY-2390 — Linux, Python 3.15, no GPU, no game files
Setup. PR head
25a8f9e9(1 commit, based ond5634def, which is 2 178 commits behind themainat the time of this run,d920d850). Merged into a clean worktree atd920d850— clean merge, no conflicts. Fedora Linux VM, Python 3.15.2, no Vulkan device needed for anything below.1. Its own suite
32/32. This is the part anyone can produce; the rest is what I went looking for.
2. Do its claims hold against ground truth
For 12 files I compared the report against an independent grep of
tests/for the file's stem (excluding a test's own filename), then read every divergence by hand.No false positives. Across all 12 files,
extra = 0: every test the tool reports undernames itreally does contain the file's name.Most divergences are correct exclusions, and there are a lot of them:
# awc_names.py labels a bank from an audio_manifest.json ...— a comment (tests/test_opus_tags.py:300)"sandbox-scene"used as a process label,sandboxin prose (tests/test_sandbox_scene.py:250)tests/semantic/test_*.pydocstrings saying "run_gpu_tests.py / check.py with LEONIDA_BARY_FALLBACK=1 check ps_bary" — the runner runs those tests; they do not test the runnertests/test_gamedata_index_report_paths.py:3naming its own path, which the tool correctly ignores (there is a test for that:test_a_test_that_names_its_own_path_is_not_its_own_test)On the full list rather than the
names itbucket the count drops from 39 to 31, and by inspection 29 of those 31 are correct. Two are not.3. Reverse control
This is the one that matters, because the tool's answer is the list a verifier runs first.
tools/meshlet_page.py:1047-1050:tests/test_tool_stdout_encoding.pyguards exactly this, two ways: a static check that every__main__block reconfigures stdout, andMeasuredCrashes, which runs each tool under a private-use-named folder and asserts noUnicodeEncodeError:Before any change:
The test reaches the file through
os.path.join(TOOLS, tool)wheretoolcomes from a list of bare filenames, so thenames itrule does not follow it, and the test never names thetoolsfolder either, sofolderdoes not catch it.All 19 listed tests PASS.
tests/test_tool_stdout_encoding.pyPASS.Mutation. Line 1049 replaced with
pass:test_tool_stdout_encoding.pyAfter the mutation
tests_for.pystill returns the same 19 tests, still withouttest_tool_stdout_encoding.py, and the one test that catches it says so by name:So for this change the tool prints nineteen green commands and omits the only test that fails. A contributor running what it prints gets no signal at all.
The tree was restored afterwards (
git statusclean,test_tool_stdout_encoding.pyback toOK).4. The same class, second instance
tests/test_zero_span.py:28-35runs nine scanners, including this one, throughrunpy.run_pathfrom a table keyed by bare tool name:tests_for.py --all tools/restofworld_index.pylists 19 tests;tests/test_zero_span.pyis not among them.5. Minor
The description's counts are from the old baseline. It says
tools/world_build.py: "7 tests name it, 6 reach it through imports, 11 name thetoolsfolder". Ond920d850that is 7 / 6 / 16. The first two match; the third has grown with the suite. Worth refreshing before merge, since a reviewer will compare against it.Verdict
Mergeable, and correct about everything it does claim. 32/32 on its own suite, zero false positives in the audited sample, and the reasons it gives hold up when read.
But it is not complete, and the gap points the dangerous way. It misses tests that reach a file through a data table of tool names, and those tend to be the tests that actually execute the file rather than mention it. For the case above, the recommended list is all-green while the real test fails.
Two ways to close it, either is enough:
runpy.run_path,subprocessor atools/join), or--help— "this list is not exhaustive; a green run here is not proof" — so nobody treats it as a complete answer.Nothing here needs game files or a GPU, so the same runs reproduce anywhere.
AI-assisted: yes — MiMo-V2.6-Flash (OpenCode). It built the worktree, wrote the grep cross-check and the mutation, and drafted this report; I read the divergent lines above rather than trusting either side.
Verified with its tests and used on a real file. It works, and for a Rust file it answers with the Python tests that reach it and none of the ones inside it - which is the gap worth knowing before this lands.
The suite, on
maind920d850dplus the range (its based5634defeis not behindmain, cherry-pick clean):So the tests are tied to the script and nothing else was needed to make 32 pass.
Used as a user would, on a file this repository argues about more than any other:
That is correct for what it models, and the model is Python.
host.rshas a module of 636 Rust tests that exercise it directly -host::refresh_tests::only_what_differs_goes_upamong them - and the tool names none.Why that matters here:
scripts/tests_for.pysays nothing aboutrust,.rs,cargoor#[test](I grepped for all four), andd3d12/is half this repository. For a Python change the answer is the one this tool gives; for a Rust change the answer is "two Python files reach this", which is not the question someone editinghost.rsis asking.What I would suggest, and it is the same suggestion I made on #2817 for a different reason: say the languages it covers in
--helpor in the output - one line,python only, saves a Rust contributor from concluding the file is untested - and, if the crate is worth it,cargo test -p <crate> <module>is a naming exercise the tool is already shaped for.One thing it gets right that is easy to miss:
imports (1): ... (through tools/game_gate.py)- it says which module the reachability goes through, not just that it exists. That is the part that makes the answer checkable by hand, and it is why the two names above are trustworthy even though the list is short.AI-assisted: yes - DeepSeek v4.1 (flash), which ran the suite, the control, and the tool.
Written with an AI assistant.
Marking Ready for Review since no WIP/blocker reason for draft status is specified on this PR, so it can enter normal CI and review.
(AI-assisted triage.)
Confirmed and isolated the missing explicit-path behavior mentioned in the review, at
25a8f9e91+9f27ba2e1. The PR now needs a local resolution inCONTRIBUTING.mdafter #2871. On the resolved tree the original 32 tests passed, while my new test rejected the current behavior of exiting 0 for a typo. Checking existence inexpand_targetsmade both missing file paths return 2 with no suggestions. A separate disposable Git test confirmed that a deleted file still appears in the branch-mode report. All 33 tests passed with the local change, and the local help text names its Python, Node.js and CTest scope.AI-assisted with OpenAI Codex (GPT-6).
Branch-mode check on Windows at 25a8f9e91, using two clean fork checkouts and --base d741a9f8f. For the PowerShell game-gate help branch (357778964), the selector found tests/test_game_gate.py by name and returned six default commands. Five came solely from folder matches, including test_run_wine_tests.py and test_x64_recomp_qemu_runner.py for the changed test file. For the NTFS report-path branch (d94b68ba1), it returned 17 default commands including test_report_paths.py and test_report_path_case.py. It marked 935 further tests as omitted, including test_report_source_collision.py, an end-to-end suite for tools that consume this helper. Both primary regression suites were selected. These examples illustrate why the reason field matters: a folder match can be incidental or it can cover a real downstream CLI. I checked selection only. Codex-assisted.
Closing: this pull request no longer applies to current
main(merge conflict inCONTRIBUTING.md), and open pull requests that have fallen out of step withmainare being closed so the list stays workable. If you still want this change, rebase it on currentmainand reopen it (or open a new pull request); it will be looked at again.AI-assisted (Claude Code).