From 99378ed0d757b0f37cdc7cc602b41e44cb8dbde5 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 5 Nov 2017 17:50:09 +0100 Subject: [PATCH] Disable tests using wxUIActionSimulator under non-MSW platforms wxUIActionSimulator is just too unreliable to be used there, so while fixing it should really be a priority, for now at least prevent these spurious failures from masking any other ones, which indicate real problems that need to be fixed. Notice that these tests can still be enabled by setting the environment variable WX_UI_TESTS to 1 (or disabled by setting it to 0 under MSW). --- tests/test.cpp | 31 +++++++++++++++++++++++++++++++ tests/testprec.h | 16 ++++++++++------ 2 files changed, 41 insertions(+), 6 deletions(-) diff --git a/tests/test.cpp b/tests/test.cpp index 5e2f6c5c7d..ba853d53ea 100644 --- a/tests/test.cpp +++ b/tests/test.cpp @@ -360,6 +360,37 @@ extern bool IsAutomaticTest() #if wxUSE_GUI +bool EnableUITests() +{ + static int s_enabled = -1; + if ( s_enabled == -1 ) + { + // Allow explicitly configuring this via an environment variable under + // all platforms. + wxString enabled; + if ( wxGetEnv("WX_UI_TESTS", &enabled) ) + { + if ( enabled == "1" ) + s_enabled = 1; + else if ( enabled == "0" ) + s_enabled = 0; + else + wxFprintf(stderr, "Unknown \"WX_UI_TESTS\" value \"%s\" ignored.\n", enabled); + } + + if ( s_enabled == -1 ) + { +#ifdef __WXMSW__ + s_enabled = 1; +#else // !__WXMSW__ + s_enabled = 0; +#endif // __WXMSW__/!__WXMSW__ + } + } + + return s_enabled == 1; +} + void DeleteTestWindow(wxWindow* win) { if ( !win ) diff --git a/tests/testprec.h b/tests/testprec.h index 8bbaf4be70..f5661446ed 100644 --- a/tests/testprec.h +++ b/tests/testprec.h @@ -10,13 +10,14 @@ // this allows the tests that do not rely on it to run on platforms that don't // support it. // -// FIXME: And while OS X does support it, more or less, too many tests -// currently fail under it so disable all interactive tests there. They -// should, of course, be reenabled a.s.a.p. -#if wxUSE_UIACTIONSIMULATOR && !defined(__WXOSX__) - #define WXUISIM_TEST(test) CPPUNIT_TEST(test) +// Unfortunately, currently too many of the UI tests fail on non-MSW platforms, +// so they're disabled there by default. This really, really needs to be fixed, +// but for now having the UI tests always failing is not helpful as it prevents +// other test failures from being noticed, so disable them there. +#if wxUSE_UIACTIONSIMULATOR + #define WXUISIM_TEST(test) if ( EnableUITests() ) { CPPUNIT_TEST(test) } #else - #define WXUISIM_TEST(test) (void)0 + #define WXUISIM_TEST(test) #endif // define wxHAVE_U_ESCAPE if the compiler supports \uxxxx character constants @@ -169,6 +170,9 @@ private: #if wxUSE_GUI +// Return true if the UI tests are enabled, used by WXUISIM_TEST(). +extern bool EnableUITests(); + // Helper function deleting the window without asserts (and hence exceptions // thrown from its dtor!) even if it has mouse capture. void DeleteTestWindow(wxWindow* win);