[browser][file system] Tests System.IO.FileSystem (#39768)
authorKenneth Pouncey <kjpou@pt.lu>
Mon, 10 Aug 2020 20:35:25 +0000 (22:35 +0200)
committerGitHub <noreply@github.com>
Mon, 10 Aug 2020 20:35:25 +0000 (16:35 -0400)
* [browser][file system] Tests System.IO.FileSystem

* Remove FileSystem from test project exclusions.

* [browser][filesystem] Comment on skipped tests due to IO.Pipes not supported

* [browser][filesystem] Comment on skipped tests due to monitor not supported

* Address review comments

* Address review comments on how to handle monitor PNSE

* Update src/libraries/System.IO.FileSystem/tests/File/GetSetTimes.cs

Co-authored-by: Jan Kotas <jkotas@microsoft.com>
* Add ActiveIssue for browser platform

```
        [ActiveIssue("https://github.com/dotnet/runtime/issues/39955", TestPlatforms.Browser)]
        public void NotFoundErrorIsExpected()
```

* Simplify test case with `PlatformDetection.IsSuperUser` as per review comment

* Remove unused variable from tests

* Browser platform volume does not limit each component of the path to a total of 255 characters.

- Remove the test `DirectoryWithComponentLongerThanMaxComponentAsPath_ThrowsException` for Browser platform.
- Add new test `DirectoryWithComponentLongerThanMaxComponentAsPath_BrowserDoesNotThrowsException` for Browser platform in case this check is added in the future.

* Fix windows tests

* Add ActiveIssue to test System.IO.Tests.DirectoryInfo_Name.CurrentDirectory

- System.IO.Tests.DirectoryInfo_Name.CurrentDirectory does not pass because it is using Path.GetFileName on the current directory of "/".
- See issue https://github.com/dotnet/runtime/issues/39998 for more information

* Add active issue for tests that need to support file locking.

* Add active issue for tests that need to support file locking.

* Browser volume does not have a limit on segments

* Remove browser platform test

* Remove active issue for NotFoundErrorIsExpected

* Remove platform specific from SkippingHiddenFiles

* Fix enumeration test errors failing from `HiddenFilesAreReturned`.

- WebAssembly (BROWSER) has dirent d_type but is not identifying correctly but by returning UNKNOWN the managed code properly stats the file to detect if entry is directory or not.

* Fix enumeration test errors failing from `HiddenFilesAreReturned`.

- WebAssembly (BROWSER) has dirent d_type but is not identifying correctly but by returning UNKNOWN the managed code properly stats the file to detect if entry is directory or not.

* Fix build for TARGET_WASM not defined

* Address review comment by add check for IsWindows to IsSuperUser.

* Address review comment by add check for IsWindows to IsSuperUser.

* Platform Specific test for hidden files no longer needed.

* Platform Specific test fno longer needed.

* Use active issue for rename issue

* ActiveIssue no longer needed

- PR https://github.com/dotnet/runtime/pull/40310 works around the issue for now while waiting for fix https://github.com/emscripten-core/emscripten/issues/11804 / https://github.com/emscripten-core/emscripten/pull/11812

* Use ActiveIssue for SettingUpdatesProperties

* Use ActiveIssue for TimesIncludeMillisecondPart

* Use ActiveIssue for ErrorHandlingTests failures

* Use ActiveIssue for SetUptoNanoseconds

* Use ActiveIssue for GetSetTimes test failures

* Use ActiveIssue for tests failing with DirectoryNotFoundException

* Use ActiveIssue for tests failing with UnauthorizedAccessException

* Remove debugging statement from pal_io

* Address type in CreateDirectory method name

Co-authored-by: Jan Kotas <jkotas@microsoft.com>
Co-authored-by: Mitchell Hwang <mitchell.hwang@microsoft.com>
35 files changed:
src/libraries/Common/tests/TestUtilities/System/PlatformDetection.Unix.cs
src/libraries/Native/Unix/System.Native/pal_io.c
src/libraries/System.IO.FileSystem/tests/Base/BaseGetSetTimes.cs
src/libraries/System.IO.FileSystem/tests/Directory/CreateDirectory.cs
src/libraries/System.IO.FileSystem/tests/Directory/Delete.cs
src/libraries/System.IO.FileSystem/tests/Directory/Exists.cs
src/libraries/System.IO.FileSystem/tests/Directory/Move.cs
src/libraries/System.IO.FileSystem/tests/DirectoryInfo/Exists.cs
src/libraries/System.IO.FileSystem/tests/DirectoryInfo/MoveTo.cs
src/libraries/System.IO.FileSystem/tests/DirectoryInfo/Name.cs
src/libraries/System.IO.FileSystem/tests/Enumeration/ErrorHandlingTests.cs
src/libraries/System.IO.FileSystem/tests/File/Copy.cs
src/libraries/System.IO.FileSystem/tests/File/Create.cs
src/libraries/System.IO.FileSystem/tests/File/Exists.cs
src/libraries/System.IO.FileSystem/tests/File/GetSetTimes.cs
src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllBytes.cs
src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllBytesAsync.cs
src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllLines.cs
src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllLinesAsync.cs
src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllText.cs
src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllTextAsync.cs
src/libraries/System.IO.FileSystem/tests/FileInfo/Exists.cs
src/libraries/System.IO.FileSystem/tests/FileInfo/GetSetTimes.cs
src/libraries/System.IO.FileSystem/tests/FileStream/CanSeek.cs
src/libraries/System.IO.FileSystem/tests/FileStream/CopyToAsync.cs
src/libraries/System.IO.FileSystem/tests/FileStream/Flush.cs
src/libraries/System.IO.FileSystem/tests/FileStream/Pipes.cs
src/libraries/System.IO.FileSystem/tests/FileStream/ReadWriteSpan.cs
src/libraries/System.IO.FileSystem/tests/FileStream/WriteAsync.cs
src/libraries/System.IO.FileSystem/tests/FileStream/ctor_str_fm_fa_fs.cs
src/libraries/System.IO.FileSystem/tests/FileStream/ctor_str_fm_fa_fs.write.cs
src/libraries/System.IO.FileSystem/tests/FileSystemTest.Browser.cs [new file with mode: 0644]
src/libraries/System.IO.FileSystem/tests/System.IO.FileSystem.Tests.csproj
src/libraries/System.IO.MemoryMappedFiles/tests/MemoryMappedFile.CreateFromFile.Tests.cs
src/libraries/tests.proj

index a042993..fb7db1e 100644 (file)
@@ -47,9 +47,7 @@ namespace System
         public static bool IsNotFedoraOrRedHatFamily => !IsFedora && !IsRedHatFamily;
         public static bool IsNotDebian10 => !IsDebian10;
 
-        public static bool IsSuperUser => IsBrowser ? false : (!IsWindows ?
-            libc.geteuid() == 0 :
-            throw new PlatformNotSupportedException());
+        public static bool IsSuperUser => IsBrowser || IsWindows ? false : libc.geteuid() == 0;
 
         public static Version OpenSslVersion => !IsOSXLike && !IsWindows ?
             GetOpenSslVersion() :
index 85c5bf0..e0ed6ca 100644 (file)
@@ -91,7 +91,10 @@ c_static_assert(PAL_S_IFSOCK == S_IFSOCK);
 // Validate that our enum for inode types is the same as what is
 // declared by the dirent.h header on the local system.
 // (AIX doesn't have dirent d_type, so none of this there)
-#if defined(DT_UNKNOWN)
+// WebAssembly (BROWSER) has dirent d_type but is not correct
+// by returning UNKNOWN the managed code properly stats the file
+// to detect if entry is directory or not.
+#if defined(DT_UNKNOWN) || defined(TARGET_WASM)
 c_static_assert((int)PAL_DT_UNKNOWN == (int)DT_UNKNOWN);
 c_static_assert((int)PAL_DT_FIFO == (int)DT_FIFO);
 c_static_assert((int)PAL_DT_CHR == (int)DT_CHR);
@@ -345,10 +348,13 @@ static void ConvertDirent(const struct dirent* entry, DirectoryEntry* outputEntr
     // the start of the unmanaged string. Give the caller back a pointer to the
     // location of the start of the string that exists in their own byte buffer.
     outputEntry->Name = entry->d_name;
-#if !defined(DT_UNKNOWN)
+#if !defined(DT_UNKNOWN) || defined(TARGET_WASM)
     // AIX has no d_type, and since we can't get the directory that goes with
     // the filename from ReadDir, we can't stat the file. Return unknown and
     // hope that managed code can properly stat the file.
+    // WebAssembly (BROWSER) has dirent d_type but is not correct
+    // by returning UNKNOWN the managed code properly stats the file
+    // to detect if entry is directory or not.
     outputEntry->InodeType = PAL_DT_UNKNOWN;
 #else
     outputEntry->InodeType = (int32_t)entry->d_type;
index 58a515e..67d9655 100644 (file)
@@ -41,6 +41,7 @@ namespace System.IO.Tests
         }
 
         [Fact]
+        [ActiveIssue("https://github.com/dotnet/runtime/issues/40528", TestPlatforms.Browser)]
         public void SettingUpdatesProperties()
         {
             T item = GetExistingItem();
@@ -77,6 +78,7 @@ namespace System.IO.Tests
         }
 
         [ConditionalFact(nameof(isNotHFS))] // OSX HFS driver format does not support millisec granularity
+        [ActiveIssue("https://github.com/dotnet/runtime/issues/40530", TestPlatforms.Browser)]
         public void TimesIncludeMillisecondPart()
         {
             T item = GetExistingItem();
index 5b3b2dc..78c234d 100644 (file)
@@ -210,17 +210,26 @@ namespace System.IO.Tests
             Assert.Equal(path, result.FullName);
             Assert.True(Directory.Exists(result.FullName));
         }
+        #endregion
+
+        #region PlatformSpecific
 
         [Theory,
             MemberData(nameof(PathsWithComponentLongerThanMaxComponent))]
+        [PlatformSpecific(~TestPlatforms.Browser)] // Browser does not have a limit on the maximum component length
         public void DirectoryWithComponentLongerThanMaxComponentAsPath_ThrowsException(string path)
         {
             AssertExtensions.ThrowsAny<IOException, DirectoryNotFoundException, PathTooLongException>(() => Create(path));
         }
 
-        #endregion
-
-        #region PlatformSpecific
+        [Theory,
+            MemberData(nameof(PathsWithComponentLongerThanMaxComponent))]
+        [PlatformSpecific(TestPlatforms.Browser)] // Browser specific test in case the check changes in the future
+        public void DirectoryWithComponentLongerThanMaxComponentAsPath_BrowserDoesNotThrowException(string path)
+        {
+            DirectoryInfo result = Create(path);
+            Assert.True(Directory.Exists(path));
+        }
 
         [Theory, MemberData(nameof(PathsWithInvalidColons))]
         [PlatformSpecific(TestPlatforms.Windows)]
index 386b847..00d5c46 100644 (file)
@@ -244,6 +244,7 @@ namespace System.IO.Tests
         }
 
         [Fact]
