Fix possible indefinite loop in FileWatcherTest (#23)

The test
  FileWatcherTest/FileWatcherParameterizedTest.RecreateWatchedDir/ReadDirectoryChangesExW
is flaky. This CL doesn't fix the root cause, but it fixes the
indefinite spin in GetChangedFiles when there is no file change.
This commit is contained in:
Lutz Justen
2022-11-28 11:04:02 +01:00
committed by GitHub
parent a97d16c4e9
commit b0f5403854

View File

@@ -140,7 +140,11 @@ class FileWatcherParameterizedTest : public ::testing::TestWithParam<bool> {
// Wait for events, until they are processed.
while (modified_files.size() < number_of_files) {
EXPECT_TRUE(WaitForChange());
if (!WaitForChange()) {
LOG_ERROR("No change detected after %s",
absl::FormatDuration(kWaitTimeout));
return modified_files;
}
for (const auto& [path, info] : watcher_.GetModifiedFiles())
modified_files.insert_or_assign(path, info);
}