Skip to content

Fix: let the C++ unit test tree's root CMakeLists describe the tree it builds - #2421

Merged
ChaoZheng109 merged 1 commit into
hw-native-sys:mainfrom
poursoul:fix/ut-cpp-root-cmake-header
Sep 22, 2026
Merged

ChaoZheng109 merged 1 commit into
hw-native-sys:mainfrom
poursoul:fix/ut-cpp-root-cmake-header

Conversation

@poursoul

Copy link
Copy Markdown
Collaborator

What

tests/ut/cpp/CMakeLists.txt's opening three lines and its project() name described the tree as it stood years ago. Four lines, raised in review on #2418 after it merged.

Line Said Actually
10 "C++ unit tests for src/common/hierarchical" that tree holds 12 of the 155 cases here
11 cmake --build . --target run_ut_cpp no such target — and none in the 1979-line version either, so this has pointed at nothing since it was written
12 ctest --test-dir build/ut_cpp the directory is tests/ut/cpp/build
15 project(hierarchical_ut CXX) same stale scope

The defect predates #2418, but that PR rewrote this file from 1979 lines to 191 on the theme of letting the structure say what the CMake used to, so leaving its own opening lines saying something else is a doc-consistency.md §1 problem inside it.

The commands are not re-written here

The new opening points at docs/testing/adding-a-cpp-unit-test.md rather than carrying a corrected recipe. docs/testing.md:539, that page's §8, and docs/ci.md:426 already hold one each. These three lines were wrong because they were a fourth copy that nobody consults when the commands change — writing correct ones in would reset the drift for one cycle and restore the mechanism.

project() rename has no consumer

Verified three ways, not one:

  • git grep finds no PROJECT_NAME, CMAKE_PROJECT_NAME or hierarchical_ut_SOURCE_DIR reference in the tree — every path is spelled CMAKE_SOURCE_DIR / CMAKE_CURRENT_SOURCE_DIR.
  • CI configures by -S/-B path and runs by --test-dir (_ut-no-hardware.yml:106-108, _ut-npu-a2a3.yml:53), never by project name.
  • The tree calls enable_testing() without include(CTest), so no DartConfiguration.tcl is generated at all. The name's one landing place is CMAKE_PROJECT_NAME in the cache.

simpler_ut_cpp is unused repo-wide and matches both the simpler_ut_* helper prefix and the ut-cpp job name in docs/ci.md.

Test plan

Clean configure, since the globs are CONFIGURE_DEPENDS but an object library's source list is not re-read per build:

rm -rf tests/ut/cpp/build
cmake -B tests/ut/cpp/build -S tests/ut/cpp -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
cmake --build tests/ut/cpp/build --parallel 8
ctest --test-dir tests/ut/cpp/build -LE requires_hardware -j8 --output-on-failure
python tests/lint/check_ut_cpp_axis.py
python tests/lint/check_ut_cpp_stub_linkage.py
python tests/lint/check_ut_cpp_case_naming.py
Check Result
configure + build 229 targets, clean
ctest (no hardware) 229/229 passed, 5.95 s
axis / stub-linkage / case-naming exit 0 each
pre-commit run --files tests/ut/cpp/CMakeLists.txt all Passed
run_ut_cpp / build/ut_cpp / hierarchical_ut repo-wide 0 occurrences each

Hardware-labelled cases are unaffected — the diff touches no target, source, or property.

…t builds

tests/ut/cpp/CMakeLists.txt opened by naming src/common/hierarchical as its
subject, a target to build the tree with, and a directory to run ctest in. All
three were wrong. That tree holds 12 of the 155 cases here. `run_ut_cpp` names
no target and never did: the 1979-line version this file replaced carried the
same line and no add_custom_target either, so it has pointed at nothing since
it was written, and reading it as something the refactor dropped is the wrong
conclusion to leave available. The build directory is tests/ut/cpp/build, which
is what CI, docs/testing.md and docs/ci.md all use.

The opening now states what the tree is and what this file in particular holds,
and points at docs/testing/adding-a-cpp-unit-test.md for the commands rather
than carrying a fourth copy of them. Writing the correct commands here would
reset the drift once, and the reason these lines were wrong is that they are a
copy nobody consults when the commands change.

project() takes the tree's own name. Nothing consumes the old one: no
PROJECT_NAME or hierarchical_ut_SOURCE_DIR reference exists anywhere, CI
configures by -S/-B path and runs by --test-dir, and the tree calls
enable_testing() without include(CTest), so not even a DartConfiguration.tcl is
written. The name's one landing place is CMAKE_PROJECT_NAME in the cache.

229 targets built from a clean configure, 229 ctest passes, and
check_ut_cpp_axis.py, check_ut_cpp_stub_linkage.py and
check_ut_cpp_case_naming.py all clean.
@coderabbitai

coderabbitai Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: b0c8473b-891c-49b2-9eb0-220759d282b8

📥 Commits

Reviewing files that changed from the base of the PR and between 98c7c17 and 196e738.

📒 Files selected for processing (1)
  • tests/ut/cpp/CMakeLists.txt

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The C++ unit-test CMake project now covers multiple test directories. It also checks for orphan cases and writes the PYUT manifest after test registration.

Changes

C++ unit-test tree

Layer / File(s) Summary
Configure the expanded C++ unit-test tree
tests/ut/cpp/CMakeLists.txt
The project is renamed to simpler_ut_cpp. The configuration adds support, common, a2a3, and a5 subdirectories. It invokes orphan-case validation and PYUT manifest generation after registration.

Priority: ⬇️ Low

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Other

Merge Risk: ⚪ Minimal · up to 196e7

The change expands C++ unit-test coverage and validation metadata generation, with reported successful build and test results. No merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: updating the C++ unit-test tree's root CMakeLists description to match the tree it builds.
Description check ✅ Passed The description directly explains the stale references, the updated project name and documentation link, and the reported validation results.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

A rabbit checks each test-tree lane
Support and common join the train
A2A3 and A5 appear
Orphan cases disappear
The PYUT map is written clear

Comment @coderabbitai help to get the list of available commands.

@ChaoZheng109
ChaoZheng109 merged commit 329a920 into hw-native-sys:main Sep 22, 2026
17 checks passed
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.

2 participants