mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 05:27:43 +00:00
LibCore: Make the FileWatcher test resilient against outside events
The test currently watches /tmp, which the OS can create/modify files under at any time outside of our control. So just ignore events that we aren't interested in. Also test removing an item from the FileWatcher.
This commit is contained in:
parent
0e7a48bd7d
commit
8438c509e9
1 changed files with 6 additions and 2 deletions
|
@ -26,12 +26,16 @@ TEST_CASE(file_watcher_child_events)
|
|||
|
||||
int event_count = 0;
|
||||
file_watcher->on_change = [&](Core::FileWatcherEvent const& event) {
|
||||
// Ignore path events under /tmp that can occur for anything else the OS is
|
||||
// doing to create/delete files there.
|
||||
if (event.event_path != "/tmp/testfile"sv)
|
||||
return;
|
||||
|
||||
if (event_count == 0) {
|
||||
EXPECT_EQ(event.event_path, "/tmp/testfile");
|
||||
EXPECT(has_flag(event.type, Core::FileWatcherEvent::Type::ChildCreated));
|
||||
} else if (event_count == 1) {
|
||||
EXPECT_EQ(event.event_path, "/tmp/testfile");
|
||||
EXPECT(has_flag(event.type, Core::FileWatcherEvent::Type::ChildDeleted));
|
||||
EXPECT(MUST(file_watcher->remove_watch("/tmp/"sv)));
|
||||
|
||||
event_loop.quit(0);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue