From 7e96ac31156ccfd8a1a55238a2e3c24720590ec1 Mon Sep 17 00:00:00 2001 From: David Cantu Date: Fri, 23 Jul 2021 15:41:37 -0700 Subject: [PATCH 1/8] Do not prevent Extensions.FileProviders tests from running in CI --- .../Microsoft.Extensions.FileProviders.Physical.Tests.csproj | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/libraries/Microsoft.Extensions.FileProviders.Physical/tests/Microsoft.Extensions.FileProviders.Physical.Tests.csproj b/src/libraries/Microsoft.Extensions.FileProviders.Physical/tests/Microsoft.Extensions.FileProviders.Physical.Tests.csproj index 6b4ab37b34045f..6d87e179e21109 100644 --- a/src/libraries/Microsoft.Extensions.FileProviders.Physical/tests/Microsoft.Extensions.FileProviders.Physical.Tests.csproj +++ b/src/libraries/Microsoft.Extensions.FileProviders.Physical/tests/Microsoft.Extensions.FileProviders.Physical.Tests.csproj @@ -1,10 +1,9 @@ - + Microsoft.Extensions.FileProviders.Physical $(NetCoreAppCurrent);net461 true - true false From 0fe37387a284d61164425d45fc02ff97d7cfbac6 Mon Sep 17 00:00:00 2001 From: David Cantu Date: Mon, 2 Aug 2021 12:20:25 -0700 Subject: [PATCH 2/8] Remove SkipOnPlatform --- .../tests/AssemblyInfo.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/libraries/Microsoft.Extensions.FileProviders.Physical/tests/AssemblyInfo.cs b/src/libraries/Microsoft.Extensions.FileProviders.Physical/tests/AssemblyInfo.cs index b95172c7efbafa..9e6b00f9cf467a 100644 --- a/src/libraries/Microsoft.Extensions.FileProviders.Physical/tests/AssemblyInfo.cs +++ b/src/libraries/Microsoft.Extensions.FileProviders.Physical/tests/AssemblyInfo.cs @@ -2,6 +2,4 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; -using Xunit; - -[assembly: SkipOnPlatform(TestPlatforms.Browser, "Microsoft.Extensions.FileProviders.Physical is not supported on Browser")] +using Xunit; From 276b0089ffbbf571db09bf8f8025b5a6cf81751c Mon Sep 17 00:00:00 2001 From: David Cantu Date: Tue, 3 Aug 2021 09:10:49 -0700 Subject: [PATCH 3/8] Do not throw PNSE for PhysicalFileProvider in browser, fallback to use polling instead --- .../src/PhysicalFileProvider.cs | 9 ++++----- .../src/Resources/Strings.resx | 4 ++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/PhysicalFileProvider.cs b/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/PhysicalFileProvider.cs index 290d33aaa21294..3042ad456decdf 100644 --- a/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/PhysicalFileProvider.cs +++ b/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/PhysicalFileProvider.cs @@ -160,13 +160,12 @@ internal PhysicalFilesWatcher CreateFileWatcher() { string root = PathUtils.EnsureTrailingSlash(Path.GetFullPath(Root)); - // When both UsePollingFileWatcher & UseActivePolling are set, we won't use a FileSystemWatcher. - FileSystemWatcher watcher = UsePollingFileWatcher && UseActivePolling ? null : + // When UsePollingFileWatcher & UseActivePolling are set OR when target platform is browser, we won't use a FileSystemWatcher. + FileSystemWatcher watcher = UsePollingFileWatcher && UseActivePolling #if NETCOREAPP - OperatingSystem.IsBrowser() ? throw new PlatformNotSupportedException(SR.Format(SR.FileSystemWatcher_PlatformNotSupported, typeof(FileSystemWatcher))) : new FileSystemWatcher(root); -#else - new FileSystemWatcher(root); + || OperatingSystem.IsBrowser() #endif + ? null : new FileSystemWatcher(root); return new PhysicalFilesWatcher(root, watcher, UsePollingFileWatcher, _filters) { diff --git a/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/Resources/Strings.resx b/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/Resources/Strings.resx index 1eb0026a4f2a76..61a2f55a718489 100644 --- a/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/Resources/Strings.resx +++ b/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/Resources/Strings.resx @@ -130,6 +130,6 @@ Unexpected type of FileSystemInfo - The type {0} is not supported on this platform, use polling instead. + The type '{0}' is not supported on this platform, use polling instead. - \ No newline at end of file + From 57bbe424b2ebfab88ec7041392ad0df69ee1cee0 Mon Sep 17 00:00:00 2001 From: David Cantu Date: Tue, 3 Aug 2021 09:11:50 -0700 Subject: [PATCH 4/8] Use SkipOnPlatform only on tests that use FileSystemWatcher --- .../tests/PhysicalFileProviderTests.cs | 23 +++++++++++++++++++ .../tests/PhysicalFilesWatcherTests.cs | 6 +++++ 2 files changed, 29 insertions(+) diff --git a/src/libraries/Microsoft.Extensions.FileProviders.Physical/tests/PhysicalFileProviderTests.cs b/src/libraries/Microsoft.Extensions.FileProviders.Physical/tests/PhysicalFileProviderTests.cs index 96bf27b7b5acab..ba3c08a7ac432b 100644 --- a/src/libraries/Microsoft.Extensions.FileProviders.Physical/tests/PhysicalFileProviderTests.cs +++ b/src/libraries/Microsoft.Extensions.FileProviders.Physical/tests/PhysicalFileProviderTests.cs @@ -348,6 +348,7 @@ public void TokenIsSameForSamePath() [Fact] [ActiveIssue("https://github.com/dotnet/runtime/issues/34582", TestPlatforms.Windows, TargetFrameworkMonikers.Netcoreapp, TestRuntimes.Mono)] + [SkipOnPlatform(TestPlatforms.Browser, "System.IO.FileSystem.Watcher is not supported on Browser")] public async Task TokensFiredOnFileChange() { using (var root = new DisposableFileSystem()) @@ -378,6 +379,7 @@ public async Task TokensFiredOnFileChange() [Fact] [ActiveIssue("https://github.com/dotnet/runtime/issues/34582", TestPlatforms.Windows, TargetFrameworkMonikers.Netcoreapp, TestRuntimes.Mono)] + [SkipOnPlatform(TestPlatforms.Browser, "System.IO.FileSystem.Watcher is not supported on Browser")] public async Task TokenCallbackInvokedOnFileChange() { using (var root = new DisposableFileSystem()) @@ -414,6 +416,7 @@ public async Task TokenCallbackInvokedOnFileChange() [Fact] [ActiveIssue("https://github.com/dotnet/runtime/issues/34582", TestPlatforms.Windows, TargetFrameworkMonikers.Netcoreapp, TestRuntimes.Mono)] + [SkipOnPlatform(TestPlatforms.Browser, "System.IO.FileSystem.Watcher is not supported on Browser")] public async Task WatcherWithPolling_ReturnsTrueForFileChangedWhenFileSystemWatcherDoesNotRaiseEvents() { using (var root = new DisposableFileSystem()) @@ -444,6 +447,7 @@ public async Task WatcherWithPolling_ReturnsTrueForFileChangedWhenFileSystemWatc [Fact] [ActiveIssue("https://github.com/dotnet/runtime/issues/34582", TestPlatforms.Windows, TargetFrameworkMonikers.Netcoreapp, TestRuntimes.Mono)] + [SkipOnPlatform(TestPlatforms.Browser, "System.IO.FileSystem.Watcher is not supported on Browser")] public async Task WatcherWithPolling_ReturnsTrueForFileRemovedWhenFileSystemWatcherDoesNotRaiseEvents() { using (var root = new DisposableFileSystem()) @@ -476,6 +480,7 @@ public async Task WatcherWithPolling_ReturnsTrueForFileRemovedWhenFileSystemWatc [Fact] [ActiveIssue("https://github.com/dotnet/runtime/issues/34582", TestPlatforms.Windows, TargetFrameworkMonikers.Netcoreapp, TestRuntimes.Mono)] + [SkipOnPlatform(TestPlatforms.Browser, "System.IO.FileSystem.Watcher is not supported on Browser")] public async Task TokensFiredOnFileDeleted() { using (var root = new DisposableFileSystem()) @@ -787,6 +792,7 @@ public void GetDirectoryContentsReturnsFilesWhenExclusionDisabled() [Fact] [ActiveIssue("https://github.com/dotnet/runtime/issues/34582", TestPlatforms.Windows, TargetFrameworkMonikers.Netcoreapp, TestRuntimes.Mono)] + [SkipOnPlatform(TestPlatforms.Browser, "System.IO.FileSystem.Watcher is not supported on Browser")] public async Task FileChangeTokenNotNotifiedAfterExpiry() { using (var root = new DisposableFileSystem()) @@ -835,6 +841,7 @@ public void TokenIsSameForSamePathCaseInsensitive() [Fact] [ActiveIssue("https://github.com/dotnet/runtime/issues/34582", TestPlatforms.Windows, TargetFrameworkMonikers.Netcoreapp, TestRuntimes.Mono)] + [SkipOnPlatform(TestPlatforms.Browser, "System.IO.FileSystem.Watcher is not supported on Browser")] public async Task CorrectTokensFiredForMultipleFiles() { using (var root = new DisposableFileSystem()) @@ -868,6 +875,7 @@ public async Task CorrectTokensFiredForMultipleFiles() [Fact] [ActiveIssue("https://github.com/dotnet/runtime/issues/34582", TestPlatforms.Windows, TargetFrameworkMonikers.Netcoreapp, TestRuntimes.Mono)] + [SkipOnPlatform(TestPlatforms.Browser, "System.IO.FileSystem.Watcher is not supported on Browser")] public async Task TokenNotAffectedByExceptions() { using (var root = new DisposableFileSystem()) @@ -975,6 +983,7 @@ public void NoopChangeTokenForAbsolutePathFilters() [Fact] [ActiveIssue("https://github.com/dotnet/runtime/issues/34582", TestPlatforms.Windows, TargetFrameworkMonikers.Netcoreapp, TestRuntimes.Mono)] + [SkipOnPlatform(TestPlatforms.Browser, "System.IO.FileSystem.Watcher is not supported on Browser")] public async Task TokenFiredOnCreation() { using (var root = new DisposableFileSystem()) @@ -1000,6 +1009,7 @@ public async Task TokenFiredOnCreation() [Fact] [ActiveIssue("https://github.com/dotnet/runtime/issues/34582", TestPlatforms.Windows, TargetFrameworkMonikers.Netcoreapp, TestRuntimes.Mono)] + [SkipOnPlatform(TestPlatforms.Browser, "System.IO.FileSystem.Watcher is not supported on Browser")] public async Task TokenFiredOnDeletion() { using (var root = new DisposableFileSystem()) @@ -1025,6 +1035,7 @@ public async Task TokenFiredOnDeletion() [Fact] [ActiveIssue("https://github.com/dotnet/runtime/issues/34582", TestPlatforms.Windows, TargetFrameworkMonikers.Netcoreapp, TestRuntimes.Mono)] + [SkipOnPlatform(TestPlatforms.Browser, "System.IO.FileSystem.Watcher is not supported on Browser")] public async Task TokenFiredForFilesUnderPathEndingWithSlash() { using (var root = new DisposableFileSystem()) @@ -1079,6 +1090,7 @@ public async Task TokenFiredForRelativePathStartingWithSlash_Windows(string slas [InlineData("///")] // Testing Unix specific behaviour on leading slashes. [PlatformSpecific(TestPlatforms.AnyUnix)] + [SkipOnPlatform(TestPlatforms.Browser, "System.IO.FileSystem.Watcher is not supported on Browser")] public async Task TokenFiredForRelativePathStartingWithSlash_Unix(string slashes) { await TokenFiredForRelativePathStartingWithSlash(slashes); @@ -1121,6 +1133,7 @@ public async Task TokenNotFiredForInvalidPathStartingWithSlash_Windows(string sl [InlineData("/\0/")] // Testing Unix specific behaviour on leading slashes. [PlatformSpecific(TestPlatforms.AnyUnix)] + [SkipOnPlatform(TestPlatforms.Browser, "System.IO.FileSystem.Watcher is not supported on Browser")] public async Task TokenNotFiredForInvalidPathStartingWithSlash_Unix(string slashes) { await TokenNotFiredForInvalidPathStartingWithSlash(slashes); @@ -1152,6 +1165,7 @@ private async Task TokenNotFiredForInvalidPathStartingWithSlash(string slashes) [Fact] [ActiveIssue("https://github.com/dotnet/runtime/issues/34582", TestPlatforms.Windows, TargetFrameworkMonikers.Netcoreapp, TestRuntimes.Mono)] + [SkipOnPlatform(TestPlatforms.Browser, "System.IO.FileSystem.Watcher is not supported on Browser")] public async Task TokenFiredForGlobbingPatternsPointingToSubDirectory() { using (var root = new DisposableFileSystem()) @@ -1201,6 +1215,7 @@ public void TokensWithForwardAndBackwardSlashesAreSame() [Fact] [ActiveIssue("https://github.com/dotnet/runtime/issues/34582", TestPlatforms.Windows, TargetFrameworkMonikers.Netcoreapp, TestRuntimes.Mono)] + [SkipOnPlatform(TestPlatforms.Browser, "System.IO.FileSystem.Watcher is not supported on Browser")] public async Task TokensFiredForOldAndNewNamesOnRename() { using (var root = new DisposableFileSystem()) @@ -1230,6 +1245,7 @@ public async Task TokensFiredForOldAndNewNamesOnRename() [Fact] [ActiveIssue("https://github.com/dotnet/runtime/issues/34582", TestPlatforms.Windows, TargetFrameworkMonikers.Netcoreapp, TestRuntimes.Mono)] + [SkipOnPlatform(TestPlatforms.Browser, "System.IO.FileSystem.Watcher is not supported on Browser")] public async Task TokensFiredForNewDirectoryContentsOnRename() { var tcsShouldNotFire = new TaskCompletionSource(); @@ -1303,6 +1319,7 @@ void Fail(object state) [Fact] [ActiveIssue("https://github.com/dotnet/runtime/issues/34582", TestPlatforms.Windows, TargetFrameworkMonikers.Netcoreapp, TestRuntimes.Mono)] + [SkipOnPlatform(TestPlatforms.Browser, "System.IO.FileSystem.Watcher is not supported on Browser")] public async Task TokenNotFiredForFileNameStartingWithPeriod() { using (var root = new DisposableFileSystem()) @@ -1370,6 +1387,7 @@ public async Task TokensNotFiredForHiddenAndSystemFiles() [Fact] [ActiveIssue("https://github.com/dotnet/runtime/issues/34582", TestPlatforms.Windows, TargetFrameworkMonikers.Netcoreapp, TestRuntimes.Mono)] + [SkipOnPlatform(TestPlatforms.Browser, "System.IO.FileSystem.Watcher is not supported on Browser")] public async Task TokensFiredForAllEntriesOnError() { using (var root = new DisposableFileSystem()) @@ -1398,6 +1416,7 @@ public async Task TokensFiredForAllEntriesOnError() [Fact] [ActiveIssue("https://github.com/dotnet/runtime/issues/34582", TestPlatforms.Windows, TargetFrameworkMonikers.Netcoreapp, TestRuntimes.Mono)] + [SkipOnPlatform(TestPlatforms.Browser, "System.IO.FileSystem.Watcher is not supported on Browser")] public async Task WildCardToken_RaisesEventsForNewFilesAdded() { // Arrange @@ -1424,6 +1443,7 @@ public async Task WildCardToken_RaisesEventsForNewFilesAdded() [Fact] [ActiveIssue("https://github.com/dotnet/runtime/issues/34582", TestPlatforms.Windows, TargetFrameworkMonikers.Netcoreapp, TestRuntimes.Mono)] + [SkipOnPlatform(TestPlatforms.Browser, "System.IO.FileSystem.Watcher is not supported on Browser")] public async Task WildCardToken_RaisesEventsWhenFileSystemWatcherDoesNotFire() { // Arrange @@ -1473,6 +1493,7 @@ public void UsePollingFileWatcher_FileWatcherNull_SetsSuccessfully() } [Fact] + [SkipOnPlatform(TestPlatforms.Browser, "System.IO.FileSystem.Watcher is not supported on Browser")] public void UsePollingFileWatcher_FileWatcherNotNull_SetterThrows() { // Arrange @@ -1493,6 +1514,7 @@ public void UsePollingFileWatcher_FileWatcherNotNull_SetterThrows() } [Fact] + [SkipOnPlatform(TestPlatforms.Browser, "System.IO.FileSystem.Watcher is not supported on Browser")] public void UsePollingFileWatcher_FileWatcherNotNull_ReturnsFalse() { // Arrange @@ -1589,6 +1611,7 @@ public void CreateFileWatcher_CreatesWatcherWithPollingAndActiveFlags() [InlineData(false)] [InlineData(true)] [ActiveIssue("https://github.com/dotnet/runtime/issues/34582", TestPlatforms.Windows, TargetFrameworkMonikers.Netcoreapp, TestRuntimes.Mono)] + [SkipOnPlatform(TestPlatforms.Browser, "System.IO.FileSystem.Watcher is not supported on Browser")] public async Task CanDeleteWatchedDirectory(bool useActivePolling) { using (var root = new DisposableFileSystem()) diff --git a/src/libraries/Microsoft.Extensions.FileProviders.Physical/tests/PhysicalFilesWatcherTests.cs b/src/libraries/Microsoft.Extensions.FileProviders.Physical/tests/PhysicalFilesWatcherTests.cs index 77771f5390adc5..2e48a7cb0c0f70 100644 --- a/src/libraries/Microsoft.Extensions.FileProviders.Physical/tests/PhysicalFilesWatcherTests.cs +++ b/src/libraries/Microsoft.Extensions.FileProviders.Physical/tests/PhysicalFilesWatcherTests.cs @@ -18,6 +18,7 @@ public class PhysicalFilesWatcherTests private const int WaitTimeForTokenToFire = 500; [Fact] + [SkipOnPlatform(TestPlatforms.Browser, "System.IO.FileSystem.Watcher is not supported on Browser")] public void CreateFileChangeToken_DoesNotAllowPathsAboveRoot() { using (var root = new DisposableFileSystem()) @@ -37,6 +38,7 @@ public void CreateFileChangeToken_DoesNotAllowPathsAboveRoot() [Fact] [ActiveIssue("https://github.com/dotnet/runtime/issues/34582", TestPlatforms.Windows, TargetFrameworkMonikers.Netcoreapp, TestRuntimes.Mono)] + [SkipOnPlatform(TestPlatforms.Browser, "System.IO.FileSystem.Watcher is not supported on Browser")] public async Task HandlesOnRenamedEventsThatMatchRootPath() { using (var root = new DisposableFileSystem()) @@ -129,6 +131,7 @@ public void RaiseChangeEvents_CancelsAndRemovesMultipleChangedTokens() } [Fact] + [SkipOnPlatform(TestPlatforms.Browser, "System.IO.FileSystem.Watcher is not supported on Browser")] public void GetOrAddFilePathChangeToken_AddsPollingChangeTokenWithCancellationToken_WhenActiveCallbackIsTrue() { using (var root = new DisposableFileSystem()) @@ -155,6 +158,7 @@ public void GetOrAddFilePathChangeToken_AddsPollingChangeTokenWithCancellationTo } [Fact] + [SkipOnPlatform(TestPlatforms.Browser, "System.IO.FileSystem.Watcher is not supported on Browser")] public void GetOrAddFilePathChangeToken_AddsPollingChangeTokenWhenPollingIsEnabled() { using (var root = new DisposableFileSystem()) @@ -179,6 +183,7 @@ public void GetOrAddFilePathChangeToken_AddsPollingChangeTokenWhenPollingIsEnabl } [Fact] + [SkipOnPlatform(TestPlatforms.Browser, "System.IO.FileSystem.Watcher is not supported on Browser")] public void GetOrAddFilePathChangeToken_DoesNotAddsPollingChangeTokenWhenCallbackIsDisabled() { using (var root = new DisposableFileSystem()) @@ -193,6 +198,7 @@ public void GetOrAddFilePathChangeToken_DoesNotAddsPollingChangeTokenWhenCallbac } [Fact] + [SkipOnPlatform(TestPlatforms.Browser, "System.IO.FileSystem.Watcher is not supported on Browser")] public void GetOrAddWildcardChangeToken_AddsPollingChangeTokenWithCancellationToken_WhenActiveCallbackIsTrue() { using (var root = new DisposableFileSystem()) From e69ca2cc6433b647d5c129c8c010fc80a5e22b36 Mon Sep 17 00:00:00 2001 From: David Cantu Date: Wed, 4 Aug 2021 08:23:44 -0700 Subject: [PATCH 5/8] Set UsePollingFileWatcher and UseActivePolling for browser to avoid ArgumentNullException in PhysicalFilesWatcher --- .../src/PhysicalFileProvider.cs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/PhysicalFileProvider.cs b/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/PhysicalFileProvider.cs index 3042ad456decdf..de58daa3906d4e 100644 --- a/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/PhysicalFileProvider.cs +++ b/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/PhysicalFileProvider.cs @@ -160,12 +160,21 @@ internal PhysicalFilesWatcher CreateFileWatcher() { string root = PathUtils.EnsureTrailingSlash(Path.GetFullPath(Root)); - // When UsePollingFileWatcher & UseActivePolling are set OR when target platform is browser, we won't use a FileSystemWatcher. - FileSystemWatcher watcher = UsePollingFileWatcher && UseActivePolling + FileSystemWatcher watcher; #if NETCOREAPP - || OperatingSystem.IsBrowser() + // For browser we will proactively fallback to polling since FileSystemWatcher is not supported. + if (OperatingSystem.IsBrowser()) + { + UsePollingFileWatcher = true; + UseActivePolling = true; + watcher = null; + } + else #endif - ? null : new FileSystemWatcher(root); + { + // When UsePollingFileWatcher & UseActivePolling are set, we won't use a FileSystemWatcher. + watcher = UsePollingFileWatcher && UseActivePolling ? null : new FileSystemWatcher(root); + } return new PhysicalFilesWatcher(root, watcher, UsePollingFileWatcher, _filters) { From 88d7c6ea7da87a99aceb26aa4ead9e6a0b67e59a Mon Sep 17 00:00:00 2001 From: David Cantu Date: Wed, 4 Aug 2021 08:43:02 -0700 Subject: [PATCH 6/8] Fix Moq CI failures --- .../Microsoft.Extensions.FileProviders.Physical.Tests.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libraries/Microsoft.Extensions.FileProviders.Physical/tests/Microsoft.Extensions.FileProviders.Physical.Tests.csproj b/src/libraries/Microsoft.Extensions.FileProviders.Physical/tests/Microsoft.Extensions.FileProviders.Physical.Tests.csproj index 6d87e179e21109..515300a27aec6c 100644 --- a/src/libraries/Microsoft.Extensions.FileProviders.Physical/tests/Microsoft.Extensions.FileProviders.Physical.Tests.csproj +++ b/src/libraries/Microsoft.Extensions.FileProviders.Physical/tests/Microsoft.Extensions.FileProviders.Physical.Tests.csproj @@ -10,6 +10,7 @@ + From 1d185cab468bddf2e162ff1d1c026e142dd563d5 Mon Sep 17 00:00:00 2001 From: David Cantu Date: Wed, 4 Aug 2021 12:44:54 -0700 Subject: [PATCH 7/8] Use Assert.Same instead of Assert.Equals --- .../tests/PhysicalFileProviderTests.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libraries/Microsoft.Extensions.FileProviders.Physical/tests/PhysicalFileProviderTests.cs b/src/libraries/Microsoft.Extensions.FileProviders.Physical/tests/PhysicalFileProviderTests.cs index ba3c08a7ac432b..1df1c9f0115a93 100644 --- a/src/libraries/Microsoft.Extensions.FileProviders.Physical/tests/PhysicalFileProviderTests.cs +++ b/src/libraries/Microsoft.Extensions.FileProviders.Physical/tests/PhysicalFileProviderTests.cs @@ -341,7 +341,7 @@ public void TokenIsSameForSamePath() Assert.NotNull(token1); Assert.NotNull(token2); - Assert.Equal(token2, token1); + Assert.Same(token2, token1); } } } @@ -834,7 +834,7 @@ public void TokenIsSameForSamePathCaseInsensitive() var fileName = Guid.NewGuid().ToString(); var token = provider.Watch(fileName); var lowerCaseToken = provider.Watch(fileName.ToLowerInvariant()); - Assert.Equal(token, lowerCaseToken); + Assert.Same(token, lowerCaseToken); } } } @@ -1208,7 +1208,7 @@ public void TokensWithForwardAndBackwardSlashesAreSame() var token1 = provider.Watch(@"a/b\c"); var token2 = provider.Watch(@"a\b/c"); - Assert.Equal(token1, token2); + Assert.Same(token1, token2); } } } From e45e8b708726fb4ac385fd6f3dc77d19ca51666e Mon Sep 17 00:00:00 2001 From: David Cantu Date: Wed, 4 Aug 2021 13:17:11 -0700 Subject: [PATCH 8/8] Disable tests for IChangeToken equality between multiple Watch() calls in Browser --- .../tests/PhysicalFileProviderTests.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/libraries/Microsoft.Extensions.FileProviders.Physical/tests/PhysicalFileProviderTests.cs b/src/libraries/Microsoft.Extensions.FileProviders.Physical/tests/PhysicalFileProviderTests.cs index 1df1c9f0115a93..80e94fc31f910c 100644 --- a/src/libraries/Microsoft.Extensions.FileProviders.Physical/tests/PhysicalFileProviderTests.cs +++ b/src/libraries/Microsoft.Extensions.FileProviders.Physical/tests/PhysicalFileProviderTests.cs @@ -325,6 +325,7 @@ public void GetFileInfoReturnsFileInfoWhenExclusionDisabled() [Fact] [ActiveIssue("https://github.com/dotnet/runtime/issues/34582", TestPlatforms.Windows, TargetFrameworkMonikers.Netcoreapp, TestRuntimes.Mono)] + [SkipOnPlatform(TestPlatforms.Browser, "Browser always uses Active Polling which doesn't return the same instance between multiple calls to Watch(string)")] public void TokenIsSameForSamePath() { using (var root = new DisposableFileSystem()) @@ -341,7 +342,7 @@ public void TokenIsSameForSamePath() Assert.NotNull(token1); Assert.NotNull(token2); - Assert.Same(token2, token1); + Assert.Equal(token2, token1); } } } @@ -825,6 +826,7 @@ public async Task FileChangeTokenNotNotifiedAfterExpiry() [Fact] [ActiveIssue("https://github.com/dotnet/runtime/issues/34582", TestPlatforms.Windows, TargetFrameworkMonikers.Netcoreapp, TestRuntimes.Mono)] + [SkipOnPlatform(TestPlatforms.Browser, "Browser always uses Active Polling which doesn't return the same instance between multiple calls to Watch(string)")] public void TokenIsSameForSamePathCaseInsensitive() { using (var root = new DisposableFileSystem()) @@ -834,7 +836,7 @@ public void TokenIsSameForSamePathCaseInsensitive() var fileName = Guid.NewGuid().ToString(); var token = provider.Watch(fileName); var lowerCaseToken = provider.Watch(fileName.ToLowerInvariant()); - Assert.Same(token, lowerCaseToken); + Assert.Equal(token, lowerCaseToken); } } } @@ -1199,6 +1201,7 @@ public async Task TokenFiredForGlobbingPatternsPointingToSubDirectory() [Fact] [ActiveIssue("https://github.com/dotnet/runtime/issues/34582", TestPlatforms.Windows, TargetFrameworkMonikers.Netcoreapp, TestRuntimes.Mono)] + [SkipOnPlatform(TestPlatforms.Browser, "Browser always uses Active Polling which doesn't return the same instance between multiple calls to Watch(string)")] public void TokensWithForwardAndBackwardSlashesAreSame() { using (var root = new DisposableFileSystem()) @@ -1208,7 +1211,7 @@ public void TokensWithForwardAndBackwardSlashesAreSame() var token1 = provider.Watch(@"a/b\c"); var token2 = provider.Watch(@"a\b/c"); - Assert.Same(token1, token2); + Assert.Equal(token1, token2); } } }