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);