Repository navigation
tools: register the self-tests nothing ran, and teach the sweep to see a tools/*.py at all (fixes #1901) - #1916
bong-water-water-bong wants to merge 1 commit into
Conversation
…e a tools/*.py at all (fixes #1901) #1824's check asks whether every `tests/*.sh` is referenced by something that can run it -- `need` is that glob and nothing else, so a tool shipping a `--self-test` was invisible to it. Two were unregistered at the time the issue was filed; the rule below finds **three**, and the third is the reason the rule exists rather than the two hand-picked files: ``` tools/batched_repeat.py --selftest (not in the issue's list) tools/whisper_encoder_baseline.py --self-test ``` Both are registered here through #1891's `add_python_test()`: `batched_repeat.py --selftest` (its own spelling, since before the hyphenated convention) and `whisper_encoder_baseline.py --self-test`. Both pass on this tree, device-free. **The rule, and why it is narrow.** `need` now also includes any `tools/*.py` that *declares* a self-test. The blanket version ("every tools/*.py referenced by nothing") found 16 of 60 on this tree -- most legitimately CLI-only -- and a list that noisy is one nobody reads. A tool that ships a check and is registered nowhere is the defect; a tool that only has a CLI is not. **And the sweep was green on a disabled registration**, which is the same defect one layer in. `referenced()` counted a basename anywhere in a place that can run things, so `# add_python_test(...)` — or `# add_test(...)` for the 73 scripts — read as a runner. Comment-only lines are dropped now, and the mutation shows it: with both of this PR's registrations commented out the sweep names them instead of passing. ## Self-test Two cases added, in the file's own style (synthetic roots, and the verdict has to NAME the offender): * a self-testing tool nothing registers → drift, named; * the same tool registered → clean, **and** a `tools/*.py` with no self-test is not a row (the negative that keeps the rule narrow). ## Verified ``` tools/ci/tests_referenced_check.py --check --root . -> 73 script(s) and 17 self-testing tool(s) are referenced (rc 0) tools/ci/tests_referenced_check.py --self-test -> 0 failure(s) python3 tools/batched_repeat.py --selftest -> selftest: ok python3 tools/whisper_encoder_baseline.py --self-test -> whisper_encoder_baseline: ok ctest -R 'tests_referenced|tool_selftest|ci_targets' -> 100% tests passed, 0 failed out of 6 mutation: comment out both registrations -> the sweep names both tools tools/copyright.py --check (staged) -> rc 0 ``` Fixes #1901. Refs #1824, #1891.
|
Closing as a duplicate of #1910 ( What #1910 has that this does not:
What I have handed to #1910 and would like kept, because it is a real hole in the sweep this PR extends: referenced() counts a basename in a COMMENT as a runnerMeasured on my copy: commenting out both registrations left I also reviewed #1912 (the third PR for this issue) and asked for it to be closed in favour of #1910, with one piece to fold in: argparse-parsed detection rather than a substring match, so a docstring mentioning Rule for me, again: |
#1824's check asks whether every
tests/*.shis referenced by something that can run it —needis that glob and nothing else, so a tool shipping a--self-testwas invisible to it. Two were unregistered when the issue was filed; the rule below finds three, and the third is the reason the rule exists rather than the hand-picked pair:Both are registered here through #1891's
add_python_test()—batched_repeat.py --selftest(its own spelling, from before the hyphenated convention) andwhisper_encoder_baseline.py --self-test. Both pass on this tree, device-free.The rule, and why it is narrow.
neednow also includes anytools/*.pythat declares a self-test. The blanket version ("everytools/*.pyreferenced by nothing") found 16 of 60 on this tree — most legitimately CLI-only — and a list that noisy is one nobody reads. A tool that ships a check and is registered nowhere is the defect; a tool that only has a CLI is not.And the sweep was green on a disabled registration — the same defect one layer in.
referenced()counted a basename anywhere in a place that can run things, so# add_python_test(...), or# add_test(...)for the 73 scripts, read as a runner. Comment-only lines are dropped now, and the mutation shows it: with both of this PR's registrations commented out, the sweep names them instead of passing.Self-test
Two cases in the file's own style (synthetic roots; the verdict must NAME the offender):
tools/*.pywith no self-test is not a row (the negative that keeps the rule narrow).Verified
Fixes #1901. Refs #1824, #1891.