From 95ce2d4e1bb18f6ba802ccc5f094243202c81ae9 Mon Sep 17 00:00:00 2001 From: ml-physec <206103694+ml-physec@users.noreply.github.com> Date: Mon, 20 Jul 2026 15:33:22 +0200 Subject: [PATCH] Clear detail stack in every situation --- auto/generate_test_runner.rb | 4 ++++ src/unity.c | 6 +++++- src/unity_internals.h | 4 ++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index b1f6aea5..bd4ec5e8 100755 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -431,7 +431,11 @@ def create_run_test(output) output.puts(' return;') output.puts('#endif') output.puts(' Unity.NumberOfTests++;') + output.puts('#ifdef UNITY_DETAIL_STACK_SIZE') + output.puts(' Unity.CurrentDetailStackSize = 0;') + output.puts('#else') output.puts(' UNITY_CLR_DETAILS();') + output.puts('#endif') output.puts(' UNITY_EXEC_TIME_START();') output.puts(' CMock_Init();') output.puts(' if (TEST_PROTECT())') diff --git a/src/unity.c b/src/unity.c index 49280b3c..686252f3 100644 --- a/src/unity.c +++ b/src/unity.c @@ -2535,8 +2535,12 @@ void UnityBegin(const char* filename) Unity.TestIgnores = 0; Unity.CurrentTestFailed = 0; Unity.CurrentTestIgnored = 0; - +#ifdef UNITY_DETAIL_STACK_SIZE + Unity.CurrentDetailStackSize = 0; +#else UNITY_CLR_DETAILS(); +#endif + UNITY_OUTPUT_START(); } diff --git a/src/unity_internals.h b/src/unity_internals.h index 9dac4f06..01422457 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -1332,8 +1332,8 @@ int UnityTestMatches(void); #define UNITY_DETAIL_PUSH(label, value) UnityPushDetail((UNITY_DETAIL_LABEL_TYPE)(label), (UNITY_DETAIL_VALUE_TYPE)(value), __LINE__) #define UNITY_DETAIL_POP(label, value) UnityPopDetail((UNITY_DETAIL_LABEL_TYPE)(label), (UNITY_DETAIL_VALUE_TYPE)(value), __LINE__) #else -#define UNITY_DETAIL_PUSH(label, value) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDetailStack) -#define UNITY_DETAIL_POP(label, value) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDetailStack) +#define UNITY_DETAIL_PUSH(label, value) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(__LINE__), UnityStrErrDetailStack) +#define UNITY_DETAIL_POP(label, value) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(__LINE__), UnityStrErrDetailStack) #endif /* End of UNITY_INTERNALS_H */