diff --git a/src/libraries/Microsoft.Extensions.FileProviders.Physical/tests/PhysicalFileProviderTests.cs b/src/libraries/Microsoft.Extensions.FileProviders.Physical/tests/PhysicalFileProviderTests.cs index d972b3626e1bdd..e0667e1093b974 100644 --- a/src/libraries/Microsoft.Extensions.FileProviders.Physical/tests/PhysicalFileProviderTests.cs +++ b/src/libraries/Microsoft.Extensions.FileProviders.Physical/tests/PhysicalFileProviderTests.cs @@ -1270,6 +1270,13 @@ void Fail(object state) using (var physicalFilesWatcher = new PhysicalFilesWatcher(root.Path + Path.DirectorySeparatorChar, fileSystemWatcher, pollForChanges: false)) using (var provider = new PhysicalFileProvider(root.Path) { FileWatcher = physicalFilesWatcher }) { + // This test only relies on the watcher events that are injected below via + // fileSystemWatcher.CallOnRenamed, which invokes FileSystemWatcher.OnRenamed directly and + // so bypasses Filter matching. Setting a Filter that cannot match any of the (randomly + // generated) names used by this test suppresses any genuine native events - e.g. ones + // belatedly reported by macOS fseventsd for the directory/file creation below. + fileSystemWatcher.Filter = "this-filter-does-not-match-anything"; + var oldDirectoryName = Guid.NewGuid().ToString(); var oldSubDirectoryName = Guid.NewGuid().ToString(); var oldSubDirectoryPath = Path.Combine(oldDirectoryName, oldSubDirectoryName);