Re-enable running FS watcher test on OS X
Use a workaround to compensate for the differences between a non-GUI and GUI event loop with wxOSX. This allows the FS watcher tests to pass (previously it would hang) under OS X without having to move the tests to the test GUI application (where the tests do pass on OS X already, without needing this workaround). See #16969.
This commit is contained in:
parent
bb14d8e131
commit
f0e098fa06
@ -30,6 +30,15 @@
|
||||
|
||||
#include "testfile.h"
|
||||
|
||||
/*
|
||||
This test used to be disabled on OS X as it hung. Work around the apparent
|
||||
wxOSX differences between a non-GUI event loop and a GUI event loop (where
|
||||
the tests do run fine) until this gets resolved.
|
||||
*/
|
||||
#ifdef __WXOSX__
|
||||
#define OSX_EVENT_LOOP_WORKAROUND
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// local functions
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -191,10 +200,16 @@ public:
|
||||
enum { WAIT_DURATION = 3 };
|
||||
|
||||
EventHandler(int types = wxFSW_EVENT_ALL) :
|
||||
eg(EventGenerator::Get()), m_loop(0), m_count(0), m_watcher(0),
|
||||
m_eventTypes(types)
|
||||
eg(EventGenerator::Get()), m_loop(0),
|
||||
#ifdef OSX_EVENT_LOOP_WORKAROUND
|
||||
m_loopActivator(NULL),
|
||||
#endif
|
||||
m_count(0), m_watcher(0), m_eventTypes(types)
|
||||
{
|
||||
m_loop = new wxEventLoop();
|
||||
#ifdef OSX_EVENT_LOOP_WORKAROUND
|
||||
m_loopActivator = new wxEventLoopActivator(m_loop);
|
||||
#endif
|
||||
Connect(wxEVT_IDLE, wxIdleEventHandler(EventHandler::OnIdle));
|
||||
Connect(wxEVT_FSWATCHER, wxFileSystemWatcherEventHandler(
|
||||
EventHandler::OnFileSystemEvent));
|
||||
@ -203,6 +218,9 @@ public:
|
||||
virtual ~EventHandler()
|
||||
{
|
||||
delete m_watcher;
|
||||
#ifdef OSX_EVENT_LOOP_WORKAROUND
|
||||
delete m_loopActivator;
|
||||
#endif
|
||||
if (m_loop)
|
||||
{
|
||||
if (m_loop->IsRunning())
|
||||
@ -221,6 +239,13 @@ public:
|
||||
{
|
||||
wxIdleEvent* e = new wxIdleEvent();
|
||||
QueueEvent(e);
|
||||
|
||||
#ifdef OSX_EVENT_LOOP_WORKAROUND
|
||||
// The fs watcher test cases will hang on OS X if Yield() is not called.
|
||||
// It seems that the OS X event loop and / or queueing behaves
|
||||
// differently than on MSW and Linux.
|
||||
m_loop->Yield(true);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Run()
|
||||
@ -387,6 +412,9 @@ public:
|
||||
protected:
|
||||
EventGenerator& eg;
|
||||
wxEventLoopBase* m_loop; // loop reference
|
||||
#ifdef OSX_EVENT_LOOP_WORKAROUND
|
||||
wxEventLoopActivator* m_loopActivator;
|
||||
#endif
|
||||
int m_count; // idle events count
|
||||
|
||||
wxFileSystemWatcher* m_watcher;
|
||||
@ -459,15 +487,8 @@ private:
|
||||
wxDECLARE_NO_COPY_CLASS(FileSystemWatcherTestCase);
|
||||
};
|
||||
|
||||
// the test currently hangs under OS X for some reason and this prevents tests
|
||||
// ran by buildbot from completing so disable it until someone has time to
|
||||
// debug it
|
||||
//
|
||||
// FIXME: debug and fix this!
|
||||
#ifndef __WXOSX__
|
||||
// register in the unnamed registry so that these tests are run by default
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( FileSystemWatcherTestCase );
|
||||
#endif
|
||||
|
||||
// also include in its own registry so that these tests can be run alone
|
||||
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( FileSystemWatcherTestCase,
|
||||
@ -951,7 +972,16 @@ void FileSystemWatcherTestCase::TestTrees()
|
||||
};
|
||||
|
||||
TreeTester tester;
|
||||
|
||||
// The fs watcher test cases will hang on OS X if we call Run().
|
||||
// This is likely due to differences between the event loop
|
||||
// between OS X and the other ports.
|
||||
#ifdef OSX_EVENT_LOOP_WORKAROUND
|
||||
tester.Init();
|
||||
tester.GenerateEvent();
|
||||
#else
|
||||
tester.Run();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user