CMakeLists lists the 136 test-target fragments by hand: a new target needs a top-file edit (replace the includes with one glob)

Open
#2,892 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
55/100
Issue type
Refactor
Clarity
Clearly specified
Activity status
Active
Tech stack
cmake, cpp

Research direction

Read src/runtime/CMakeLists.txt around the BUILD_TESTING block and tools/tests/test_runtime_lifecycle_invariants.py first. Move the loop and conditional wrappers into their test fragments, and relocate the top-level statements that name fragment targets before adding the sorted glob and include loop. Configure with just test-auth-unit <name> before and after; done means the target list and compile commands match, and the invariant test rejects a hand-listed include.

Written by the indexing model from the issue text.

Description

Evidence at 488513ca3

src/runtime/CMakeLists.txt lists each of the 136 test-target fragments in src/runtime/tests/targets/ by hand, one include(tests/targets/<name>.cmake) line each (grep -c '^include(tests/targets/' src/runtime/CMakeLists.txt prints 136; the lines run from 454 to 1004, inside the if(BUILD_TESTING) block that runs from 450 to 1011). A new test target therefore needs an edit to the top file as well as its own fragment. Four of the 136 are not plain includes:

  • two sit inside foreach(_logging_suffix a b) and foreach(_exports_fixture nevr deprecated) and take the loop variable through the fragment's name (test_plugin_logging_.cmake, test_plugin_.cmake);
  • one sits inside if(NEVR_UPDATE_CORE_ENABLED) (test_update_core_link.cmake, line 959);
  • two sit inside a nested if in the block.

Top-level statements in the same block also name fragment targets: add_dependencies(test_behavioral test_plugin_future_api ...) (about line 994) runs between fragment includes.

Not shown

  • Whether every fragment runs unchanged when all of them are included from one place. The loop and conditional includes need their wrapper moved into the fragment; the top-level statements that name fragment targets need to move into a fragment too. Neither is measured yet.
  • The compile commands and the target list after the change. The change must keep both, which is measured by configuring before and after.

Falsifier

After the fix, adding a file tests/targets/.cmake changes no CMakeLists.txt: the target appears in the configured build (ninja -t targets all), and the top file's text does not change. At 488513ca3 the same addition needs an include line in the top file.

Work

  1. Test first, in tools/tests/test_runtime_lifecycle_invariants.py: the top file contains no include(tests/targets/<name>.cmake) line and contains one glob over tests/targets/*.cmake. Red at 488513ca3 (136 hand-listed lines).
  2. The top file gets file(GLOB ... CONFIGURE_DEPENDS ...) over src/runtime/tests/targets/*.cmake, sorted, then a foreach that includes each file, at one position after the last top-level statement that names a fragment target.
  3. Each loop and conditional include moves its wrapper into its fragment (the foreach or the if goes into the .cmake file).
  4. The top-level statements that name fragment targets move into a fragment.
  5. Verification: configure before and after (the target list has 945 entries before and after, and the compile commands are identical). The configure is just test-auth-unit <name> with BUILD_TESTING on, which configures the tree.
  6. Mutant: a hand-listed include line added back fails the rule test.
Dominant language
C++
Stars
3
Forks
5
Avg merge
4h 37m
Merged PRs (30d)
524

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from EchoTools/nevr-runtime

All issues in EchoTools/nevr-runtime

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.