From 61e39b26f819d635ee12946045cc9dac0867a44c Mon Sep 17 00:00:00 2001 From: bong-water-water-bong Date: Tue, 10 Nov 2026 13:42:53 -0400 Subject: [PATCH] cmake: the Python tool self-tests get their own registration file (engine#1979, first family) Every open PR appends an `add_test`/`add_executable`/`add_dependencies` row to one 1100-line CMakeLists.txt, so each merge shifts every following hunk and a PR open for a few hours conflicts on registration lines whose meaning never changed -- three PRs from three lanes in one afternoon, all stale on `CMakeLists.txt` alone. The mechanism that fixes it already exists and is half-adopted: `cmake/tests-gpu-hold.cmake` is the one family file, and BOTH CI guards already treat `cmake/tests-*.cmake` as registration files (`hrx_build_scope.py`'s REGISTRATION_FILE, and `ci_targets_check.py` follows `include()` since #1601). This moves the block every lane touches most: the **eleven** `add_python_test(...)` rows (ci_targets and its self-test, tests_referenced, device_holders, moe_placement, pack-version, the five `tool_selftest_*` rows, and the two beside them) into `cmake/tests-python-tools.cmake`, with a single `include()` where they were. They are contiguous, target-free, and unguarded, which is what makes the move safe: a family file whose `include()` sat inside an `if()` would change which configuration registers its tests, so that is the thing to check before moving any other family. Verified three ways, because "the rows are still there" is the only claim that matters here: * `ctest -N` on a **fresh configure of main** and of this branch both report **186** tests -- nothing lost, nothing duplicated; * the eleven moved names are all present in the branch's list; * `ci_targets_check --check` -> "9 ... (baseline 9), and none new"; `tests_referenced_check` -> "21 tool self-test(s) are registered" (unchanged); `copyright.py --check` clean for tracked files. Refs #1979 --- CMakeLists.txt | 25 +------------------ cmake/tests-python-tools.cmake | 44 ++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 24 deletions(-) create mode 100644 cmake/tests-python-tools.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 71b63011b..1291e3466 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -293,30 +293,7 @@ function(add_python_test name) message(STATUS "ctest: not registering ${name} (no Python3 interpreter)") endif() endfunction() -# engine#1864: the ordering rule itself, checked on the file (no configure, no build): every ${Python3_EXECUTABLE} use has -# to follow the find_package above. The nine that did not ran through their exec bit, and a mode-only rewrite of one -# script turned the row into BAD_COMMAND. -add_python_test(python_test_order_check ${CMAKE_SOURCE_DIR}/tests/python_test_order_check.py --check --root ${CMAKE_SOURCE_DIR}) -add_python_test(python_test_order_check_self ${CMAKE_SOURCE_DIR}/tests/python_test_order_check.py --self-test) -add_python_test(ci_targets ${CMAKE_SOURCE_DIR}/tools/ci/ci_targets_check.py --check --root ${CMAKE_SOURCE_DIR}) -add_python_test(ci_targets_self ${CMAKE_SOURCE_DIR}/tools/ci/ci_targets_check.py --self-test) -# engine#1820: the other half of ci_targets_check -- a standalone shell test that nothing references cannot fail. -# `need` is every tests/*.sh, `have` is every file that mentions its basename somewhere that can run it, and -# tools/ci/unreferenced_tests.txt carries the deliberate exclusions WITH their reasons, so the list can shrink. -add_python_test(tests_referenced ${CMAKE_SOURCE_DIR}/tools/ci/tests_referenced_check.py --check --root ${CMAKE_SOURCE_DIR}) -add_python_test(tests_referenced_self ${CMAKE_SOURCE_DIR}/tools/ci/tests_referenced_check.py --self-test) -# engine#1901: five tools ship a --self-test that no runner named, so the arms existed, were maintained beside the logic they -# check, and never executed. All five run device-free and fast (58-277 ms measured), so they are rows rather than allow-list -# excuses, and tools/ci/tests_referenced_check.py now counts tools/**/*.py that declare one and are named by no RUNNER -# (CMakeLists/cmake/workflows -- a citation in another tool's source is not a runner: that is the 5-vs-2 difference). -# Registered through add_python_test (engine#1864), so they run THROUGH the interpreter: my first version used the raw -# `${Python3_EXECUTABLE}` form above the find_package and the repository's own ordering guard caught it by name -- -# tools/mtp_head_ref.py is the one of the five without an exec bit, and it became BAD_COMMAND under ctest. -add_python_test(tool_selftest_batched_repeat ${CMAKE_SOURCE_DIR}/tools/batched_repeat.py --selftest) -add_python_test(tool_selftest_logprob_agree ${CMAKE_SOURCE_DIR}/tools/logprob_agree.py --selftest) -add_python_test(tool_selftest_mtp_head_ref ${CMAKE_SOURCE_DIR}/tools/mtp_head_ref.py --selftest) -add_python_test(tool_selftest_spec_decode_acceptance ${CMAKE_SOURCE_DIR}/tools/spec_decode_acceptance.py --selftest) -add_python_test(tool_selftest_whisper_encoder_baseline ${CMAKE_SOURCE_DIR}/tools/whisper_encoder_baseline.py --self-test) +include(cmake/tests-python-tools.cmake) # engine#1777: the release row's own arm, which merged unregistered -- this sweep is what found it (engine#1820). add_test(NAME release_check_hrx_init_reason COMMAND bash ${CMAKE_SOURCE_DIR}/tests/release_check_hrx_init_reason_test.sh ${CMAKE_SOURCE_DIR}/os/mini/release-check.sh) # engine#1615: every process holding the GPU/NPU device must belong to a live gpu-hold/npu-hold ticket. Three diff --git a/cmake/tests-python-tools.cmake b/cmake/tests-python-tools.cmake new file mode 100644 index 000000000..aa973cc8d --- /dev/null +++ b/cmake/tests-python-tools.cmake @@ -0,0 +1,44 @@ +# Copyright 2026 bong-water-water-bong +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Python tool self-tests (engine#1979). Every row here drives a `tools/*.py` or `tests/*.py` self-test through +# `add_python_test()`, defined in CMakeLists.txt above this include. They live in their own file because they are the rows +# every lane appends one of, and they were the block that went stale first -- two lanes appending to different registration +# files cannot conflict. `cmake/tests-gpu-hold.cmake` is the same idea for a target-bearing family, and both CI guards +# already treat `cmake/tests-*.cmake` as registration files, so nothing in the checks needs to know this file exists. +# engine#1864: the ordering rule itself, checked on the file (no configure, no build): every ${Python3_EXECUTABLE} use has +# to follow the find_package above. The nine that did not ran through their exec bit, and a mode-only rewrite of one +# script turned the row into BAD_COMMAND. +add_python_test(python_test_order_check ${CMAKE_SOURCE_DIR}/tests/python_test_order_check.py --check --root ${CMAKE_SOURCE_DIR}) +add_python_test(python_test_order_check_self ${CMAKE_SOURCE_DIR}/tests/python_test_order_check.py --self-test) +add_python_test(ci_targets ${CMAKE_SOURCE_DIR}/tools/ci/ci_targets_check.py --check --root ${CMAKE_SOURCE_DIR}) +add_python_test(ci_targets_self ${CMAKE_SOURCE_DIR}/tools/ci/ci_targets_check.py --self-test) +# engine#1820: the other half of ci_targets_check -- a standalone shell test that nothing references cannot fail. +# `need` is every tests/*.sh, `have` is every file that mentions its basename somewhere that can run it, and +# tools/ci/unreferenced_tests.txt carries the deliberate exclusions WITH their reasons, so the list can shrink. +add_python_test(tests_referenced ${CMAKE_SOURCE_DIR}/tools/ci/tests_referenced_check.py --check --root ${CMAKE_SOURCE_DIR}) +add_python_test(tests_referenced_self ${CMAKE_SOURCE_DIR}/tools/ci/tests_referenced_check.py --self-test) +# engine#1901: five tools ship a --self-test that no runner named, so the arms existed, were maintained beside the logic they +# check, and never executed. All five run device-free and fast (58-277 ms measured), so they are rows rather than allow-list +# excuses, and tools/ci/tests_referenced_check.py now counts tools/**/*.py that declare one and are named by no RUNNER +# (CMakeLists/cmake/workflows -- a citation in another tool's source is not a runner: that is the 5-vs-2 difference). +# Registered through add_python_test (engine#1864), so they run THROUGH the interpreter: my first version used the raw +# `${Python3_EXECUTABLE}` form above the find_package and the repository's own ordering guard caught it by name -- +# tools/mtp_head_ref.py is the one of the five without an exec bit, and it became BAD_COMMAND under ctest. +add_python_test(tool_selftest_batched_repeat ${CMAKE_SOURCE_DIR}/tools/batched_repeat.py --selftest) +add_python_test(tool_selftest_logprob_agree ${CMAKE_SOURCE_DIR}/tools/logprob_agree.py --selftest) +add_python_test(tool_selftest_mtp_head_ref ${CMAKE_SOURCE_DIR}/tools/mtp_head_ref.py --selftest) +add_python_test(tool_selftest_spec_decode_acceptance ${CMAKE_SOURCE_DIR}/tools/spec_decode_acceptance.py --selftest) +add_python_test(tool_selftest_whisper_encoder_baseline ${CMAKE_SOURCE_DIR}/tools/whisper_encoder_baseline.py --self-test)