Skip to content

Conversation

koudis
Copy link
Member

@koudis koudis commented Aug 2, 2025

Summary by CodeRabbit

  • Refactor
    • Replaced local test and cache variable management logic with external implementations from a shared package.
    • Simplified test and cache management files to only verify and include external resources.
  • Chores
    • Introduced dependency on an external package for test and cache variable management.
  • Chores
    • Updated workflow environment variables to use version 1.2.0 of the external package across all platforms.

Copy link

coderabbitai bot commented Aug 2, 2025

Walkthrough

The changes replace all local macro and function definitions for testing and cache variable management in test/TEST.cmake and test/cache_var.cmake with logic that locates and includes external shared implementations from the CMLIB package. All previous in-file implementations are removed, and the files now act as wrappers to include the corresponding functionality from CMLIB after verifying its presence. Additionally, the GitHub workflow files .github/workflows/examples.yml and .github/workflows/tests.yml update the CMLIB_VERSION environment variable from 1.1.0 to 1.2.0.

Changes

Cohort / File(s) Change Summary
Test Macro and Function Delegation
test/TEST.cmake
Removed all local test macros and functions; now finds and verifies CMLIB, checks CMLIB_DIR, and includes external TEST.cmake from CMLIB_DIR.
Cache Variable Management Delegation
test/cache_var.cmake
Removed all local cache variable management functions; now requires CMLIB, checks CMLIB_DIR, and includes external cache_var.cmake from CMLIB_DIR.
CI Workflow Version Update
.github/workflows/examples.yml, .github/workflows/tests.yml
Updated CMLIB_VERSION environment variable from 1.1.0 to 1.2.0 to use the newer version of the cmakelib repository in CI jobs.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Suggested reviewers

  • Melky-Phoe

Poem

In burrows deep, I once would write
Test macros hopping left and right.
But now I pause, include instead,
From CMLIB’s warren, code is fed.
Simpler paths, less code to keep—
A rabbit’s dream: review is cheap!
🐇✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4fe232f and f45b905.

