From 9ca2b0e716a4289eb333c2f764c521da0f09bbd3 Mon Sep 17 00:00:00 2001 From: Mike Solar Date: Fri, 17 Jul 2026 17:38:15 +0800 Subject: [PATCH] tests: skip MainWindow construction test where OpenGL is unavailable The test forces GraphicsBackend=opengl and builds a full MainWindow with QOpenGLWidget-based viewer panels. On headless platforms whose QPA cannot provide a GL context (Ubuntu/Windows CI on offscreen), the app's GL calls crash on a non-current context (SEGFAULT in CI on both). Probe with QOpenGLContext+QOffscreenSurface and GTEST_SKIP when GL is unusable; the test still runs on platforms with real GL. --- tests/gtest/mainwindow_test.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/gtest/mainwindow_test.cpp b/tests/gtest/mainwindow_test.cpp index 2ff648530..e6609b4ea 100644 --- a/tests/gtest/mainwindow_test.cpp +++ b/tests/gtest/mainwindow_test.cpp @@ -1,6 +1,8 @@ #include #include +#include +#include #include #include #include @@ -248,6 +250,21 @@ TEST(MainWindowStatusBar, DoubleClickEmitsSignal) // MainWindow directly. TEST(MainWindow, ConstructsOffscreenWithPanelsAndMenus) { + // MainWindow instantiates viewer panels containing QOpenGLWidget. On + // platforms without a usable OpenGL implementation (e.g. headless CI + // runners on the offscreen QPA), constructing it crashes in GL code + // ("QOpenGLFunctions created with non-current context"). Probe first and + // skip where GL is unavailable. + QOffscreenSurface probe_surface; + probe_surface.create(); + QOpenGLContext probe_context; + const bool gl_available = + probe_context.create() && probe_context.makeCurrent(&probe_surface); + probe_context.doneCurrent(); + if (!gl_available) { + GTEST_SKIP() << "OpenGL is not usable on this platform"; + } + // Must precede RenderManager creation: PreviewAutoCacher constructs a // Project whose ColorManager dereferences the default OCIO config ColorManager::SetUpDefaultConfig();