mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 05:25:32 +03: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
Notes:
sideshowbarker
2024-07-17 06:28:38 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/8438c509e9 Pull-request: https://github.com/SerenityOS/serenity/pull/17086 Reviewed-by: https://github.com/linusg ✅
@ -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…
Reference in New Issue
Block a user