📒 Files selected for processing (2)
  • .github/workflows/examples.yml (1 hunks)
  • .github/workflows/tests.yml (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • .github/workflows/examples.yml
  • .github/workflows/tests.yml
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: test_windows
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch tests_framework_validation

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
test/TEST.cmake (1)

2-3: Fix typo and clarify dependency statement.

There's a spelling error: "unnecesssary" should be "unnecessary". Also, the comment about "avoiding dependencies" seems contradictory since this change actually introduces a dependency on CMLIB.

-# TEST.cmake are shared with CMLIB to avoid unnecesssary dependencies.
-# TESTS.cmake is properly validated.
+# TEST.cmake is shared with CMLIB to avoid duplicate dependencies.
+# TEST.cmake is properly validated.
test/cache_var.cmake (1)

2-3: Fix typo and clarify dependency statement.

Same issues as in TEST.cmake: "unnecesssary" should be "unnecessary", and the dependency statement could be clearer.

-# cache_var.cmake are shared with CMLIB to avoid unnecesssary dependencies.
+# cache_var.cmake is shared with CMLIB to avoid duplicate dependencies.
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f6e2fc6 and 4fe232f.

📒 Files selected for processing (2)
  • test/TEST.cmake (1 hunks)
  • test/cache_var.cmake (1 hunks)
🧰 Additional context used
🧠 Learnings (13)
📓 Common learnings
Learnt from: koudis
PR: cmakelib/cmakelib-component-cmdef#11
File: test/CMakeLists.txt:9-11
Timestamp: 2025-06-17T22:15:13.853Z
Learning: The cmakelib-component-cmdef project uses a custom testing framework with TEST.cmake and custom macros like TEST_RUN, TEST_RUN_AND_CHECK_OUTPUT rather than CTest. CTest integration is not needed or used in this project.
Learnt from: koudis
PR: cmakelib/cmakelib-component-cmdef#11
File: test/CMDEF_ADD_EXECUTABLE/test_cases/missing_target_error/CMakeLists.txt:14-17
Timestamp: 2025-06-08T19:13:14.984Z
Learning: For CMake test cases that verify error conditions (like missing required parameters), use TEST_RUN_AND_CHECK_OUTPUT or similar test harness macros instead of directly calling the function being tested. Direct calls will abort CMake without proper test assertion, while test harnesses can capture and validate expected error messages.
Learnt from: koudis
PR: cmakelib/cmakelib-component-cmdef#11
File: test/CMDEF_ADD_EXECUTABLE/test_cases/missing_target_error/CMakeLists.txt:11-12
Timestamp: 2025-06-16T19:45:39.391Z
Learning: In CMDEF test suites, individual error test cases (like missing_target_error) should NOT include TEST.cmake. They are designed to be executed by main test orchestrators that use TEST_RUN_AND_CHECK_OUTPUT to capture and validate the expected fatal errors. Individual test cases should simply trigger the error condition.
Learnt from: koudis
PR: cmakelib/cmakelib-component-cmdef#11
File: test/CMDEF_ADD_LIBRARY/test_cases/cache_variables_validation/CMakeLists.txt:120-122
Timestamp: 2025-06-16T20:53:24.161Z
Learning: The CACHE_VAR_FORCE_SET macro in cache_var.cmake is designed to handle multiple calls safely - it only saves the original cache variable state on the first call and preserves that saved state through subsequent calls, allowing proper restoration to the pre-test value.
Learnt from: koudis
PR: cmakelib/cmakelib-component-cmdef#11
File: test/CMDEF_INSTALL/test_cases/install_related/include_dirs/CMakeLists.txt:0-0
Timestamp: 2025-06-16T19:47:01.662Z
Learning: In the CMDEF_INSTALL system, export destination paths intentionally contain double slashes like `${CMDEF_LIBRARY_INSTALL_DIR}/cmake//` - this is the actual format produced by the implementation, not a formatting error in tests.
Learnt from: koudis
PR: cmakelib/cmakelib-component-cmdef#11
File: test/CMDEF_ENV/cache_variables_validation/CMakeLists.txt:215-218
Timestamp: 2025-06-17T21:44:57.056Z
Learning: In CMDEF_ENV cache variable validation tests, hardcoded platform-specific values (like Windows architecture "x86-64" and version "1") are intentional and used to validate expected cache variable values in the test environment, rather than testing dynamic detection capabilities which are covered by other test cases.
Learnt from: koudis
PR: cmakelib/cmakelib-component-cmdef#11
File: test/install_override.cmake:29-52
Timestamp: 2025-06-16T19:50:42.083Z
Learning: When overriding built-in CMake commands (like INSTALL) for testing purposes, MACRO() must be used instead of function() to properly shadow the original command. This is a specific case where the macro form is technically required despite general preferences for functions to avoid variable leakage.
Learnt from: koudis
PR: cmakelib/cmakelib-component-cmdef#11
File: test/TEST.cmake:248-253
Timestamp: 2025-07-15T21:03:21.495Z
Learning: In CMake's GET_PROPERTY and MATCHES operations, explicit NOTFOUND checking is not needed for functions like TEST_CHECK_TARGET_PROPERTY_CONTAINS because CMake handles missing properties automatically during pattern matching operations.
Learnt from: koudis
PR: cmakelib/cmakelib-component-cmdef#11
File: test/CMDEF_INSTALL/test_cases/interface_lib/CMakeLists.txt:93-95
Timestamp: 2025-06-16T19:51:02.357Z
Learning: In modern CMake, the IF command automatically dereferences variables in conditions. For example, `IF(variable_name MATCHES pattern)` works correctly without needing explicit variable expansion syntax like `IF("${variable_name}" MATCHES pattern)`. The explicit syntax is not required for basic variable dereferencing in IF conditions.
📚 Learning: the cache_var_force_set macro in cache_var.cmake is designed to handle multiple calls safely - it on...
Learnt from: koudis
PR: cmakelib/cmakelib-component-cmdef#11
File: test/CMDEF_ADD_LIBRARY/test_cases/cache_variables_validation/CMakeLists.txt:120-122
Timestamp: 2025-06-16T20:53:24.161Z
Learning: The CACHE_VAR_FORCE_SET macro in cache_var.cmake is designed to handle multiple calls safely - it only saves the original cache variable state on the first call and preserves that saved state through subsequent calls, allowing proper restoration to the pre-test value.

Applied to files:

  • test/cache_var.cmake
  • test/TEST.cmake
📚 Learning: when overriding built-in cmake commands (like install) for testing purposes, macro() must be used in...
Learnt from: koudis
PR: cmakelib/cmakelib-component-cmdef#11
File: test/install_override.cmake:29-52
Timestamp: 2025-06-16T19:50:42.083Z
Learning: When overriding built-in CMake commands (like INSTALL) for testing purposes, MACRO() must be used instead of function() to properly shadow the original command. This is a specific case where the macro form is technically required despite general preferences for functions to avoid variable leakage.

Applied to files:

  • test/cache_var.cmake
  • test/TEST.cmake
📚 Learning: the cmakelib-component-cmdef project uses a custom testing framework with test.cmake and custom macr...
Learnt from: koudis
PR: cmakelib/cmakelib-component-cmdef#11
File: test/CMakeLists.txt:9-11
Timestamp: 2025-06-17T22:15:13.853Z
Learning: The cmakelib-component-cmdef project uses a custom testing framework with TEST.cmake and custom macros like TEST_RUN, TEST_RUN_AND_CHECK_OUTPUT rather than CTest. CTest integration is not needed or used in this project.

Applied to files:

  • test/cache_var.cmake
  • test/TEST.cmake
📚 Learning: in cmdef_env cache variable validation tests, hardcoded platform-specific values (like windows archi...
Learnt from: koudis
PR: cmakelib/cmakelib-component-cmdef#11
File: test/CMDEF_ENV/cache_variables_validation/CMakeLists.txt:215-218
Timestamp: 2025-06-17T21:44:57.056Z
Learning: In CMDEF_ENV cache variable validation tests, hardcoded platform-specific values (like Windows architecture "x86-64" and version "1") are intentional and used to validate expected cache variable values in the test environment, rather than testing dynamic detection capabilities which are covered by other test cases.

Applied to files:

  • test/cache_var.cmake
  • test/TEST.cmake
📚 Learning: in cmake's get_property and matches operations, explicit notfound checking is not needed for functio...
Learnt from: koudis
PR: cmakelib/cmakelib-component-cmdef#11
File: test/TEST.cmake:248-253
Timestamp: 2025-07-15T21:03:21.495Z
Learning: In CMake's GET_PROPERTY and MATCHES operations, explicit NOTFOUND checking is not needed for functions like TEST_CHECK_TARGET_PROPERTY_CONTAINS because CMake handles missing properties automatically during pattern matching operations.

Applied to files:

  • test/cache_var.cmake
  • test/TEST.cmake
📚 Learning: for cmake test cases that verify error conditions (like missing required parameters), use test_run_a...
Learnt from: koudis
PR: cmakelib/cmakelib-component-cmdef#11
File: test/CMDEF_ADD_EXECUTABLE/test_cases/missing_target_error/CMakeLists.txt:14-17
Timestamp: 2025-06-08T19:13:14.984Z
Learning: For CMake test cases that verify error conditions (like missing required parameters), use TEST_RUN_AND_CHECK_OUTPUT or similar test harness macros instead of directly calling the function being tested. Direct calls will abort CMake without proper test assertion, while test harnesses can capture and validate expected error messages.

Applied to files:

  • test/cache_var.cmake
  • test/TEST.cmake
📚 Learning: in the cmdef_install system, export destination paths intentionally contain double slashes like `${c...
Learnt from: koudis
PR: cmakelib/cmakelib-component-cmdef#11
File: test/CMDEF_INSTALL/test_cases/install_related/include_dirs/CMakeLists.txt:0-0
Timestamp: 2025-06-16T19:47:01.662Z
Learning: In the CMDEF_INSTALL system, export destination paths intentionally contain double slashes like `${CMDEF_LIBRARY_INSTALL_DIR}/cmake//` - this is the actual format produced by the implementation, not a formatting error in tests.

Applied to files:

  • test/cache_var.cmake
  • test/TEST.cmake
📚 Learning: in cmdef test suites, individual error test cases (like missing_target_error) should not include tes...
Learnt from: koudis
PR: cmakelib/cmakelib-component-cmdef#11
File: test/CMDEF_ADD_EXECUTABLE/test_cases/missing_target_error/CMakeLists.txt:11-12
Timestamp: 2025-06-16T19:45:39.391Z
Learning: In CMDEF test suites, individual error test cases (like missing_target_error) should NOT include TEST.cmake. They are designed to be executed by main test orchestrators that use TEST_RUN_AND_CHECK_OUTPUT to capture and validate the expected fatal errors. Individual test cases should simply trigger the error condition.

Applied to files:

  • test/cache_var.cmake
  • test/TEST.cmake
📚 Learning: in modern cmake, the if command automatically dereferences variables in conditions. for example, `if...
Learnt from: koudis
PR: cmakelib/cmakelib-component-cmdef#11
File: test/CMDEF_INSTALL/test_cases/interface_lib/CMakeLists.txt:93-95
Timestamp: 2025-06-16T19:51:02.357Z
Learning: In modern CMake, the IF command automatically dereferences variables in conditions. For example, `IF(variable_name MATCHES pattern)` works correctly without needing explicit variable expansion syntax like `IF("${variable_name}" MATCHES pattern)`. The explicit syntax is not required for basic variable dereferencing in IF conditions.

Applied to files:

  • test/cache_var.cmake
  • test/TEST.cmake
📚 Learning: cmake does not have an `unset_property` command. the only way to clear a property in cmake is using ...
Learnt from: koudis
PR: cmakelib/cmakelib-component-cmdef#11
File: test/cache_var.cmake:77-79
Timestamp: 2025-06-16T20:53:31.710Z
Learning: CMake does not have an `UNSET_PROPERTY` command. The only way to clear a property in CMake is using `SET_PROPERTY(GLOBAL PROPERTY <prop>)` without a value, which sets the property to an empty value rather than removing it completely.

Applied to files:

  • test/cache_var.cmake
📚 Learning: cmake does not have an `unset_property` command. the only way to clear a property in cmake is using ...
Learnt from: koudis
PR: cmakelib/cmakelib-component-cmdef#11
File: test/cache_var.cmake:77-79
Timestamp: 2025-06-16T20:53:31.710Z
Learning: CMake does not have an `UNSET_PROPERTY` command. The only way to clear a property in CMake is using `SET_PROPERTY(GLOBAL PROPERTY <prop>)` without a value. There is an `UNSET()` command but it only works for variables, not properties.

Applied to files:

  • test/cache_var.cmake
📚 Learning: the cmdef_package system creates a custom target named "package" (uppercase) in multiconfig builds, ...
Learnt from: koudis
PR: cmakelib/cmakelib-component-cmdef#11
File: test/CMDEF_PACKAGE/package_test_macros.cmake:92-96
Timestamp: 2025-06-16T20:53:43.698Z
Learning: The CMDEF_PACKAGE system creates a custom target named "PACKAGE" (uppercase) in multiconfig builds, which should not exist in single-config builds. This is different from CMake's built-in CPack "package" target (lowercase).

Applied to files:

  • test/TEST.cmake
🔇 Additional comments (5)
test/TEST.cmake (2)

8-10: Good defensive programming with directory validation.

The directory existence check provides clear error messaging and prevents cryptic include failures. If FIND_PACKAGE(CMLIB REQUIRED) is adopted, this check may become redundant but doesn't hurt to keep for extra safety.


12-12: Ensure external TEST.cmake implements all required test macros

I’ve confirmed that the codebase still uses the full suite of test macros across many test cases, for example:
• TEST_RUN
• TEST_RUN_AND_CHECK_OUTPUT
• TEST_CHECK_TARGET_PROPERTY
• TEST_CHECK_TARGET_INCLUDE_DIRECTORIES_CONTAINS
• TEST_CHECK_TARGET_LACKS_PROPERTY
• TEST_CHECK_TARGET_PROPERTY_CONTAINS
…among others.

Please verify that the external ${CMLIB_DIR}/test/TEST.cmake you’re including at line 12 provides definitions for all these macros; missing any will break the existing test suite.

test/cache_var.cmake (3)

6-6: Good use of REQUIRED flag for explicit dependency management.

This correctly uses FIND_PACKAGE(CMLIB REQUIRED) which provides better error messages and makes the dependency explicit, unlike the optional approach in TEST.cmake.


8-10: Defensive programming with directory validation.

The directory existence check is good defensive programming. Since FIND_PACKAGE(CMLIB REQUIRED) is used, this check may be redundant but provides extra safety and clear error messaging.


12-12: Ensure External Cache Variable Macros Maintain Safety Guarantees

The INCLUDE("${CMLIB_DIR}/test/cache_var.cmake") at line 12 correctly replaces the local cache‐variable routines with those bundled in CMLIB. We’ve confirmed that across the test suite the three macros—CACHE_VAR_FORCE_SET, CACHE_VAR_FORCE_UNSET, and CACHE_VAR_RESTORE—are invoked repeatedly without error, which demonstrates they are available and in use.

Please manually verify in the CMLIB source that:

  • Each macro is defined (via macro(), not function()) to ensure the internal “first‐call only” capture of the original cache state.
  • Repeated invocations do not overwrite or leak the saved state.
  • Restoration reliably returns to the pre-test value.

Once you’ve confirmed these definitions and safety guarantees in the CMLIB version, this inclusion can be approved without further changes.

@koudis koudis merged commit a396638 into master Aug 2, 2025
20 checks passed
@koudis koudis deleted the tests_framework_validation branch August 9, 2025 18:46
@coderabbitai coderabbitai bot mentioned this pull request Aug 22, 2025
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.

1 participant