[common] Fix FileWatcherTest once and for all (#53)

But...

ONCE AND FOR ALL!

A recent change introduced WaitForWatching(), which was supposed to
block until the file watcher is actively monitoring the directory.
However this always returned immediately since the watcher is in
kFailed state if the directory was deleted, which counts as watching
(IsStarted returns true for both kWatching and kFailed states).

This CL adds an IsWatching() helper function that returns true only for
the kWatching state, which means that the directory is actively being
watched.
This commit is contained in:
Lutz Justen
2023-01-09 17:56:47 +01:00
committed by GitHub
parent edd0ab023b
commit 8c6deaac90
3 changed files with 33 additions and 13 deletions
+6 -1
View File
@@ -77,7 +77,12 @@ class FileWatcherWin {
// Stops watching directory changes.
absl::Status StopWatching() ABSL_LOCKS_EXCLUDED(modified_files_mutex_);
// Indicates whether a directory is currently watched.
// Indicates whether StartWatching() was called, but StopWatching() was not
// called yet.
bool IsStarted() const;
// Indicates whether a directory is actively watched for changes. In contrast
// to IsStarted(), returns false while the directory does not exist.
bool IsWatching() const;
// Returns the watching status.