Skip to content

Rename TEST_SUITE_INITIALIZE/CLEANUP to _INTERNAL and guard behind DEFINE_ macros#287

Open
parth21999 wants to merge 1 commit intomasterfrom
paaggarwal/rename-suite-init-cleanup-to-internal
Open

Rename TEST_SUITE_INITIALIZE/CLEANUP to _INTERNAL and guard behind DEFINE_ macros#287
parth21999 wants to merge 1 commit intomasterfrom
paaggarwal/rename-suite-init-cleanup-to-internal

Conversation

@parth21999
Copy link
Member

Summary

TEST_SUITE_INITIALIZE and TEST_SUITE_CLEANUP are renamed to TEST_SUITE_INITIALIZE_INTERNAL and TEST_SUITE_CLEANUP_INTERNAL, and guarded behind DEFINE_TEST_SUITE_INITIALIZE / DEFINE_TEST_SUITE_CLEANUP preprocessor guards.

Why

We are introducing wrapper macros (in c-pal) that inject additional fixtures into suite init/cleanup - for example, a process watchdog that terminates test suites that hang. These wrapper macros need to call testrunnerswitcher's suite init/cleanup, but we want to prevent test code from bypassing the wrapper and calling the raw macros directly.

By renaming to _INTERNAL and gating behind DEFINE_ guards:

  1. Test code cannot use the raw macros - they are not defined unless the guards are explicitly set, so direct use produces a compile error.
  2. Wrapper macros define the guards before including testrunnerswitcher.h, enabling them to use _INTERNAL while keeping the abstraction intact.
  3. No leakage of testrunnerswitcher internals - the wrapper macro only references TEST_SUITE_INITIALIZE_INTERNAL / TEST_SUITE_CLEANUP_INTERNAL, without needing to know about CPP_UNITTEST, CTEST_SUITE_INITIALIZE, or cppunittest_mutex_fixtures_*.
  4. The _INTERNAL name discourages direct use even if someone discovers the guard mechanism.

Impact

  • Both CPP_UNITTEST and ctest paths are updated identically.
  • TEST_FUNCTION_INITIALIZE / TEST_FUNCTION_CLEANUP are unchanged.
  • Dependent repos that currently use TEST_SUITE_INITIALIZE directly will need to migrate to the new wrapper macros.

…FINE_ macros

TEST_SUITE_INITIALIZE and TEST_SUITE_CLEANUP are renamed to
TEST_SUITE_INITIALIZE_INTERNAL and TEST_SUITE_CLEANUP_INTERNAL.
They are now guarded behind DEFINE_TEST_SUITE_INITIALIZE and
DEFINE_TEST_SUITE_CLEANUP preprocessor guards respectively.

This prevents test code from using these macros directly, enforcing
that all test suites go through an appropriate wrapper macro that
defines the guards before including this header. The wrapper macro
can inject additional fixtures (e.g. watchdog timers) while keeping
testrunnerswitcher's CPP_UNITTEST/ctest abstraction intact.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@parth21999
Copy link
Member Author

/AzurePipelines run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Member

@dcristoloveanu dcristoloveanu left a comment

Choose a reason for hiding this comment

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

:shipit:

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