Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,8 @@ private static bool GetAlpnSupport()
public static bool SupportsAlpn => s_supportsAlpn.Value;
public static bool SupportsClientAlpn => SupportsAlpn || IsOSX || IsMacCatalyst || IsiOS || IstvOS;
public static bool SupportsHardLinkCreation => !IsAndroid && !IsLinuxBionic;
// macOS FSEvents and OpenBSD libinotify don't preserve the order of FileSystemWatcher events for different paths.
public static bool IsFileSystemWatcherEventOrderPreserved => !IsOSX && !IsMacCatalyst && !IsOpenBSD;

private static readonly Lazy<bool> s_supportsTls10 = new Lazy<bool>(GetTls10Support);
private static readonly Lazy<bool> s_supportsTls11 = new Lazy<bool>(GetTls11Support);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ public void Directory_Move_From_Watched_To_Unwatched()
}

[ConditionalTheory]
[ActiveIssue("https://github.com/dotnet/runtime/issues/127651", TestPlatforms.OSX)]
[PlatformSpecific(TestPlatforms.OSX)]
[InlineData(1)]
[InlineData(2)]
Expand Down Expand Up @@ -196,7 +195,7 @@ private void DirectoryMove_Multiple_FromWatchedToUnwatched(int filesCount, bool

var expectedEvents = dirs.Select(dir => new FiredEvent(WatcherChangeTypes.Deleted, dir.DirectoryInWatchedDir));

Assert.Equal(expectedEvents, events);
AssertEventsEqual(expectedEvents, events);
}

private void DirectoryMove_Multiple_FromUnwatchedToWatched(int filesCount)
Expand All @@ -222,7 +221,7 @@ private void DirectoryMove_Multiple_FromUnwatchedToWatched(int filesCount)
List<FiredEvent> events = ExpectEvents(watcher, filesCount, action);
var expectedEvents = dirs.Select(dir => new FiredEvent(WatcherChangeTypes.Created, dir.DirectoryInWatchedDir));

Assert.Equal(expectedEvents, events);
AssertEventsEqual(expectedEvents, events);
}

private void DirectoryMove_FromWatchedToUnwatched(WatcherChangeTypes eventType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ public void File_Move_Multiple_From_Watched_To_Unwatched(int filesCount)
}

[Theory]
[SkipOnPlatform(TestPlatforms.OpenBSD, "libinotify on OpenBSD does not preserve event ordering.")]
[InlineData(1)]
[InlineData(2)]
[InlineData(3)]
Expand Down Expand Up @@ -233,7 +232,7 @@ private void FileMove_Multiple_FromWatchedToUnwatched(int filesCount, bool skipO

var expectedEvents = files.Select(file => new FiredEvent(WatcherChangeTypes.Deleted, file.FileInWatchedDir));

Assert.Equal(expectedEvents, events);
AssertEventsEqual(expectedEvents, events);
}

private void FileMove_Multiple_FromUnwatchedToWatched(int filesCount)
Expand All @@ -259,7 +258,7 @@ private void FileMove_Multiple_FromUnwatchedToWatched(int filesCount)
List<FiredEvent> events = ExpectEvents(watcher, filesCount, action);
var expectedEvents = files.Select(file => new FiredEvent(WatcherChangeTypes.Created, file.FileInWatchedDir));

Assert.Equal(expectedEvents, events);
AssertEventsEqual(expectedEvents, events);
}

private void FileMove_FromUnwatchedToWatched(WatcherChangeTypes eventType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,19 @@ internal static Func<FiredEvent, bool> CreateDeduplicatingFilter(WatcherChangeTy
return firedEvent => (firedEvent.EventType & filteredTypes) != 0 || !seenEvents.TryAdd(firedEvent, true);
}

// Where the OS doesn't preserve the order of events for different paths, compare them as a multiset.
// Elsewhere the implementation must preserve the OS order (e.g. the deferred IN_MOVED_FROM handling on Linux).
internal static void AssertEventsEqual(IEnumerable<FiredEvent> expected, IEnumerable<FiredEvent> actual)
{
if (!PlatformDetection.IsFileSystemWatcherEventOrderPreserved)
{
expected = expected.OrderBy(e => e.ToString(), StringComparer.Ordinal);
actual = actual.OrderBy(e => e.ToString(), StringComparer.Ordinal);
}

Assert.Equal(expected, actual);
}

// Observe until an expected count of events is triggered, otherwise fail. Return all filtered events.
internal static List<FiredEvent> ExpectEvents(FileSystemWatcher watcher, int expectedEvents, Action action, Func<FiredEvent, bool>? isFilteredOut = null)
{
Expand Down
Loading