+        [ActiveIssue("https://github.com/dotnet/runtime/issues/40536", TestPlatforms.Browser)]
         public void RecursiveDeleteWithTrailingSlash()
         {
             DirectoryInfo testDir = Directory.CreateDirectory(GetTestFilePath());
index 04b1411..44d07e2 100644 (file)
@@ -390,7 +390,7 @@ namespace System.IO.Tests
         }
 
         [Fact]
-        [PlatformSpecific(TestPlatforms.AnyUnix)]  // Makes call to native code (libc)
+        [PlatformSpecific(TestPlatforms.AnyUnix & ~TestPlatforms.Browser)]  // Makes call to native code (libc)
         public void FalseForNonRegularFile()
         {
             string fileName = GetTestFilePath();
index 3dcd99c..c5a145c 100644 (file)
@@ -173,6 +173,7 @@ namespace System.IO.Tests
         }
 
         [Fact]
+        [ActiveIssue("https://github.com/dotnet/runtime/issues/40536", TestPlatforms.Browser)]
         public void TrailingDirectorySeparators()
         {
             string testDirSource = Path.Combine(TestDirectory, GetTestFileName());
index 615bd4c..1be2524 100644 (file)
@@ -110,7 +110,7 @@ namespace System.IO.Tests
         }
 
         [Fact]
