From 4f74ceb9379ef2bef1f2a6b3acdde5b678b123d5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org>
Date: Fri, 13 Oct 2023 14:14:25 -0400
Subject: [PATCH] Testsuite: fix issue with Octave in a Wayland desktop session

If under a Wayland desktop session, some graphics would be displayed on the
screen, despite Octave being run in the virtual X11 frame buffer (xvfb).
Moreover, some unexplained random crashes would occur.

This commit ensures that Wayland is never used when running the testsuite.

By the way, add a command to explain why xvfb-run is needed and the
--no-window-system option cannot be run (see commit
96346b77e5e39ece565fc19f9b404f62c352488d).
---
 scripts/test-driver | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/scripts/test-driver b/scripts/test-driver
index 8ddef9bd14..7ff38db3b9 100755
--- a/scripts/test-driver
+++ b/scripts/test-driver
@@ -99,6 +99,10 @@ for test_file in "${test_files[@]}"; do
     if [[ $build_for == matlab ]]; then
         "$matlab_octave_exe" "${matlab_batch_flags[@]}" "$test_arg"
     else
+        unset XDG_SESSION_TYPE # Ensure that Wayland will not be used if in a desktop session
+        # We cannot use the --no-window-system option, and we have to use xvfb
+        # See the following Octave bug: https://savannah.gnu.org/bugs/?62101
+        # (this affects at least tests/shock_decomposition/ls2003_plot.mod)
         xvfb-run -a "$matlab_octave_exe" --no-init-file --silent --no-history "$test_arg"
     fi
 done
-- 
GitLab