Skip to content

Commit e9851ac

Browse files
committed
TestEngine, TestSuite: crash handler installed by ImGuiTestEngine_InstallDefaultCrashHandler() always print a crash string and extra info.
1 parent 633e258 commit e9851ac

File tree

2 files changed

+19
-14
lines changed

2 files changed

+19
-14
lines changed

Diff for: docs/CHANGELOG.txt

+4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ CHANGELOG
55
Those changes are not all listed here.
66
** For a while this is going to ONLY INCLUDE BREAKING CHANGES.
77

8+
2025/03/17:
9+
- TestEngine: helper crash handler installed by ImGuiTestEngine_InstallDefaultCrashHandler()
10+
always print a crash string and extra info, even if result export settings are set to None.
11+
812
2025/03/11:
913
- TestEngine: fixes various small issues compiling on game consoles.
1014

Diff for: imgui_test_engine/imgui_te_engine.cpp

+15-14
Original file line numberDiff line numberDiff line change
@@ -1465,9 +1465,8 @@ void ImGuiTestEngine_GetResult(ImGuiTestEngine* engine, int& count_tested, int&
14651465
for (int n = 0; n < engine->TestsAll.Size; n++)
14661466
{
14671467
ImGuiTest* test = engine->TestsAll[n];
1468-
if (test->Output.Status == ImGuiTestStatus_Unknown)
1468+
if (test->Output.Status == ImGuiTestStatus_Unknown || test->Output.Status == ImGuiTestStatus_Queued)
14691469
continue;
1470-
IM_ASSERT(test->Output.Status != ImGuiTestStatus_Queued);
14711470
IM_ASSERT(test->Output.Status != ImGuiTestStatus_Running);
14721471
count_tested++;
14731472
if (test->Output.Status == ImGuiTestStatus_Success)
@@ -2004,30 +2003,32 @@ void ImGuiTestEngine_ErrorRecoveryRun(ImGuiTestEngine* engine)
20042003

20052004
void ImGuiTestEngine_CrashHandler()
20062005
{
2006+
ImGuiContext& g = *GImGui;
2007+
ImGuiTestEngine* engine = (ImGuiTestEngine*)g.TestEngine;
2008+
ImGuiTest* crashed_test = (engine->TestContext && engine->TestContext->Test) ? engine->TestContext->Test : nullptr;
2009+
2010+
ImOsConsoleSetTextColor(ImOsConsoleStream_StandardError, ImOsConsoleTextColor_BrightRed);
2011+
if (crashed_test != nullptr)
2012+
fprintf(stderr, "**ImGuiTestEngine_CrashHandler()** Crashed while running \"%s\" :(\n", crashed_test->Name);
2013+
else
2014+
fprintf(stderr, "**ImGuiTestEngine_CrashHandler()** Crashed :(\n");
2015+
20072016
static bool handled = false;
20082017
if (handled)
20092018
return;
20102019
handled = true;
20112020

2012-
ImGuiContext& g = *GImGui;
2013-
ImGuiTestEngine* engine = (ImGuiTestEngine*)g.TestEngine;
2014-
20152021
// Write stop times, because thread executing tests will no longer run.
20162022
engine->BatchEndTime = ImTimeGetInMicroseconds();
2017-
for (int i = 0; i < engine->TestsAll.Size; i++)
2023+
if (crashed_test && crashed_test->Output.Status == ImGuiTestStatus_Running)
20182024
{
2019-
if (engine->TestContext)
2020-
if (ImGuiTest* test = engine->TestContext->Test)
2021-
if (test->Output.Status == ImGuiTestStatus_Running)
2022-
{
2023-
test->Output.Status = ImGuiTestStatus_Error;
2024-
test->Output.EndTime = engine->BatchEndTime;
2025-
break;
2026-
}
2025+
crashed_test->Output.Status = ImGuiTestStatus_Error;
2026+
crashed_test->Output.EndTime = engine->BatchEndTime;
20272027
}
20282028

20292029
// Export test run results.
20302030
ImGuiTestEngine_Export(engine);
2031+
ImGuiTestEngine_PrintResultSummary(engine);
20312032
}
20322033

20332034
#ifdef _WIN32

0 commit comments

Comments
 (0)