-        [PlatformSpecific(TestPlatforms.AnyUnix)]  // Uses P/Invokes
+        [PlatformSpecific(TestPlatforms.AnyUnix & ~TestPlatforms.Browser)]  // Uses P/Invokes
         public void FalseForNonRegularFile()
         {
             string fileName = GetTestFilePath();
index e5e5478..fba22eb 100644 (file)
@@ -24,6 +24,7 @@ namespace System.IO.Tests
         #region UniversalTests
 
         [Fact]
+        [ActiveIssue("https://github.com/dotnet/runtime/issues/40536", TestPlatforms.Browser)]
         public void DirectoryPathUpdatesOnMove()
         {
             //NOTE: MoveTo adds a trailing separator character to the FullName of a DirectoryInfo
index 52e08f5..3002175 100644 (file)
@@ -8,6 +8,7 @@ namespace System.IO.Tests
     public class DirectoryInfo_Name : FileSystemTest
     {
         [Fact]
+        [ActiveIssue("https://github.com/dotnet/runtime/issues/39998", TestPlatforms.Browser)]
         public void CurrentDirectory()
         {
             var info = new DirectoryInfo(".");
index 2c330cb..675b86c 100644 (file)
@@ -102,6 +102,7 @@ namespace System.IO.Tests
         }
 
     [Fact]
+    [ActiveIssue("https://github.com/dotnet/runtime/issues/40531", TestPlatforms.Browser)]
     public void VariableLengthFileNames_AllCreatableFilesAreEnumerable()
     {
         DirectoryInfo testDirectory = Directory.CreateDirectory(GetTestFilePath());
@@ -119,6 +120,7 @@ namespace System.IO.Tests
     }
 
     [Fact]
+    [ActiveIssue("https://github.com/dotnet/runtime/issues/40531", TestPlatforms.Browser)]
     public void VariableLengthDirectoryNames_AllCreatableDirectoriesAreEnumerable()
     {
         DirectoryInfo testDirectory = Directory.CreateDirectory(GetTestFilePath());
index 9da51a7..e0b6957 100644 (file)
@@ -108,6 +108,7 @@ namespace System.IO.Tests
 
         [Theory]
         [MemberData(nameof(CopyFileWithData_MemberData))]
+        [ActiveIssue("https://github.com/dotnet/runtime/issues/40543", TestPlatforms.Browser)]
         public void CopyFileWithData(char[] data, bool readOnly)
         {
             string testFileSource = GetTestFilePath();
@@ -140,7 +141,10 @@ namespace System.IO.Tests
             }
 
             // Ensure last write/access time on the new file is appropriate
-            Assert.InRange(File.GetLastWriteTimeUtc(testFileDest), lastWriteTime.AddSeconds(-1), lastWriteTime.AddSeconds(1));
+            if (PlatformDetection.IsNotBrowser) // There is only one write time on browser vfs
+            {
+                Assert.InRange(File.GetLastWriteTimeUtc(testFileDest), lastWriteTime.AddSeconds(-1), lastWriteTime.AddSeconds(1));
+            }
 
             Assert.Equal(readOnly, (File.GetAttributes(testFileDest) & FileAttributes.ReadOnly) != 0);
             if (readOnly)
index 405d1f9..447bb32 100644 (file)
@@ -111,6 +111,7 @@ namespace System.IO.Tests
         }
 
         [Fact]
+        [ActiveIssue("https://github.com/dotnet/runtime/issues/40065", TestPlatforms.Browser)]
         public void FileInUse()
         {
             DirectoryInfo testDir = Directory.CreateDirectory(GetTestFilePath());
@@ -144,7 +145,12 @@ namespace System.IO.Tests
             Assert.True(File.Exists(testFile));
         }
 
+        #endregion
+
+        #region PlatformSpecific
+
         [Fact]
+        [PlatformSpecific(~TestPlatforms.Browser)] // Browser platform volume does not limit segments
         public void LongPathSegment()
         {
             DirectoryInfo testDir = Directory.CreateDirectory(GetTestFilePath());
@@ -153,10 +159,6 @@ namespace System.IO.Tests
               Create(Path.Combine(testDir.FullName, new string('a', 300))));
         }
 
-        #endregion
-
-        #region PlatformSpecific
-
         [Fact]
         [PlatformSpecific(TestPlatforms.AnyUnix)]
         public void LongDirectoryName()
index 40d5ebc..225ed8e 100644 (file)
@@ -247,7 +247,7 @@ namespace System.IO.Tests
         }
 
         [Fact]
-        [PlatformSpecific(TestPlatforms.AnyUnix)]  // Uses P/Invokes
+        [PlatformSpecific(TestPlatforms.AnyUnix & ~TestPlatforms.Browser)]  // Uses P/Invokes
         public void FalseForNonRegularFile()
         {
             string fileName = GetTestFilePath();
index a7840eb..07140ac 100644 (file)
@@ -13,7 +13,7 @@ namespace System.IO.Tests
     {
         // OSX has the limitation of setting upto 2262-04-11T23:47:16 (long.Max) date.
         // 32bit Unix has time_t up to ~ 2038.
-        private static bool SupportsLongMaxDateTime => PlatformDetection.IsWindows || (RuntimeInformation.ProcessArchitecture != Architecture.Arm && RuntimeInformation.ProcessArchitecture != Architecture.X86 && !PlatformDetection.IsOSXLike);
+        private static bool SupportsLongMaxDateTime => PlatformDetection.IsWindows || (!PlatformDetection.Is32BitProcess && !PlatformDetection.IsOSXLike);
 
         protected override string GetExistingItem()
         {
@@ -135,6 +135,7 @@ namespace System.IO.Tests
         }
 
         [ConditionalFact(nameof(isNotHFS))] // OSX HFS driver format does not support nanosecond granularity.
+        [ActiveIssue("https://github.com/dotnet/runtime/issues/40532", TestPlatforms.Browser)]
         public void SetUptoNanoseconds()
         {
             string file = GetTestFilePath();
index b6b4796..a5d9b5e 100644 (file)
@@ -80,6 +80,7 @@ namespace System.IO.Tests
         }
 
         [Fact]
+        [ActiveIssue("https://github.com/dotnet/runtime/issues/40065", TestPlatforms.Browser)]
         public void OpenFile_ThrowsIOException()
         {
             string path = GetTestFilePath();
@@ -105,7 +106,7 @@ namespace System.IO.Tests
             try
             {
                 // Operation succeeds when being run by the Unix superuser
-                if (!OperatingSystem.IsWindows() && geteuid() == 0)
+                if (PlatformDetection.IsSuperUser)
                 {
                     File.WriteAllBytes(path, Encoding.UTF8.GetBytes("text"));
                     Assert.Equal(Encoding.UTF8.GetBytes("text"), File.ReadAllBytes(path));
index 598fc01..3c46acf 100644 (file)
@@ -94,6 +94,7 @@ namespace System.IO.Tests
         }
 
         [Fact]
+        [ActiveIssue("https://github.com/dotnet/runtime/issues/40065", TestPlatforms.Browser)]
         public async Task OpenFile_ThrowsIOExceptionAsync()
         {
             string path = GetTestFilePath();
@@ -119,7 +120,7 @@ namespace System.IO.Tests
             try
             {
                 // Operation succeeds when being run by the Unix superuser
-                if (!OperatingSystem.IsWindows() && geteuid() == 0)
+                if (PlatformDetection.IsSuperUser)
                 {
                     await File.WriteAllBytesAsync(path, Encoding.UTF8.GetBytes("text"));
                     Assert.Equal(Encoding.UTF8.GetBytes("text"), await File.ReadAllBytesAsync(path));
index d5ef0ee..62ff393 100644 (file)
@@ -78,6 +78,7 @@ namespace System.IO.Tests
         }
 
         [Fact]
+        [ActiveIssue("https://github.com/dotnet/runtime/issues/40065", TestPlatforms.Browser)]
         public void OpenFile_ThrowsIOException()
         {
             string path = GetTestFilePath();
@@ -111,7 +112,7 @@ namespace System.IO.Tests
             try
             {
                 // Operation succeeds when being run by the Unix superuser
-                if (!OperatingSystem.IsWindows() && geteuid() == 0)
+                if (PlatformDetection.IsSuperUser)
                 {
                     Write(path, new string[] { "text" });
                     Assert.Equal(new string[] { "text" }, Read(path));
@@ -266,6 +267,7 @@ namespace System.IO.Tests
         }
 
         [Fact]
+        [ActiveIssue("https://github.com/dotnet/runtime/issues/40065", TestPlatforms.Browser)]
         public void OpenFile_ThrowsIOException()
         {
             string path = GetTestFilePath();
@@ -299,7 +301,7 @@ namespace System.IO.Tests
             try
             {
                 // Operation succeeds when being run by the Unix superuser
-                if (!OperatingSystem.IsWindows() && geteuid() == 0)
+                if (PlatformDetection.IsSuperUser)
                 {
                     Write(path, new string[] { "text" });
                     Assert.Equal(new string[] { "text" }, Read(path));
index 87b3ad7..d717e28 100644 (file)
@@ -76,6 +76,7 @@ namespace System.IO.Tests
         }
 
         [Fact]
+        [ActiveIssue("https://github.com/dotnet/runtime/issues/40065", TestPlatforms.Browser)]
         public async Task OpenFile_ThrowsIOExceptionAsync()
         {
             string path = GetTestFilePath();
@@ -106,7 +107,7 @@ namespace System.IO.Tests
             try
             {
                 // Operation succeeds when being run by the Unix superuser
-                if (!OperatingSystem.IsWindows() && geteuid() == 0)
+                if (PlatformDetection.IsSuperUser)
                 {
                     await WriteAsync(path, new string[] { "text" });
                     Assert.Equal(new string[] { "text" }, await ReadAsync(path));
index e511b69..9d330b2 100644 (file)
@@ -85,6 +85,7 @@ namespace System.IO.Tests
         }
 
         [Fact]
+        [ActiveIssue("https://github.com/dotnet/runtime/issues/40065", TestPlatforms.Browser)]
         public void OpenFile_ThrowsIOException()
         {
             string path = GetTestFilePath();
@@ -118,7 +119,7 @@ namespace System.IO.Tests
             try
             {
                 // Operation succeeds when being run by the Unix superuser
-                if (!OperatingSystem.IsWindows() && geteuid() == 0)
+                if (PlatformDetection.IsSuperUser)
                 {
                     Write(path, "text");
                     Assert.Equal("text", Read(path));
index 3381398..ac77b25 100644 (file)
@@ -84,6 +84,7 @@ namespace System.IO.Tests
         }
 
         [Fact]
+        [ActiveIssue("https://github.com/dotnet/runtime/issues/40065", TestPlatforms.Browser)]
         public async Task OpenFile_ThrowsIOExceptionAsync()
         {
             string path = GetTestFilePath();
@@ -114,7 +115,7 @@ namespace System.IO.Tests
             try
             {
                 // Operation succeeds when being run by the Unix superuser
-                if (!OperatingSystem.IsWindows() && geteuid() == 0)
+                if (PlatformDetection.IsSuperUser)
                 {
                     await WriteAsync(path, "text");
                     Assert.Equal("text", await ReadAsync(path));
index 777a544..b0f1779 100644 (file)
@@ -91,7 +91,7 @@ namespace System.IO.Tests
         }
 
         [Fact]
-        [PlatformSpecific(TestPlatforms.AnyUnix)]  // Uses P/Invokes
+        [PlatformSpecific(TestPlatforms.AnyUnix & ~TestPlatforms.Browser)]  // Uses P/Invokes
         public void TrueForNonRegularFile()
         {
             string fileName = GetTestFilePath();
index b27adf5..27b2e84 100644 (file)
@@ -104,6 +104,7 @@ namespace System.IO.Tests
         }
 
         [ConditionalFact(nameof(isNotHFS))]
+        [ActiveIssue("https://github.com/dotnet/runtime/issues/40530", TestPlatforms.Browser)]
         public void CopyToMillisecondPresent()
         {
             FileInfo input = GetNonZeroMilliseconds();
@@ -118,6 +119,7 @@ namespace System.IO.Tests
         }
 
         [ConditionalFact(nameof(isNotHFS))]
+        [ActiveIssue("https://github.com/dotnet/runtime/issues/40530", TestPlatforms.Browser)]
         public void CopyToNanosecondsPresent()
         {
             FileInfo input = GetNonZeroNanoseconds();
@@ -160,6 +162,7 @@ namespace System.IO.Tests
         }
 
         [ConditionalFact(nameof(isNotHFS))]
+        [ActiveIssue("https://github.com/dotnet/runtime/issues/40530", TestPlatforms.Browser)]
         public void MoveToMillisecondPresent()
         {
             FileInfo input = GetNonZeroMilliseconds();
index 0bf573c..bb1c783 100644 (file)
@@ -43,6 +43,7 @@ namespace System.IO.Tests
         }
 
         [Fact]
+        [PlatformSpecific(~TestPlatforms.Browser)] // IO.Pipes not supported
         public void CanSeekReturnsFalseForPipe()
         {
             using (var pipeStream = new AnonymousPipeServerStream())
index da71457..6141240 100644 (file)
@@ -177,6 +177,7 @@ namespace System.IO.Tests
 
         [Theory]
         [InlineData(10, 1024)]
+        [PlatformSpecific(~TestPlatforms.Browser)] // IO.Pipes not supported
         public async Task AnonymousPipeViaFileStream_AllDataCopied(int writeSize, int numWrites)
         {
             long totalLength = writeSize * numWrites;
index ba96528..b955208 100644 (file)
@@ -135,6 +135,7 @@ namespace System.IO.Tests
         [InlineData(null)]
         [InlineData(false)]
         [InlineData(true)]
+        [PlatformSpecific(~TestPlatforms.Browser)] // IO.Pipes not supported
         public void FlushCanBeUsedOnPipes_Success(bool? flushToDisk)
         {
             using (var pipeStream = new AnonymousPipeServerStream(PipeDirection.In))
index 7c6f08e..fd366dc 100644 (file)
@@ -15,6 +15,7 @@ namespace System.IO.Tests
         [Theory]
         [InlineData(true)]
         [InlineData(false)]
+        [PlatformSpecific(~TestPlatforms.Browser)] // IO.Pipes not supported
         public async Task AnonymousPipeWriteViaFileStream(bool asyncWrites)
         {
             using (var server = new AnonymousPipeServerStream(PipeDirection.In))
@@ -70,6 +71,7 @@ namespace System.IO.Tests
         [Theory]
         [InlineData(true)]
         [InlineData(false)]
+        [PlatformSpecific(~TestPlatforms.Browser)] // IO.Pipes not supported
         public async Task AnonymousPipeReadViaFileStream(bool asyncReads)
         {
             using (var server = new AnonymousPipeServerStream(PipeDirection.Out))
index f6b7416..4d66807 100644 (file)
@@ -23,7 +23,7 @@ namespace System.IO.Tests
             Assert.Throws<ObjectDisposedException>(() => fs.Write(new Span<byte>(new byte[1])));
         }
 
-        [Fact]
+        [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] // Browser PNSE: Cannot wait on monitors
         public void EmptyFile_Read_Succeeds()
         {
             using (var fs = CreateFileStream(GetTestFilePath(), FileMode.Create))
@@ -46,7 +46,7 @@ namespace System.IO.Tests
             }
         }
 
-        [Fact]
+        [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] // Browser PNSE: Cannot wait on monitors
         public void NonEmptyFile_Read_GetsExpectedData()
         {
             string fileName = GetTestFilePath();
@@ -111,7 +111,7 @@ namespace System.IO.Tests
             }
         }
 
-        [Fact]
+        [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] // Browser PNSE: Cannot wait on monitors
         public void NonEmptyWrite_WritesExpectedData()
         {
             using (var fs = CreateFileStream(GetTestFilePath(), FileMode.Create))
index 5f60690..7b236db 100644 (file)
@@ -276,7 +276,7 @@ namespace System.IO.Tests
             }
         }
 
-        [Fact]
+        [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] // Browser PNSE: Cannot wait on monitors
         public Task ManyConcurrentWriteAsyncs()
         {
             // For inner loop, just test one case
index b719725..805354e 100644 (file)
@@ -121,6 +121,7 @@ namespace System.IO.Tests
         [Theory]
         [InlineData(FileMode.Create)]
         [InlineData(FileMode.Truncate)]
+        [ActiveIssue("https://github.com/dotnet/runtime/issues/40065", TestPlatforms.Browser)]
         public void NoTruncateOnFileShareViolation(FileMode fileMode)
         {
             string fileName = GetTestFilePath();
index 6f1abef..e0d6191 100644 (file)
@@ -40,6 +40,7 @@ namespace System.IO.Tests
         }
 
         [Fact]
+        [ActiveIssue("https://github.com/dotnet/runtime/issues/40065", TestPlatforms.Browser)]
         public void FileShareWithoutWriteThrows()
         {
             string fileName = GetTestFilePath();
diff --git a/src/libraries/System.IO.FileSystem/tests/FileSystemTest.Browser.cs b/src/libraries/System.IO.FileSystem/tests/FileSystemTest.Browser.cs
new file mode 100644 (file)
index 0000000..afaa1cc
--- /dev/null
@@ -0,0 +1,16 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+using System.Runtime.InteropServices;
+using Xunit;
+
+namespace System.IO.Tests
+{
+    public abstract partial class FileSystemTest
+    {
+        protected static int mkfifo(string path, int mode)
+        {
+            throw new PlatformNotSupportedException();
+        }
+    }
+}
index e0769d4..7115d41 100644 (file)
     <Compile Include="Enumeration\ExampleTests.cs" />
     <Compile Include="Enumeration\RemovedDirectoryTests.cs" />
   </ItemGroup>
-  <ItemGroup Condition="'$(TargetsUnix)' == 'true' or '$(TargetsBrowser)' == 'true'">
+  <ItemGroup Condition="'$(TargetsUnix)' == 'true'">
     <Compile Include="FileSystemTest.Unix.cs" />
   </ItemGroup>
   <ItemGroup Condition="'$(TargetsWindows)' == 'true'">
     <Compile Include="FileSystemTest.Windows.cs" />
   </ItemGroup>
+  <ItemGroup Condition="'$(TargetsBrowser)' == 'true'">
+    <Compile Include="FileSystemTest.Browser.cs" />
+  </ItemGroup>  
   <ItemGroup>
     <!-- Rewritten -->
     <Compile Include="DirectoryInfo\GetSetAttributes.cs" />
index f23da73..4a08c3f 100644 (file)
@@ -696,13 +696,13 @@ namespace System.IO.MemoryMappedFiles.Tests
         public void WriteToReadOnlyFile_ReadWrite(MemoryMappedFileAccess access)
         {
             WriteToReadOnlyFile(access, access == MemoryMappedFileAccess.Read ||
-                            (!OperatingSystem.IsWindows() && PlatformDetection.IsSuperUser));
+                            PlatformDetection.IsSuperUser);
         }
 
         [Fact]
         public void WriteToReadOnlyFile_CopyOnWrite()
         {
-            WriteToReadOnlyFile(MemoryMappedFileAccess.CopyOnWrite, (!OperatingSystem.IsWindows() && PlatformDetection.IsSuperUser));
+            WriteToReadOnlyFile(MemoryMappedFileAccess.CopyOnWrite, PlatformDetection.IsSuperUser);
         }
 
         /// <summary>
index 9ba9856..28cee27 100644 (file)
@@ -25,7 +25,6 @@
     <!-- Mono-Browser ignores runtimeconfig.template.json (e.g. for this it has "System.Globalization.EnforceJapaneseEraYearRanges": true) -->
     <ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Globalization.Calendars\tests\CalendarTestWithConfigSwitch\System.Globalization.CalendarsWithConfigSwitch.Tests.csproj" />
 
-    <ProjectExclusions Include="$(MSBuildThisFileDirectory)System.IO.FileSystem\tests\System.IO.FileSystem.Tests.csproj" />
     <ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Linq.Parallel\tests\System.Linq.Parallel.Tests.csproj" />
     <ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Net.Http\tests\FunctionalTests\System.Net.Http.Functional.Tests.csproj" />
     <ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Net.WebSockets.Client\tests\System.Net.WebSockets.Client.Tests.csproj" />