@@ -235,52 +235,56 @@ BOOST_FIXTURE_TEST_CASE(shouldIgnoreFile, NotifierBuilderTests)
235235 thread.join ();
236236}
237237
238- // TODO: Test is flaky, fix by #52
239- // BOOST_FIXTURE_TEST_CASE(shouldWatchPathRecursively, NotifierBuilderTests)
240- // {
241-
242- // auto notifier = BuildNotifier()
243- // .watchPathRecursively(testDirectory_)
244- // .onEvent(Event::open, [&](Notification notification) {
245- // switch (notification.event) {
246- // default:
247- // break;
248- // case Event::open:
249- // if (notification.path == recursiveTestFile_) {
250- // promisedOpen_.set_value(notification);
251- // }
252- // break;
253- // }
254- // });
255-
256- // std::thread thread([¬ifier]() { notifier.runOnce(); });
257-
258- // openFile(recursiveTestFile_);
259-
260- // auto futureOpen = promisedOpen_.get_future();
261- // BOOST_CHECK(futureOpen.wait_for(timeout_) == std::future_status::ready);
262-
263- // notifier.stop();
264- // thread.join();
265- // }
266-
267- // TODO: Fix by #52
268- // BOOST_FIXTURE_TEST_CASE(shouldNotTriggerEventsOnWatchRecursively, NotifierBuilderTests)
269- // {
270- // auto notifier = BuildNotifier()
271- // .watchPathRecursively(testDirectory_)
272- // .onEvent(Event::all, [&](Notification) {
273- // BOOST_ASSERT_MSG(false, "Events should not be triggered when watching a directory
274- // recursively.");
275- // });
276-
277- // std::thread thread([¬ifier]() { notifier.runOnce(); });
278-
279- // std::this_thread::sleep_for(std::chrono::milliseconds{1000});
280-
281- // notifier.stop();
282- // thread.join();
283- // }
238+ // This test might fail on dev machines when editors trigger events by indexing the build directory
239+ BOOST_FIXTURE_TEST_CASE (shouldWatchPathRecursively, NotifierBuilderTests)
240+ {
241+
242+ auto notifier = BuildNotifier ()
243+ .watchPathRecursively (testDirectory_)
244+ .onEvent (Event::open, [&](Notification notification) {
245+ switch (notification.event ) {
246+ default :
247+ break ;
248+ case Event::open:
249+ if (notification.path == recursiveTestFile_) {
250+ promisedOpen_.set_value (notification);
251+ }
252+ break ;
253+ }
254+ });
255+
256+ std::thread thread ([¬ifier]() { notifier.runOnce (); });
257+
258+ openFile (recursiveTestFile_);
259+
260+ auto futureOpen = promisedOpen_.get_future ();
261+ BOOST_CHECK (futureOpen.wait_for (timeout_) == std::future_status::ready);
262+
263+ notifier.stop ();
264+ thread.join ();
265+ }
266+
267+ // This test might fail on dev machines when editors trigger events by indexing the build directory
268+ BOOST_FIXTURE_TEST_CASE (shouldNotTriggerEventsOnWatchRecursively, NotifierBuilderTests)
269+ {
270+ auto notifier
271+ = BuildNotifier ()
272+ .watchPathRecursively (testDirectory_)
273+ .onEvent (Event::all, [&](Notification notification) {
274+ std::cout << " event:" << notification.path << " " << notification.event
275+ << std::endl;
276+ BOOST_ASSERT_MSG (
277+ false ,
278+ " Events should not be triggered when watching a directory recursively." );
279+ });
280+
281+ std::thread thread ([¬ifier]() { notifier.run (); });
282+
283+ std::this_thread::sleep_for (std::chrono::milliseconds { 1000 });
284+
285+ notifier.stop ();
286+ thread.join ();
287+ }
284288
285289BOOST_FIXTURE_TEST_CASE (shouldWatchCreatedFile, NotifierBuilderTests)
286290{
0 commit comments