diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 37a58f48bb..ed614bcdc5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -77,7 +77,8 @@ jobs: doxygen \ python3-docutils \ python3-lxml \ - rst2pdf + rst2pdf \ + xvfb - name: Configure run: | @@ -94,12 +95,12 @@ jobs: - name: Run Tests run: | cd _build - make -j ${{ env.JOBS }} check + xvfb-run -a -e /tmp/xvfb-error-make-tests make -j ${{ env.JOBS }} check - name: Run distcheck run: | cd _build - make -j ${{ env.JOBS }} distcheck DISTCHECK_CONFIGURE_FLAGS="$CONFIGURE_FLAGS"; + xvfb-run -a -e /tmp/xvfb-error-make-distcheck make -j ${{ env.JOBS }} distcheck DISTCHECK_CONFIGURE_FLAGS="$CONFIGURE_FLAGS"; - name: ccache statistics run: ccache --show-stats @@ -150,7 +151,8 @@ jobs: python3-docutils \ python3-lxml \ rst2pdf \ - meson + meson \ + xvfb - name: Configuration run: | @@ -162,7 +164,7 @@ jobs: - name: Run Tests run: | - ninja -C _build test + xvfb-run -a -e /tmp/xvfb-error-meson-tests ninja -C _build test # distcheck not applicable, meson exports the source tree per git-archive diff --git a/tests/test_sidebar.c b/tests/test_sidebar.c index 9659dc72e7..c03d1aa649 100644 --- a/tests/test_sidebar.c +++ b/tests/test_sidebar.c @@ -137,12 +137,21 @@ void test_sidebar_openfiles_tree(void) int main(int argc, char **argv) { - g_test_init(&argc, &argv, NULL); - /* Not sure if we can really continue without DISPLAY. Fake X display perhaps? + /* In headless environments that do not provide a virtual display, + * GTK initialisation is expected to fail and gtk_init_check() + * will return FALSE. Calling any GTK function or instantiating + * any GTK type afterwards results in undefined behavior. * - * This test seems to work, at least. + * By returning 77, we can tell test harnesses compatible with + * the GNU standard approach to regard the test as skipped. */ - gtk_init_check(&argc, &argv); + if (! gtk_init_check(&argc, &argv)) + { + g_test_message("GTK initialization failed; skipping. Running inside a headless environment?"); + return 77; + } + + g_test_init(&argc, &argv, NULL); main_init_headless();