From ee0f21388fda046f507de4049b4f6e3942c82ca1 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 17 Jul 2019 14:37:19 +0200 Subject: [PATCH] Add a helper IsRunningUnderXvfb() function to the test suite This will allow disabling some tests which fail when running only under Xvfb. The new function doesn't work automatically because there doesn't seem to be any way to distinguish it from the usual server, so it just checks whether wxUSE_XVFB=1 is set in the environment, as is done by Travis CI build script. --- tests/test.cpp | 12 ++++++++++++ tests/testprec.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/tests/test.cpp b/tests/test.cpp index c291c878e8..f5135f87fb 100644 --- a/tests/test.cpp +++ b/tests/test.cpp @@ -406,6 +406,18 @@ extern bool IsAutomaticTest() return s_isAutomatic == 1; } +extern bool IsRunningUnderXVFB() +{ + static int s_isRunningUnderXVFB = -1; + if ( s_isRunningUnderXVFB == -1 ) + { + wxString value; + s_isRunningUnderXVFB = wxGetEnv("wxUSE_XVFB", &value) && value == "1"; + } + + return s_isRunningUnderXVFB == 1; +} + #if wxUSE_GUI bool EnableUITests() diff --git a/tests/testprec.h b/tests/testprec.h index 9d6a6bb34a..7ae35168cc 100644 --- a/tests/testprec.h +++ b/tests/testprec.h @@ -121,6 +121,8 @@ extern bool IsNetworkAvailable(); extern bool IsAutomaticTest(); +extern bool IsRunningUnderXVFB(); + // Helper class setting the locale to the given one for its lifetime. class LocaleSetter {