Skip to content

Commit

Permalink
test_watcher/new_directories: use a timeout similar to the simple test
Browse files Browse the repository at this point in the history
  • Loading branch information
Will committed Dec 3, 2023
1 parent 3094d25 commit c6fef0e
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions devel/src/wtr/test_watcher/test_new_directories.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ TEST_CASE("New Directories", "[test][dir][watch-target][not-perf]")

REQUIRE(fs::exists(tmpdir) || fs::create_directory(tmpdir));

/* @todo
This sleep is hiding a bug on darwin which picks
/* This sleep is hiding a bug on darwin which picks
up events slightly before we start watching. I'm
ok with that bit of wiggle-room. */
std::this_thread::sleep_for(100ms);
Expand Down Expand Up @@ -110,6 +109,14 @@ TEST_CASE("New Directories", "[test][dir][watch-target][not-perf]")

std::this_thread::sleep_for(10ms);

/* And give the watchers some room to await the events so far */
for (int i = 0;; i++) {
std::this_thread::sleep_for(10ms);
auto _ = std::scoped_lock<std::mutex>{event_recv_list_mtx};
if (event_sent_list.size() == event_recv_list.size()) break;
if (i > 1000) REQUIRE(! "Timeout: Waited more than one second for results");
}

event_sent_list.push_back(
{std::string("s/self/die@").append(tmpdir.string()),
event::effect_type::destroy,
Expand Down

0 comments on commit c6fef0e

Please sign in to comment.