mirror of
https://github.com/ThrowTheSwitch/Unity.git
synced 2026-01-23 00:15:58 +01:00
Allow user-defined TEST_PROTECT & TEST_ABORT macros
However rare, this update covers real-world use cases where: - Unity is used to provide the assertion macros only, and an external test harness/runner is used for test orchestration/reporting. - Calling longjmp on a given platform is possible, but has a platform-specific (or implementation-specific) set of prerequisites, e.g. privileged access level. Enable project-specific customisation of TEST_PROTECT and TEST_ABORT macros. - Use the user-defined UNITY_TEST_ABORT if available; fall back to default behaviour otherwise. - Use the user-defined UNITY_TEST_PROTECT if available; fall back to default behaviour otherwise. - These may be defined independently.
This commit is contained in:
@@ -759,13 +759,25 @@ extern const char UnityStrErrShorthand[];
|
||||
* Test Running Macros
|
||||
*-------------------------------------------------------*/
|
||||
|
||||
#ifdef UNITY_TEST_PROTECT
|
||||
#define TEST_PROTECT() UNITY_TEST_PROTECT()
|
||||
#else
|
||||
#ifndef UNITY_EXCLUDE_SETJMP_H
|
||||
#define TEST_PROTECT() (setjmp(Unity.AbortFrame) == 0)
|
||||
#define TEST_ABORT() longjmp(Unity.AbortFrame, 1)
|
||||
#else
|
||||
#define TEST_PROTECT() 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef UNITY_TEST_ABORT
|
||||
#define TEST_ABORT() UNITY_TEST_ABORT()
|
||||
#else
|
||||
#ifndef UNITY_EXCLUDE_SETJMP_H
|
||||
#define TEST_ABORT() longjmp(Unity.AbortFrame, 1)
|
||||
#else
|
||||
#define TEST_ABORT() return
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Automatically enable variadic macros support, if it not enabled before */
|
||||
#ifndef UNITY_SUPPORT_VARIADIC_MACROS
|
||||
|
||||
Reference in New Issue
Block a user