From d3eec3b672ed275fb3b0ab520b8e2464e699cb16 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 10 May 2011 08:54:20 +0000 Subject: [PATCH] Attempt to work around Mac g++ 4.0 bug in fswatcher unit test. Don't define the class overriding a virtual base class method inside the test function as g++ 4.0 under OS X 10.5 fails to compile this for some mysterious reason. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67722 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- tests/fswatcher/fswatchertest.cpp | 78 ++++++++++++++++++------------- 1 file changed, 46 insertions(+), 32 deletions(-) diff --git a/tests/fswatcher/fswatchertest.cpp b/tests/fswatcher/fswatchertest.cpp index 6cefa25969..fc158e7162 100644 --- a/tests/fswatcher/fswatchertest.cpp +++ b/tests/fswatcher/fswatchertest.cpp @@ -614,45 +614,59 @@ void FileSystemWatcherTestCase::TestEventAccess() tester.Run(); } -void FileSystemWatcherTestCase::TestNoEventsAfterRemove() +namespace +{ + +// We can't define this class locally inside TestNoEventsAfterRemove() for some +// reason with g++ 4.0 under OS X 10.5, it results in the following mysterious +// error: +// +// /var/tmp//ccTkNCkc.s:unknown:Non-global symbol: +// __ZThn80_ZN25FileSystemWatcherTestCase23TestNoEventsAfterRemoveEvEN11EventTester6NotifyEv.eh +// can't be a weak_definition +// +// So define this class outside the function instead. +class NoEventsAfterRemoveEventTester : public EventHandler, + public wxTimer { - class EventTester : public EventHandler, - public wxTimer +public: + NoEventsAfterRemoveEventTester() { - public: - EventTester() - { - // We need to use an inactivity timer as we never get any file - // system events in this test, so we consider that the test is - // finished when this 1s timeout expires instead of, as usual, - // stopping after getting the file system events. - Start(1000, true); - } + // We need to use an inactivity timer as we never get any file + // system events in this test, so we consider that the test is + // finished when this 1s timeout expires instead of, as usual, + // stopping after getting the file system events. + Start(1000, true); + } - virtual void GenerateEvent() - { - m_watcher->Remove(EventGenerator::GetWatchDir()); - CPPUNIT_ASSERT(eg.CreateFile()); - } + virtual void GenerateEvent() + { + m_watcher->Remove(EventGenerator::GetWatchDir()); + CPPUNIT_ASSERT(eg.CreateFile()); + } - virtual void CheckResult() - { - CPPUNIT_ASSERT( m_events.empty() ); - } + virtual void CheckResult() + { + CPPUNIT_ASSERT( m_events.empty() ); + } - virtual wxFileSystemWatcherEvent ExpectedEvent() - { - CPPUNIT_FAIL( "Shouldn't be called" ); + virtual wxFileSystemWatcherEvent ExpectedEvent() + { + CPPUNIT_FAIL( "Shouldn't be called" ); - return wxFileSystemWatcherEvent(wxFSW_EVENT_ERROR); - } + return wxFileSystemWatcherEvent(wxFSW_EVENT_ERROR); + } - virtual void Notify() - { - SendIdle(); - } - }; + virtual void Notify() + { + SendIdle(); + } +}; - EventTester tester; +} // anonymous namespace + +void FileSystemWatcherTestCase::TestNoEventsAfterRemove() +{ + NoEventsAfterRemoveEventTester tester; tester.Run(); } -- 2.47.2