From f1287154cde58f6c7d0c4425b1e1d3193ee9abef Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 1 Jun 2012 16:21:06 +0000 Subject: [PATCH 1/1] Add IsAutomaticTest() function to the unit tests. This allows to easily test if we're running on a buildbot slave and disable some difficult to debug test failures there. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71634 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- tests/controls/listbasetest.cpp | 4 +++- tests/test.cpp | 17 +++++++++++++++++ tests/testprec.h | 2 ++ tests/validators/valnum.cpp | 4 +++- 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/tests/controls/listbasetest.cpp b/tests/controls/listbasetest.cpp index 443ca241b5..65bffc00e7 100644 --- a/tests/controls/listbasetest.cpp +++ b/tests/controls/listbasetest.cpp @@ -181,11 +181,13 @@ void ListBaseTestCase::ItemClick() // generic wxListCtrl implementation. #if wxUSE_UIACTIONSIMULATOR && !defined(__WXGTK__) +#ifdef __WXMSW__ // FIXME: This test fails on MSW buildbot slaves although works fine on // development machine, no idea why. It seems to be a problem with // wxUIActionSimulator rather the wxListCtrl control itself however. - if ( wxGetUserId().Lower().Matches("buildslave*") ) + if ( IsAutomaticTest() ) return; +#endif // __WXMSW__ wxListCtrl* const list = GetList(); diff --git a/tests/test.cpp b/tests/test.cpp index c3bbc31191..155bfdf154 100644 --- a/tests/test.cpp +++ b/tests/test.cpp @@ -412,6 +412,23 @@ extern bool IsNetworkAvailable() return online; } +extern bool IsAutomaticTest() +{ + static int s_isAutomatic = -1; + if ( s_isAutomatic == -1 ) + { + // Allow setting an environment variable to emulate buildslave user for + // testing. + wxString username; + if ( !wxGetEnv("WX_TEST_USER", &username) ) + username = wxGetUserId(); + + s_isAutomatic = username.Lower().Matches("buildslave*"); + } + + return s_isAutomatic == 1; +} + // helper of OnRun(): gets the test with the given name, returning NULL (and // not an empty test suite) if there is no such test static Test *GetTestByName(const wxString& name) diff --git a/tests/testprec.h b/tests/testprec.h index 03e470a4bc..0005f5bb3e 100644 --- a/tests/testprec.h +++ b/tests/testprec.h @@ -126,6 +126,8 @@ extern void SetProcessEventFunc(ProcessEventFunc func); extern bool IsNetworkAvailable(); +extern bool IsAutomaticTest(); + // Helper class setting the locale to the given one for its lifetime. class LocaleSetter { diff --git a/tests/validators/valnum.cpp b/tests/validators/valnum.cpp index dd2d0e9835..599192e835 100644 --- a/tests/validators/valnum.cpp +++ b/tests/validators/valnum.cpp @@ -204,11 +204,13 @@ void NumValidatorTestCase::NoTrailingZeroes() void NumValidatorTestCase::Interactive() { +#ifdef __WXMSW__ // FIXME: This test fails on MSW buildbot slaves although works fine on // development machine, no idea why. It seems to be a problem with // wxUIActionSimulator rather the wxListCtrl control itself however. - if ( wxGetUserId().Lower().Matches("buildslave*") ) + if ( IsAutomaticTest() ) return; +#endif // __WXMSW__ // Set a locale using comma as thousands separator character. wxLocale loc(wxLANGUAGE_ENGLISH_UK, wxLOCALE_DONT_LOAD_DEFAULT); -- 2.45.2