From 8ca198540568b8227686278dca2ed01d05e07918 Mon Sep 17 00:00:00 2001 From: Kenneth Pouncey Date: Wed, 22 Jul 2020 12:40:27 +0200 Subject: [PATCH 01/37] [browser][file system] Tests System.IO.FileSystem --- .../tests/Base/BaseGetSetTimes.cs | 2 ++ .../tests/Directory/CreateDirectory.cs | 1 + .../tests/Directory/Delete.cs | 1 + .../tests/Directory/Exists.cs | 2 +- .../Directory/GetFileSystemEntries_str.cs | 1 + .../tests/Directory/Move.cs | 3 +++ .../tests/DirectoryInfo/Exists.cs | 2 +- .../tests/DirectoryInfo/MoveTo.cs | 1 + .../tests/DirectoryInfo/Name.cs | 1 + .../tests/Enumeration/ErrorHandlingTests.cs | 3 +++ .../tests/Enumeration/SkipAttributeTests.cs | 1 + .../Enumeration/SpecialDirectoryTests.cs | 1 + .../System.IO.FileSystem/tests/File/Copy.cs | 1 + .../System.IO.FileSystem/tests/File/Create.cs | 2 ++ .../System.IO.FileSystem/tests/File/Exists.cs | 2 +- .../tests/File/GetSetTimes.cs | 3 ++- .../tests/File/ReadWriteAllBytes.cs | 3 ++- .../tests/File/ReadWriteAllBytesAsync.cs | 3 ++- .../tests/File/ReadWriteAllLines.cs | 6 ++++-- .../tests/File/ReadWriteAllLinesAsync.cs | 3 ++- .../tests/File/ReadWriteAllText.cs | 3 ++- .../tests/File/ReadWriteAllTextAsync.cs | 3 ++- .../tests/FileInfo/Exists.cs | 2 +- .../tests/FileInfo/GetSetTimes.cs | 3 +++ .../tests/FileStream/CanSeek.cs | 1 + .../tests/FileStream/CopyToAsync.cs | 1 + .../tests/FileStream/Flush.cs | 1 + .../tests/FileStream/Pipes.cs | 2 ++ .../tests/FileStream/ReadWriteSpan.cs | 3 +++ .../tests/FileStream/SafeFileHandle.cs | 1 + .../tests/FileStream/WriteAsync.cs | 1 + .../tests/FileStream/ctor_str_fm_fa_fs.cs | 1 + .../FileStream/ctor_str_fm_fa_fs.write.cs | 1 + .../tests/FileSystemTest.Browser.cs | 21 +++++++++++++++++++ .../tests/System.IO.FileSystem.Tests.csproj | 5 ++++- 35 files changed, 78 insertions(+), 13 deletions(-) create mode 100644 src/libraries/System.IO.FileSystem/tests/FileSystemTest.Browser.cs diff --git a/src/libraries/System.IO.FileSystem/tests/Base/BaseGetSetTimes.cs b/src/libraries/System.IO.FileSystem/tests/Base/BaseGetSetTimes.cs index 58a515e0b7d43d..a4232bfb7eef25 100644 --- a/src/libraries/System.IO.FileSystem/tests/Base/BaseGetSetTimes.cs +++ b/src/libraries/System.IO.FileSystem/tests/Base/BaseGetSetTimes.cs @@ -41,6 +41,7 @@ public static TimeFunction Create(SetTime setter, GetTime getter, DateTimeKind k } [Fact] + [PlatformSpecific(~TestPlatforms.Browser)] public void SettingUpdatesProperties() { T item = GetExistingItem(); @@ -77,6 +78,7 @@ public void CanGetAllTimesAfterCreation() } [ConditionalFact(nameof(isNotHFS))] // OSX HFS driver format does not support millisec granularity + [PlatformSpecific(~TestPlatforms.Browser)] public void TimesIncludeMillisecondPart() { T item = GetExistingItem(); diff --git a/src/libraries/System.IO.FileSystem/tests/Directory/CreateDirectory.cs b/src/libraries/System.IO.FileSystem/tests/Directory/CreateDirectory.cs index 5b3b2dcbf79b12..e6779e50acc790 100644 --- a/src/libraries/System.IO.FileSystem/tests/Directory/CreateDirectory.cs +++ b/src/libraries/System.IO.FileSystem/tests/Directory/CreateDirectory.cs @@ -213,6 +213,7 @@ public void DirectoryEqualToMaxDirectory_CanBeCreatedAllAtOnce() [Theory, MemberData(nameof(PathsWithComponentLongerThanMaxComponent))] + [PlatformSpecific(~TestPlatforms.Browser)] public void DirectoryWithComponentLongerThanMaxComponentAsPath_ThrowsException(string path) { AssertExtensions.ThrowsAny(() => Create(path)); diff --git a/src/libraries/System.IO.FileSystem/tests/Directory/Delete.cs b/src/libraries/System.IO.FileSystem/tests/Directory/Delete.cs index 3648f97ef4b87c..ca8c3f28bfe145 100644 --- a/src/libraries/System.IO.FileSystem/tests/Directory/Delete.cs +++ b/src/libraries/System.IO.FileSystem/tests/Directory/Delete.cs @@ -245,6 +245,7 @@ public void RecursiveDelete() } [Fact] + [PlatformSpecific(~TestPlatforms.Browser)] public void RecursiveDeleteWithTrailingSlash() { DirectoryInfo testDir = Directory.CreateDirectory(GetTestFilePath()); diff --git a/src/libraries/System.IO.FileSystem/tests/Directory/Exists.cs b/src/libraries/System.IO.FileSystem/tests/Directory/Exists.cs index cfe5834f53d375..b91fab991a786f 100644 --- a/src/libraries/System.IO.FileSystem/tests/Directory/Exists.cs +++ b/src/libraries/System.IO.FileSystem/tests/Directory/Exists.cs @@ -391,7 +391,7 @@ public void SubdirectoryOnNonExistentDriveAsPath_ReturnsFalse() } [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(); diff --git a/src/libraries/System.IO.FileSystem/tests/Directory/GetFileSystemEntries_str.cs b/src/libraries/System.IO.FileSystem/tests/Directory/GetFileSystemEntries_str.cs index a9fbc242833c29..7a1fd58df6ea5f 100644 --- a/src/libraries/System.IO.FileSystem/tests/Directory/GetFileSystemEntries_str.cs +++ b/src/libraries/System.IO.FileSystem/tests/Directory/GetFileSystemEntries_str.cs @@ -175,6 +175,7 @@ public void TrailingSlashes() } [Fact] + [PlatformSpecific(~TestPlatforms.Browser)] public void HiddenFilesAreReturned() { // Note that APIs that take EnumerationOptions do NOT find hidden files by default diff --git a/src/libraries/System.IO.FileSystem/tests/Directory/Move.cs b/src/libraries/System.IO.FileSystem/tests/Directory/Move.cs index 3dcd99c3a44cf0..9564717d057bd6 100644 --- a/src/libraries/System.IO.FileSystem/tests/Directory/Move.cs +++ b/src/libraries/System.IO.FileSystem/tests/Directory/Move.cs @@ -33,6 +33,7 @@ public void EmptyPath() } [Fact] + [PlatformSpecific(~TestPlatforms.Browser)] public void NonExistentDirectory() { DirectoryInfo valid = Directory.CreateDirectory(GetTestFilePath()); @@ -173,6 +174,7 @@ public void DirectoryNameWithSpaces() } [Fact] + [PlatformSpecific(~TestPlatforms.Browser)] public void TrailingDirectorySeparators() { string testDirSource = Path.Combine(TestDirectory, GetTestFileName()); @@ -200,6 +202,7 @@ public void IncludeSubdirectories() } [Fact] + [PlatformSpecific(~TestPlatforms.Browser)] public void Path_Longer_Than_MaxLongPath_Throws_Exception() { string testDir = GetTestFilePath(); diff --git a/src/libraries/System.IO.FileSystem/tests/DirectoryInfo/Exists.cs b/src/libraries/System.IO.FileSystem/tests/DirectoryInfo/Exists.cs index 9438d2ab3875ff..4383e2787b7bfc 100644 --- a/src/libraries/System.IO.FileSystem/tests/DirectoryInfo/Exists.cs +++ b/src/libraries/System.IO.FileSystem/tests/DirectoryInfo/Exists.cs @@ -111,7 +111,7 @@ public void FalseForFile() } [Fact] - [PlatformSpecific(TestPlatforms.AnyUnix)] // Uses P/Invokes + [PlatformSpecific(TestPlatforms.AnyUnix & ~TestPlatforms.Browser)] // Uses P/Invokes public void FalseForNonRegularFile() { string fileName = GetTestFilePath(); diff --git a/src/libraries/System.IO.FileSystem/tests/DirectoryInfo/MoveTo.cs b/src/libraries/System.IO.FileSystem/tests/DirectoryInfo/MoveTo.cs index e5e5478fcb39df..1d6bac7ed0f537 100644 --- a/src/libraries/System.IO.FileSystem/tests/DirectoryInfo/MoveTo.cs +++ b/src/libraries/System.IO.FileSystem/tests/DirectoryInfo/MoveTo.cs @@ -24,6 +24,7 @@ protected virtual void Move(DirectoryInfo sourceDir, string destDir) #region UniversalTests [Fact] + [PlatformSpecific(~TestPlatforms.Browser)] public void DirectoryPathUpdatesOnMove() { //NOTE: MoveTo adds a trailing separator character to the FullName of a DirectoryInfo diff --git a/src/libraries/System.IO.FileSystem/tests/DirectoryInfo/Name.cs b/src/libraries/System.IO.FileSystem/tests/DirectoryInfo/Name.cs index 52e08f5c6a08fb..f35d1c86443272 100644 --- a/src/libraries/System.IO.FileSystem/tests/DirectoryInfo/Name.cs +++ b/src/libraries/System.IO.FileSystem/tests/DirectoryInfo/Name.cs @@ -8,6 +8,7 @@ namespace System.IO.Tests public class DirectoryInfo_Name : FileSystemTest { [Fact] + [PlatformSpecific(~TestPlatforms.Browser)] public void CurrentDirectory() { var info = new DirectoryInfo("."); diff --git a/src/libraries/System.IO.FileSystem/tests/Enumeration/ErrorHandlingTests.cs b/src/libraries/System.IO.FileSystem/tests/Enumeration/ErrorHandlingTests.cs index e6858057bf4f60..14725d63b017e2 100644 --- a/src/libraries/System.IO.FileSystem/tests/Enumeration/ErrorHandlingTests.cs +++ b/src/libraries/System.IO.FileSystem/tests/Enumeration/ErrorHandlingTests.cs @@ -68,6 +68,7 @@ public void OpenErrorDoesNotHappenAgainOnMoveNext() } [Fact] + [PlatformSpecific(~TestPlatforms.Browser)] public void NotFoundErrorIsExpected() { // Make sure we're returning the native error as expected (and not the PAL error on Unix) @@ -99,6 +100,7 @@ public void DeleteDirectoryAfterOpening() } [Fact] + [PlatformSpecific(~TestPlatforms.Browser)] public void VariableLengthFileNames_AllCreatableFilesAreEnumerable() { DirectoryInfo testDirectory = Directory.CreateDirectory(GetTestFilePath()); @@ -116,6 +118,7 @@ public void VariableLengthFileNames_AllCreatableFilesAreEnumerable() } [Fact] + [PlatformSpecific(~TestPlatforms.Browser)] public void VariableLengthDirectoryNames_AllCreatableDirectoriesAreEnumerable() { DirectoryInfo testDirectory = Directory.CreateDirectory(GetTestFilePath()); diff --git a/src/libraries/System.IO.FileSystem/tests/Enumeration/SkipAttributeTests.cs b/src/libraries/System.IO.FileSystem/tests/Enumeration/SkipAttributeTests.cs index 3a22c61b6f77e6..cac01bc3364f73 100644 --- a/src/libraries/System.IO.FileSystem/tests/Enumeration/SkipAttributeTests.cs +++ b/src/libraries/System.IO.FileSystem/tests/Enumeration/SkipAttributeTests.cs @@ -21,6 +21,7 @@ protected virtual string[] GetPaths(string directory, EnumerationOptions options } [Fact] + [PlatformSpecific(~TestPlatforms.Browser)] public void SkippingHiddenFiles() { DirectoryInfo testDirectory = Directory.CreateDirectory(GetTestFilePath()); diff --git a/src/libraries/System.IO.FileSystem/tests/Enumeration/SpecialDirectoryTests.cs b/src/libraries/System.IO.FileSystem/tests/Enumeration/SpecialDirectoryTests.cs index 39a747179481a8..0831b8926f6cb2 100644 --- a/src/libraries/System.IO.FileSystem/tests/Enumeration/SpecialDirectoryTests.cs +++ b/src/libraries/System.IO.FileSystem/tests/Enumeration/SpecialDirectoryTests.cs @@ -56,6 +56,7 @@ protected virtual string[] GetNames(string directory, EnumerationOptions options } [Fact] + [PlatformSpecific(~TestPlatforms.Browser)] public void SkippingHiddenFiles() { // Files that begin with periods are considered hidden on Unix diff --git a/src/libraries/System.IO.FileSystem/tests/File/Copy.cs b/src/libraries/System.IO.FileSystem/tests/File/Copy.cs index 9da51a7cd6073e..c224e465dc7435 100644 --- a/src/libraries/System.IO.FileSystem/tests/File/Copy.cs +++ b/src/libraries/System.IO.FileSystem/tests/File/Copy.cs @@ -108,6 +108,7 @@ public static IEnumerable CopyFileWithData_MemberData() [Theory] [MemberData(nameof(CopyFileWithData_MemberData))] + [PlatformSpecific(~TestPlatforms.Browser)] public void CopyFileWithData(char[] data, bool readOnly) { string testFileSource = GetTestFilePath(); diff --git a/src/libraries/System.IO.FileSystem/tests/File/Create.cs b/src/libraries/System.IO.FileSystem/tests/File/Create.cs index 405d1f92ba6904..79aca5e04555cb 100644 --- a/src/libraries/System.IO.FileSystem/tests/File/Create.cs +++ b/src/libraries/System.IO.FileSystem/tests/File/Create.cs @@ -111,6 +111,7 @@ public void InvalidDirectory() } [Fact] + [PlatformSpecific(~TestPlatforms.Browser)] public void FileInUse() { DirectoryInfo testDir = Directory.CreateDirectory(GetTestFilePath()); @@ -145,6 +146,7 @@ public void OverwriteReadOnly() } [Fact] + [PlatformSpecific(~TestPlatforms.Browser)] public void LongPathSegment() { DirectoryInfo testDir = Directory.CreateDirectory(GetTestFilePath()); diff --git a/src/libraries/System.IO.FileSystem/tests/File/Exists.cs b/src/libraries/System.IO.FileSystem/tests/File/Exists.cs index 40d5ebce3d4b77..225ed8e04e8925 100644 --- a/src/libraries/System.IO.FileSystem/tests/File/Exists.cs +++ b/src/libraries/System.IO.FileSystem/tests/File/Exists.cs @@ -247,7 +247,7 @@ public void DirectoryWithComponentLongerThanMaxComponentAsPath_ReturnsFalse(stri } [Fact] - [PlatformSpecific(TestPlatforms.AnyUnix)] // Uses P/Invokes + [PlatformSpecific(TestPlatforms.AnyUnix & ~TestPlatforms.Browser)] // Uses P/Invokes public void FalseForNonRegularFile() { string fileName = GetTestFilePath(); diff --git a/src/libraries/System.IO.FileSystem/tests/File/GetSetTimes.cs b/src/libraries/System.IO.FileSystem/tests/File/GetSetTimes.cs index a7840ebf949193..e99d7def06ae54 100644 --- a/src/libraries/System.IO.FileSystem/tests/File/GetSetTimes.cs +++ b/src/libraries/System.IO.FileSystem/tests/File/GetSetTimes.cs @@ -13,7 +13,7 @@ public class File_GetSetTimes : StaticGetSetTimes { // 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 || (RuntimeInformation.ProcessArchitecture != Architecture.Arm && RuntimeInformation.ProcessArchitecture != Architecture.X86 && !PlatformDetection.IsOSXLike && !PlatformDetection.IsBrowser); protected override string GetExistingItem() { @@ -135,6 +135,7 @@ public void SetLastWriteTimeTicks() } [ConditionalFact(nameof(isNotHFS))] // OSX HFS driver format does not support nanosecond granularity. + [PlatformSpecific(~TestPlatforms.Browser)] public void SetUptoNanoseconds() { string file = GetTestFilePath(); diff --git a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllBytes.cs b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllBytes.cs index 33c10d40b84784..f67f457d7bbaec 100644 --- a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllBytes.cs +++ b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllBytes.cs @@ -81,6 +81,7 @@ public void Overwrite() } [Fact] + [PlatformSpecific(~TestPlatforms.Browser)] public void OpenFile_ThrowsIOException() { string path = GetTestFilePath(); @@ -106,7 +107,7 @@ public void WriteToReadOnlyFile() try { // Operation succeeds when being run by the Unix superuser - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && geteuid() == 0) + if ((!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !RuntimeInformation.IsOSPlatform(OSPlatform.Browser)) && geteuid() == 0) { File.WriteAllBytes(path, Encoding.UTF8.GetBytes("text")); Assert.Equal(Encoding.UTF8.GetBytes("text"), File.ReadAllBytes(path)); diff --git a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllBytesAsync.cs b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllBytesAsync.cs index 30fc35e97b1e7a..2a5a5d573e2542 100644 --- a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllBytesAsync.cs +++ b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllBytesAsync.cs @@ -95,6 +95,7 @@ public async Task OverwriteAsync() } [Fact] + [PlatformSpecific(~TestPlatforms.Browser)] public async Task OpenFile_ThrowsIOExceptionAsync() { string path = GetTestFilePath(); @@ -120,7 +121,7 @@ public async Task WriteToReadOnlyFileAsync() try { // Operation succeeds when being run by the Unix superuser - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && geteuid() == 0) + if ((!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !RuntimeInformation.IsOSPlatform(OSPlatform.Browser)) && geteuid() == 0) { await File.WriteAllBytesAsync(path, Encoding.UTF8.GetBytes("text")); Assert.Equal(Encoding.UTF8.GetBytes("text"), await File.ReadAllBytesAsync(path)); diff --git a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllLines.cs b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllLines.cs index 89ede8680ce5f3..458398e648755a 100644 --- a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllLines.cs +++ b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllLines.cs @@ -79,6 +79,7 @@ public virtual void Overwrite() } [Fact] + [PlatformSpecific(~TestPlatforms.Browser)] public void OpenFile_ThrowsIOException() { string path = GetTestFilePath(); @@ -112,7 +113,7 @@ public void WriteToReadOnlyFile() try { // Operation succeeds when being run by the Unix superuser - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && geteuid() == 0) + if ((!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !RuntimeInformation.IsOSPlatform(OSPlatform.Browser)) && geteuid() == 0) { Write(path, new string[] { "text" }); Assert.Equal(new string[] { "text" }, Read(path)); @@ -267,6 +268,7 @@ public virtual void Overwrite() } [Fact] + [PlatformSpecific(~TestPlatforms.Browser)] public void OpenFile_ThrowsIOException() { string path = GetTestFilePath(); @@ -300,7 +302,7 @@ public void WriteToReadOnlyFile() try { // Operation succeeds when being run by the Unix superuser - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && geteuid() == 0) + if ((!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !RuntimeInformation.IsOSPlatform(OSPlatform.Browser)) && geteuid() == 0) { Write(path, new string[] { "text" }); Assert.Equal(new string[] { "text" }, Read(path)); diff --git a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllLinesAsync.cs b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllLinesAsync.cs index 9a22ccc2c36cad..13bfbab2812aae 100644 --- a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllLinesAsync.cs +++ b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllLinesAsync.cs @@ -77,6 +77,7 @@ public virtual async Task OverwriteAsync() } [Fact] + [PlatformSpecific(~TestPlatforms.Browser)] public async Task OpenFile_ThrowsIOExceptionAsync() { string path = GetTestFilePath(); @@ -107,7 +108,7 @@ public async Task WriteToReadOnlyFile() try { // Operation succeeds when being run by the Unix superuser - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && geteuid() == 0) + if ((!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !RuntimeInformation.IsOSPlatform(OSPlatform.Browser)) && geteuid() == 0) { await WriteAsync(path, new string[] { "text" }); Assert.Equal(new string[] { "text" }, await ReadAsync(path)); diff --git a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllText.cs b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllText.cs index 152858cc92388a..fb0694c2cdac0a 100644 --- a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllText.cs +++ b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllText.cs @@ -86,6 +86,7 @@ public virtual void Overwrite() } [Fact] + [PlatformSpecific(~TestPlatforms.Browser)] public void OpenFile_ThrowsIOException() { string path = GetTestFilePath(); @@ -119,7 +120,7 @@ public void WriteToReadOnlyFile() try { // Operation succeeds when being run by the Unix superuser - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && geteuid() == 0) + if ((!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !RuntimeInformation.IsOSPlatform(OSPlatform.Browser)) && geteuid() == 0) { Write(path, "text"); Assert.Equal("text", Read(path)); diff --git a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllTextAsync.cs b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllTextAsync.cs index 3d2f1d9d8da6c3..4b005bfad6a028 100644 --- a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllTextAsync.cs +++ b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllTextAsync.cs @@ -85,6 +85,7 @@ public virtual async Task OverwriteAsync() } [Fact] + [PlatformSpecific(~TestPlatforms.Browser)] public async Task OpenFile_ThrowsIOExceptionAsync() { string path = GetTestFilePath(); @@ -115,7 +116,7 @@ public async Task WriteToReadOnlyFileAsync() try { // Operation succeeds when being run by the Unix superuser - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && geteuid() == 0) + if ((!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !RuntimeInformation.IsOSPlatform(OSPlatform.Browser)) && geteuid() == 0) { await WriteAsync(path, "text"); Assert.Equal("text", await ReadAsync(path)); diff --git a/src/libraries/System.IO.FileSystem/tests/FileInfo/Exists.cs b/src/libraries/System.IO.FileSystem/tests/FileInfo/Exists.cs index 777a5448afc76c..b0f1779745f613 100644 --- a/src/libraries/System.IO.FileSystem/tests/FileInfo/Exists.cs +++ b/src/libraries/System.IO.FileSystem/tests/FileInfo/Exists.cs @@ -91,7 +91,7 @@ public void FalseForDirectory() } [Fact] - [PlatformSpecific(TestPlatforms.AnyUnix)] // Uses P/Invokes + [PlatformSpecific(TestPlatforms.AnyUnix & ~TestPlatforms.Browser)] // Uses P/Invokes public void TrueForNonRegularFile() { string fileName = GetTestFilePath(); diff --git a/src/libraries/System.IO.FileSystem/tests/FileInfo/GetSetTimes.cs b/src/libraries/System.IO.FileSystem/tests/FileInfo/GetSetTimes.cs index b27adf59f27c85..bb9b3703eff3a8 100644 --- a/src/libraries/System.IO.FileSystem/tests/FileInfo/GetSetTimes.cs +++ b/src/libraries/System.IO.FileSystem/tests/FileInfo/GetSetTimes.cs @@ -104,6 +104,7 @@ public override IEnumerable TimeFunctions(bool requiresRoundtrippi } [ConditionalFact(nameof(isNotHFS))] + [PlatformSpecific(~TestPlatforms.Browser)] public void CopyToMillisecondPresent() { FileInfo input = GetNonZeroMilliseconds(); @@ -118,6 +119,7 @@ public void CopyToMillisecondPresent() } [ConditionalFact(nameof(isNotHFS))] + [PlatformSpecific(~TestPlatforms.Browser)] public void CopyToNanosecondsPresent() { FileInfo input = GetNonZeroNanoseconds(); @@ -160,6 +162,7 @@ public void MoveToMillisecondPresent_HFS() } [ConditionalFact(nameof(isNotHFS))] + [PlatformSpecific(~TestPlatforms.Browser)] public void MoveToMillisecondPresent() { FileInfo input = GetNonZeroMilliseconds(); diff --git a/src/libraries/System.IO.FileSystem/tests/FileStream/CanSeek.cs b/src/libraries/System.IO.FileSystem/tests/FileStream/CanSeek.cs index 0bf573c15cb85c..01ebcc9c51ab30 100644 --- a/src/libraries/System.IO.FileSystem/tests/FileStream/CanSeek.cs +++ b/src/libraries/System.IO.FileSystem/tests/FileStream/CanSeek.cs @@ -43,6 +43,7 @@ public void CanSeekFalseForDisposedStream() } [Fact] + [PlatformSpecific(~TestPlatforms.Browser)] public void CanSeekReturnsFalseForPipe() { using (var pipeStream = new AnonymousPipeServerStream()) diff --git a/src/libraries/System.IO.FileSystem/tests/FileStream/CopyToAsync.cs b/src/libraries/System.IO.FileSystem/tests/FileStream/CopyToAsync.cs index da7145719b90d1..9f90c7fe9ce6ce 100644 --- a/src/libraries/System.IO.FileSystem/tests/FileStream/CopyToAsync.cs +++ b/src/libraries/System.IO.FileSystem/tests/FileStream/CopyToAsync.cs @@ -177,6 +177,7 @@ public static IEnumerable File_AllDataCopied_MemberData() [Theory] [InlineData(10, 1024)] + [PlatformSpecific(~TestPlatforms.Browser)] public async Task AnonymousPipeViaFileStream_AllDataCopied(int writeSize, int numWrites) { long totalLength = writeSize * numWrites; diff --git a/src/libraries/System.IO.FileSystem/tests/FileStream/Flush.cs b/src/libraries/System.IO.FileSystem/tests/FileStream/Flush.cs index ba965283fb16b9..c2b096ec83b762 100644 --- a/src/libraries/System.IO.FileSystem/tests/FileStream/Flush.cs +++ b/src/libraries/System.IO.FileSystem/tests/FileStream/Flush.cs @@ -7,6 +7,7 @@ namespace System.IO.Tests { + [PlatformSpecific(~TestPlatforms.Browser)] public partial class FileStream_Flush : FileSystemTest { [Theory] diff --git a/src/libraries/System.IO.FileSystem/tests/FileStream/Pipes.cs b/src/libraries/System.IO.FileSystem/tests/FileStream/Pipes.cs index 7c6f08e2057ee0..bcd8b0be2adefe 100644 --- a/src/libraries/System.IO.FileSystem/tests/FileStream/Pipes.cs +++ b/src/libraries/System.IO.FileSystem/tests/FileStream/Pipes.cs @@ -15,6 +15,7 @@ public class Pipes : FileSystemTest [Theory] [InlineData(true)] [InlineData(false)] + [PlatformSpecific(~TestPlatforms.Browser)] public async Task AnonymousPipeWriteViaFileStream(bool asyncWrites) { using (var server = new AnonymousPipeServerStream(PipeDirection.In)) @@ -70,6 +71,7 @@ await Task.WhenAll( [Theory] [InlineData(true)] [InlineData(false)] + [PlatformSpecific(~TestPlatforms.Browser)] public async Task AnonymousPipeReadViaFileStream(bool asyncReads) { using (var server = new AnonymousPipeServerStream(PipeDirection.Out)) diff --git a/src/libraries/System.IO.FileSystem/tests/FileStream/ReadWriteSpan.cs b/src/libraries/System.IO.FileSystem/tests/FileStream/ReadWriteSpan.cs index f6b74164f5ac4c..43592e9b319aa5 100644 --- a/src/libraries/System.IO.FileSystem/tests/FileStream/ReadWriteSpan.cs +++ b/src/libraries/System.IO.FileSystem/tests/FileStream/ReadWriteSpan.cs @@ -24,6 +24,7 @@ public void DisposedStream_ReadWrite_Throws() } [Fact] + [PlatformSpecific(~TestPlatforms.Browser)] public void EmptyFile_Read_Succeeds() { using (var fs = CreateFileStream(GetTestFilePath(), FileMode.Create)) @@ -47,6 +48,7 @@ public void EmptyFile_Read_Succeeds() } [Fact] + [PlatformSpecific(~TestPlatforms.Browser)] public void NonEmptyFile_Read_GetsExpectedData() { string fileName = GetTestFilePath(); @@ -112,6 +114,7 @@ public void EmptyWrites_NoDataWritten() } [Fact] + [PlatformSpecific(~TestPlatforms.Browser)] public void NonEmptyWrite_WritesExpectedData() { using (var fs = CreateFileStream(GetTestFilePath(), FileMode.Create)) diff --git a/src/libraries/System.IO.FileSystem/tests/FileStream/SafeFileHandle.cs b/src/libraries/System.IO.FileSystem/tests/FileStream/SafeFileHandle.cs index 03b3353931724a..54c0fc94f13166 100644 --- a/src/libraries/System.IO.FileSystem/tests/FileStream/SafeFileHandle.cs +++ b/src/libraries/System.IO.FileSystem/tests/FileStream/SafeFileHandle.cs @@ -66,6 +66,7 @@ public async Task ThrowWhenHandlePositionIsChanged_sync() } [Fact] + [PlatformSpecific(~TestPlatforms.Browser)] public async Task ThrowWhenHandlePositionIsChanged_async() { await ThrowWhenHandlePositionIsChanged(useAsync: true); diff --git a/src/libraries/System.IO.FileSystem/tests/FileStream/WriteAsync.cs b/src/libraries/System.IO.FileSystem/tests/FileStream/WriteAsync.cs index 2710edcbf31068..f9b6067b01029c 100644 --- a/src/libraries/System.IO.FileSystem/tests/FileStream/WriteAsync.cs +++ b/src/libraries/System.IO.FileSystem/tests/FileStream/WriteAsync.cs @@ -278,6 +278,7 @@ public static IEnumerable MemberData_FileStreamAsyncWriting() } [Fact] + [PlatformSpecific(~TestPlatforms.Browser)] public Task ManyConcurrentWriteAsyncs() { // For inner loop, just test one case diff --git a/src/libraries/System.IO.FileSystem/tests/FileStream/ctor_str_fm_fa_fs.cs b/src/libraries/System.IO.FileSystem/tests/FileStream/ctor_str_fm_fa_fs.cs index b719725f2a4535..0cc73a9e33689d 100644 --- a/src/libraries/System.IO.FileSystem/tests/FileStream/ctor_str_fm_fa_fs.cs +++ b/src/libraries/System.IO.FileSystem/tests/FileStream/ctor_str_fm_fa_fs.cs @@ -121,6 +121,7 @@ public void FileShareOpenOrCreate() [Theory] [InlineData(FileMode.Create)] [InlineData(FileMode.Truncate)] + [PlatformSpecific(~TestPlatforms.Browser)] public void NoTruncateOnFileShareViolation(FileMode fileMode) { string fileName = GetTestFilePath(); diff --git a/src/libraries/System.IO.FileSystem/tests/FileStream/ctor_str_fm_fa_fs.write.cs b/src/libraries/System.IO.FileSystem/tests/FileStream/ctor_str_fm_fa_fs.write.cs index 6f1abef3d17ad5..155bc18b18f244 100644 --- a/src/libraries/System.IO.FileSystem/tests/FileStream/ctor_str_fm_fa_fs.write.cs +++ b/src/libraries/System.IO.FileSystem/tests/FileStream/ctor_str_fm_fa_fs.write.cs @@ -40,6 +40,7 @@ public void FileShareWriteExisting() } [Fact] + [PlatformSpecific(~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 index 00000000000000..7fdb83c3c19ece --- /dev/null +++ b/src/libraries/System.IO.FileSystem/tests/FileSystemTest.Browser.cs @@ -0,0 +1,21 @@ +// 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 geteuid() + { + throw new PlatformNotSupportedException(); + } + + protected static int mkfifo(string path, int mode) + { + throw new PlatformNotSupportedException(); + } + } +} diff --git a/src/libraries/System.IO.FileSystem/tests/System.IO.FileSystem.Tests.csproj b/src/libraries/System.IO.FileSystem/tests/System.IO.FileSystem.Tests.csproj index e0769d47d16a41..7115d412c07422 100644 --- a/src/libraries/System.IO.FileSystem/tests/System.IO.FileSystem.Tests.csproj +++ b/src/libraries/System.IO.FileSystem/tests/System.IO.FileSystem.Tests.csproj @@ -46,12 +46,15 @@ - + + + + From 1726ceaf42721169b7e4440f2a74249b538e1fc7 Mon Sep 17 00:00:00 2001 From: Kenneth Pouncey Date: Thu, 23 Jul 2020 06:26:11 +0200 Subject: [PATCH 02/37] Remove FileSystem from test project exclusions. --- src/libraries/tests.proj | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libraries/tests.proj b/src/libraries/tests.proj index 98273a01002a84..993827c404189f 100644 --- a/src/libraries/tests.proj +++ b/src/libraries/tests.proj @@ -29,7 +29,6 @@ - From 1497c02b8304306da196d9cf2373accccd90915c Mon Sep 17 00:00:00 2001 From: Kenneth Pouncey Date: Fri, 24 Jul 2020 08:31:11 +0200 Subject: [PATCH 03/37] [browser][filesystem] Comment on skipped tests due to IO.Pipes not supported --- .../System.IO.FileSystem/tests/FileStream/CanSeek.cs | 2 +- .../System.IO.FileSystem/tests/FileStream/CopyToAsync.cs | 2 +- src/libraries/System.IO.FileSystem/tests/FileStream/Flush.cs | 1 + src/libraries/System.IO.FileSystem/tests/FileStream/Pipes.cs | 4 ++-- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/libraries/System.IO.FileSystem/tests/FileStream/CanSeek.cs b/src/libraries/System.IO.FileSystem/tests/FileStream/CanSeek.cs index 01ebcc9c51ab30..bb1c7836e95e79 100644 --- a/src/libraries/System.IO.FileSystem/tests/FileStream/CanSeek.cs +++ b/src/libraries/System.IO.FileSystem/tests/FileStream/CanSeek.cs @@ -43,7 +43,7 @@ public void CanSeekFalseForDisposedStream() } [Fact] - [PlatformSpecific(~TestPlatforms.Browser)] + [PlatformSpecific(~TestPlatforms.Browser)] // IO.Pipes not supported public void CanSeekReturnsFalseForPipe() { using (var pipeStream = new AnonymousPipeServerStream()) diff --git a/src/libraries/System.IO.FileSystem/tests/FileStream/CopyToAsync.cs b/src/libraries/System.IO.FileSystem/tests/FileStream/CopyToAsync.cs index 9f90c7fe9ce6ce..6141240ce7f765 100644 --- a/src/libraries/System.IO.FileSystem/tests/FileStream/CopyToAsync.cs +++ b/src/libraries/System.IO.FileSystem/tests/FileStream/CopyToAsync.cs @@ -177,7 +177,7 @@ public static IEnumerable File_AllDataCopied_MemberData() [Theory] [InlineData(10, 1024)] - [PlatformSpecific(~TestPlatforms.Browser)] + [PlatformSpecific(~TestPlatforms.Browser)] // IO.Pipes not supported public async Task AnonymousPipeViaFileStream_AllDataCopied(int writeSize, int numWrites) { long totalLength = writeSize * numWrites; diff --git a/src/libraries/System.IO.FileSystem/tests/FileStream/Flush.cs b/src/libraries/System.IO.FileSystem/tests/FileStream/Flush.cs index c2b096ec83b762..c36d778f80c8e3 100644 --- a/src/libraries/System.IO.FileSystem/tests/FileStream/Flush.cs +++ b/src/libraries/System.IO.FileSystem/tests/FileStream/Flush.cs @@ -136,6 +136,7 @@ public void FlushCallsFlush_flushToDisk_False() [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)) diff --git a/src/libraries/System.IO.FileSystem/tests/FileStream/Pipes.cs b/src/libraries/System.IO.FileSystem/tests/FileStream/Pipes.cs index bcd8b0be2adefe..fd366dc702ffff 100644 --- a/src/libraries/System.IO.FileSystem/tests/FileStream/Pipes.cs +++ b/src/libraries/System.IO.FileSystem/tests/FileStream/Pipes.cs @@ -15,7 +15,7 @@ public class Pipes : FileSystemTest [Theory] [InlineData(true)] [InlineData(false)] - [PlatformSpecific(~TestPlatforms.Browser)] + [PlatformSpecific(~TestPlatforms.Browser)] // IO.Pipes not supported public async Task AnonymousPipeWriteViaFileStream(bool asyncWrites) { using (var server = new AnonymousPipeServerStream(PipeDirection.In)) @@ -71,7 +71,7 @@ await Task.WhenAll( [Theory] [InlineData(true)] [InlineData(false)] - [PlatformSpecific(~TestPlatforms.Browser)] + [PlatformSpecific(~TestPlatforms.Browser)] // IO.Pipes not supported public async Task AnonymousPipeReadViaFileStream(bool asyncReads) { using (var server = new AnonymousPipeServerStream(PipeDirection.Out)) From 19cba4dcd5cc5df80d857e561dcb7dfe2614c073 Mon Sep 17 00:00:00 2001 From: Kenneth Pouncey Date: Fri, 24 Jul 2020 08:35:22 +0200 Subject: [PATCH 04/37] [browser][filesystem] Comment on skipped tests due to monitor not supported --- .../System.IO.FileSystem/tests/FileStream/ReadWriteSpan.cs | 6 +++--- .../System.IO.FileSystem/tests/FileStream/WriteAsync.cs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libraries/System.IO.FileSystem/tests/FileStream/ReadWriteSpan.cs b/src/libraries/System.IO.FileSystem/tests/FileStream/ReadWriteSpan.cs index 43592e9b319aa5..b9f8c2d061b721 100644 --- a/src/libraries/System.IO.FileSystem/tests/FileStream/ReadWriteSpan.cs +++ b/src/libraries/System.IO.FileSystem/tests/FileStream/ReadWriteSpan.cs @@ -24,7 +24,7 @@ public void DisposedStream_ReadWrite_Throws() } [Fact] - [PlatformSpecific(~TestPlatforms.Browser)] + [PlatformSpecific(~TestPlatforms.Browser)] // PNSE: Cannot wait on monitors public void EmptyFile_Read_Succeeds() { using (var fs = CreateFileStream(GetTestFilePath(), FileMode.Create)) @@ -48,7 +48,7 @@ public void EmptyFile_Read_Succeeds() } [Fact] - [PlatformSpecific(~TestPlatforms.Browser)] + [PlatformSpecific(~TestPlatforms.Browser)] // PNSE: Cannot wait on monitors public void NonEmptyFile_Read_GetsExpectedData() { string fileName = GetTestFilePath(); @@ -114,7 +114,7 @@ public void EmptyWrites_NoDataWritten() } [Fact] - [PlatformSpecific(~TestPlatforms.Browser)] + [PlatformSpecific(~TestPlatforms.Browser)] // PNSE: Cannot wait on monitors public void NonEmptyWrite_WritesExpectedData() { using (var fs = CreateFileStream(GetTestFilePath(), FileMode.Create)) diff --git a/src/libraries/System.IO.FileSystem/tests/FileStream/WriteAsync.cs b/src/libraries/System.IO.FileSystem/tests/FileStream/WriteAsync.cs index f9b6067b01029c..e39a82e2316c35 100644 --- a/src/libraries/System.IO.FileSystem/tests/FileStream/WriteAsync.cs +++ b/src/libraries/System.IO.FileSystem/tests/FileStream/WriteAsync.cs @@ -278,7 +278,7 @@ public static IEnumerable MemberData_FileStreamAsyncWriting() } [Fact] - [PlatformSpecific(~TestPlatforms.Browser)] + [PlatformSpecific(~TestPlatforms.Browser)] // PNSE: Cannot wait on monitors public Task ManyConcurrentWriteAsyncs() { // For inner loop, just test one case From cb8bef88bc4a202341aa873d5b6ac5963433431c Mon Sep 17 00:00:00 2001 From: Kenneth Pouncey Date: Fri, 24 Jul 2020 08:46:59 +0200 Subject: [PATCH 05/37] Address review comments --- .../System.IO.FileSystem/tests/File/ReadWriteAllBytes.cs | 2 +- .../System.IO.FileSystem/tests/File/ReadWriteAllBytesAsync.cs | 2 +- .../System.IO.FileSystem/tests/File/ReadWriteAllLines.cs | 4 ++-- .../System.IO.FileSystem/tests/File/ReadWriteAllLinesAsync.cs | 2 +- .../System.IO.FileSystem/tests/File/ReadWriteAllText.cs | 2 +- .../System.IO.FileSystem/tests/File/ReadWriteAllTextAsync.cs | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllBytes.cs b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllBytes.cs index f67f457d7bbaec..37803129e5d50f 100644 --- a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllBytes.cs +++ b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllBytes.cs @@ -107,7 +107,7 @@ public void WriteToReadOnlyFile() try { // Operation succeeds when being run by the Unix superuser - if ((!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !RuntimeInformation.IsOSPlatform(OSPlatform.Browser)) && geteuid() == 0) + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !RuntimeInformation.IsOSPlatform(OSPlatform.Browser) && geteuid() == 0) { File.WriteAllBytes(path, Encoding.UTF8.GetBytes("text")); Assert.Equal(Encoding.UTF8.GetBytes("text"), File.ReadAllBytes(path)); diff --git a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllBytesAsync.cs b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllBytesAsync.cs index 2a5a5d573e2542..f674438797d1e4 100644 --- a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllBytesAsync.cs +++ b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllBytesAsync.cs @@ -121,7 +121,7 @@ public async Task WriteToReadOnlyFileAsync() try { // Operation succeeds when being run by the Unix superuser - if ((!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !RuntimeInformation.IsOSPlatform(OSPlatform.Browser)) && geteuid() == 0) + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !RuntimeInformation.IsOSPlatform(OSPlatform.Browser) && geteuid() == 0) { await File.WriteAllBytesAsync(path, Encoding.UTF8.GetBytes("text")); Assert.Equal(Encoding.UTF8.GetBytes("text"), await File.ReadAllBytesAsync(path)); diff --git a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllLines.cs b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllLines.cs index 458398e648755a..42e1dda5a368b6 100644 --- a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllLines.cs +++ b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllLines.cs @@ -113,7 +113,7 @@ public void WriteToReadOnlyFile() try { // Operation succeeds when being run by the Unix superuser - if ((!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !RuntimeInformation.IsOSPlatform(OSPlatform.Browser)) && geteuid() == 0) + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !RuntimeInformation.IsOSPlatform(OSPlatform.Browser) && geteuid() == 0) { Write(path, new string[] { "text" }); Assert.Equal(new string[] { "text" }, Read(path)); @@ -302,7 +302,7 @@ public void WriteToReadOnlyFile() try { // Operation succeeds when being run by the Unix superuser - if ((!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !RuntimeInformation.IsOSPlatform(OSPlatform.Browser)) && geteuid() == 0) + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !RuntimeInformation.IsOSPlatform(OSPlatform.Browser) && geteuid() == 0) { Write(path, new string[] { "text" }); Assert.Equal(new string[] { "text" }, Read(path)); diff --git a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllLinesAsync.cs b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllLinesAsync.cs index 13bfbab2812aae..43ee37a6475d3a 100644 --- a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllLinesAsync.cs +++ b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllLinesAsync.cs @@ -108,7 +108,7 @@ public async Task WriteToReadOnlyFile() try { // Operation succeeds when being run by the Unix superuser - if ((!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !RuntimeInformation.IsOSPlatform(OSPlatform.Browser)) && geteuid() == 0) + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !RuntimeInformation.IsOSPlatform(OSPlatform.Browser) && geteuid() == 0) { await WriteAsync(path, new string[] { "text" }); Assert.Equal(new string[] { "text" }, await ReadAsync(path)); diff --git a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllText.cs b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllText.cs index fb0694c2cdac0a..2adeca063d9f65 100644 --- a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllText.cs +++ b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllText.cs @@ -120,7 +120,7 @@ public void WriteToReadOnlyFile() try { // Operation succeeds when being run by the Unix superuser - if ((!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !RuntimeInformation.IsOSPlatform(OSPlatform.Browser)) && geteuid() == 0) + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !RuntimeInformation.IsOSPlatform(OSPlatform.Browser) && geteuid() == 0) { Write(path, "text"); Assert.Equal("text", Read(path)); diff --git a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllTextAsync.cs b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllTextAsync.cs index 4b005bfad6a028..459a7e45e81bb8 100644 --- a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllTextAsync.cs +++ b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllTextAsync.cs @@ -116,7 +116,7 @@ public async Task WriteToReadOnlyFileAsync() try { // Operation succeeds when being run by the Unix superuser - if ((!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !RuntimeInformation.IsOSPlatform(OSPlatform.Browser)) && geteuid() == 0) + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !RuntimeInformation.IsOSPlatform(OSPlatform.Browser) && geteuid() == 0) { await WriteAsync(path, "text"); Assert.Equal("text", await ReadAsync(path)); From ca9ab82d4552a93ceabb6d7215f25e1f941850ef Mon Sep 17 00:00:00 2001 From: Kenneth Pouncey Date: Fri, 24 Jul 2020 13:19:14 +0200 Subject: [PATCH 06/37] Address review comments on how to handle monitor PNSE --- .../tests/FileStream/ReadWriteSpan.cs | 9 +++------ .../System.IO.FileSystem/tests/FileStream/WriteAsync.cs | 3 +-- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/libraries/System.IO.FileSystem/tests/FileStream/ReadWriteSpan.cs b/src/libraries/System.IO.FileSystem/tests/FileStream/ReadWriteSpan.cs index b9f8c2d061b721..4d66807a3c993f 100644 --- a/src/libraries/System.IO.FileSystem/tests/FileStream/ReadWriteSpan.cs +++ b/src/libraries/System.IO.FileSystem/tests/FileStream/ReadWriteSpan.cs @@ -23,8 +23,7 @@ public void DisposedStream_ReadWrite_Throws() Assert.Throws(() => fs.Write(new Span(new byte[1]))); } - [Fact] - [PlatformSpecific(~TestPlatforms.Browser)] // PNSE: Cannot wait on monitors + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] // Browser PNSE: Cannot wait on monitors public void EmptyFile_Read_Succeeds() { using (var fs = CreateFileStream(GetTestFilePath(), FileMode.Create)) @@ -47,8 +46,7 @@ public void EmptyFile_Read_Succeeds() } } - [Fact] - [PlatformSpecific(~TestPlatforms.Browser)] // PNSE: Cannot wait on monitors + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] // Browser PNSE: Cannot wait on monitors public void NonEmptyFile_Read_GetsExpectedData() { string fileName = GetTestFilePath(); @@ -113,8 +111,7 @@ public void EmptyWrites_NoDataWritten() } } - [Fact] - [PlatformSpecific(~TestPlatforms.Browser)] // PNSE: Cannot wait on monitors + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] // Browser PNSE: Cannot wait on monitors public void NonEmptyWrite_WritesExpectedData() { using (var fs = CreateFileStream(GetTestFilePath(), FileMode.Create)) diff --git a/src/libraries/System.IO.FileSystem/tests/FileStream/WriteAsync.cs b/src/libraries/System.IO.FileSystem/tests/FileStream/WriteAsync.cs index e39a82e2316c35..ecd265ee1130b2 100644 --- a/src/libraries/System.IO.FileSystem/tests/FileStream/WriteAsync.cs +++ b/src/libraries/System.IO.FileSystem/tests/FileStream/WriteAsync.cs @@ -277,8 +277,7 @@ public static IEnumerable MemberData_FileStreamAsyncWriting() } } - [Fact] - [PlatformSpecific(~TestPlatforms.Browser)] // PNSE: Cannot wait on monitors + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] // Browser PNSE: Cannot wait on monitors public Task ManyConcurrentWriteAsyncs() { // For inner loop, just test one case From 2e49e466ed618fc8641a193db169d063681365d9 Mon Sep 17 00:00:00 2001 From: Kenneth Pouncey Date: Mon, 27 Jul 2020 06:37:17 +0200 Subject: [PATCH 07/37] Update src/libraries/System.IO.FileSystem/tests/File/GetSetTimes.cs Co-authored-by: Jan Kotas --- src/libraries/System.IO.FileSystem/tests/File/GetSetTimes.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.IO.FileSystem/tests/File/GetSetTimes.cs b/src/libraries/System.IO.FileSystem/tests/File/GetSetTimes.cs index e99d7def06ae54..2e0c99e93c612c 100644 --- a/src/libraries/System.IO.FileSystem/tests/File/GetSetTimes.cs +++ b/src/libraries/System.IO.FileSystem/tests/File/GetSetTimes.cs @@ -13,7 +13,7 @@ public class File_GetSetTimes : StaticGetSetTimes { // 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 && !PlatformDetection.IsBrowser); + private static bool SupportsLongMaxDateTime => PlatformDetection.IsWindows || (!PlatformDetection.Is32BitProcess && !PlatformDetection.IsOSXLike); protected override string GetExistingItem() { From f69b500578e14a05515f31c1c3e12e3c85f99c13 Mon Sep 17 00:00:00 2001 From: Kenneth Pouncey Date: Mon, 27 Jul 2020 11:06:53 +0200 Subject: [PATCH 08/37] Add ActiveIssue for browser platform ``` [ActiveIssue("https://github.com/dotnet/runtime/issues/39955", TestPlatforms.Browser)] public void NotFoundErrorIsExpected() ``` --- .../tests/Enumeration/ErrorHandlingTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.IO.FileSystem/tests/Enumeration/ErrorHandlingTests.cs b/src/libraries/System.IO.FileSystem/tests/Enumeration/ErrorHandlingTests.cs index 14725d63b017e2..e13ffdba2cc256 100644 --- a/src/libraries/System.IO.FileSystem/tests/Enumeration/ErrorHandlingTests.cs +++ b/src/libraries/System.IO.FileSystem/tests/Enumeration/ErrorHandlingTests.cs @@ -68,7 +68,7 @@ public void OpenErrorDoesNotHappenAgainOnMoveNext() } [Fact] - [PlatformSpecific(~TestPlatforms.Browser)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/39955", TestPlatforms.Browser)] public void NotFoundErrorIsExpected() { // Make sure we're returning the native error as expected (and not the PAL error on Unix) From 9b5cf83e6b916bd77ec412899ab055dc966867ae Mon Sep 17 00:00:00 2001 From: Kenneth Pouncey Date: Mon, 27 Jul 2020 11:11:51 +0200 Subject: [PATCH 09/37] Simplify test case with `PlatformDetection.IsSuperUser` as per review comment --- .../System.IO.FileSystem/tests/File/ReadWriteAllBytes.cs | 2 +- .../System.IO.FileSystem/tests/File/ReadWriteAllBytesAsync.cs | 2 +- .../System.IO.FileSystem/tests/File/ReadWriteAllLines.cs | 4 ++-- .../System.IO.FileSystem/tests/File/ReadWriteAllLinesAsync.cs | 2 +- .../System.IO.FileSystem/tests/File/ReadWriteAllText.cs | 2 +- .../System.IO.FileSystem/tests/File/ReadWriteAllTextAsync.cs | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllBytes.cs b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllBytes.cs index 37803129e5d50f..c7d63dd81707b0 100644 --- a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllBytes.cs +++ b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllBytes.cs @@ -107,7 +107,7 @@ public void WriteToReadOnlyFile() try { // Operation succeeds when being run by the Unix superuser - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !RuntimeInformation.IsOSPlatform(OSPlatform.Browser) && geteuid() == 0) + if (PlatformDetection.IsSuperUser) { File.WriteAllBytes(path, Encoding.UTF8.GetBytes("text")); Assert.Equal(Encoding.UTF8.GetBytes("text"), File.ReadAllBytes(path)); diff --git a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllBytesAsync.cs b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllBytesAsync.cs index f674438797d1e4..dd5b507aebfc72 100644 --- a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllBytesAsync.cs +++ b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllBytesAsync.cs @@ -121,7 +121,7 @@ public async Task WriteToReadOnlyFileAsync() try { // Operation succeeds when being run by the Unix superuser - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !RuntimeInformation.IsOSPlatform(OSPlatform.Browser) && geteuid() == 0) + if (PlatformDetection.IsSuperUser) { await File.WriteAllBytesAsync(path, Encoding.UTF8.GetBytes("text")); Assert.Equal(Encoding.UTF8.GetBytes("text"), await File.ReadAllBytesAsync(path)); diff --git a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllLines.cs b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllLines.cs index 42e1dda5a368b6..c83732a25d9fe9 100644 --- a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllLines.cs +++ b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllLines.cs @@ -113,7 +113,7 @@ public void WriteToReadOnlyFile() try { // Operation succeeds when being run by the Unix superuser - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !RuntimeInformation.IsOSPlatform(OSPlatform.Browser) && geteuid() == 0) + if (PlatformDetection.IsSuperUser) { Write(path, new string[] { "text" }); Assert.Equal(new string[] { "text" }, Read(path)); @@ -302,7 +302,7 @@ public void WriteToReadOnlyFile() try { // Operation succeeds when being run by the Unix superuser - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !RuntimeInformation.IsOSPlatform(OSPlatform.Browser) && geteuid() == 0) + if (PlatformDetection.IsSuperUser) { Write(path, new string[] { "text" }); Assert.Equal(new string[] { "text" }, Read(path)); diff --git a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllLinesAsync.cs b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllLinesAsync.cs index 43ee37a6475d3a..05b8a0ec6593df 100644 --- a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllLinesAsync.cs +++ b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllLinesAsync.cs @@ -108,7 +108,7 @@ public async Task WriteToReadOnlyFile() try { // Operation succeeds when being run by the Unix superuser - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !RuntimeInformation.IsOSPlatform(OSPlatform.Browser) && geteuid() == 0) + if (PlatformDetection.IsSuperUser) { await WriteAsync(path, new string[] { "text" }); Assert.Equal(new string[] { "text" }, await ReadAsync(path)); diff --git a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllText.cs b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllText.cs index 2adeca063d9f65..6029bd96aba64d 100644 --- a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllText.cs +++ b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllText.cs @@ -120,7 +120,7 @@ public void WriteToReadOnlyFile() try { // Operation succeeds when being run by the Unix superuser - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !RuntimeInformation.IsOSPlatform(OSPlatform.Browser) && geteuid() == 0) + if (PlatformDetection.IsSuperUser) { Write(path, "text"); Assert.Equal("text", Read(path)); diff --git a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllTextAsync.cs b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllTextAsync.cs index 459a7e45e81bb8..1d844b0b5a7924 100644 --- a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllTextAsync.cs +++ b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllTextAsync.cs @@ -116,7 +116,7 @@ public async Task WriteToReadOnlyFileAsync() try { // Operation succeeds when being run by the Unix superuser - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !RuntimeInformation.IsOSPlatform(OSPlatform.Browser) && geteuid() == 0) + if (PlatformDetection.IsSuperUser) { await WriteAsync(path, "text"); Assert.Equal("text", await ReadAsync(path)); From b8c080bab06a03f8f5a234097a1ae1726939a367 Mon Sep 17 00:00:00 2001 From: Kenneth Pouncey Date: Mon, 27 Jul 2020 11:14:46 +0200 Subject: [PATCH 10/37] Remove unused variable from tests --- .../System.IO.FileSystem/tests/FileSystemTest.Browser.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/libraries/System.IO.FileSystem/tests/FileSystemTest.Browser.cs b/src/libraries/System.IO.FileSystem/tests/FileSystemTest.Browser.cs index 7fdb83c3c19ece..afaa1cc90e9167 100644 --- a/src/libraries/System.IO.FileSystem/tests/FileSystemTest.Browser.cs +++ b/src/libraries/System.IO.FileSystem/tests/FileSystemTest.Browser.cs @@ -8,11 +8,6 @@ namespace System.IO.Tests { public abstract partial class FileSystemTest { - protected static int geteuid() - { - throw new PlatformNotSupportedException(); - } - protected static int mkfifo(string path, int mode) { throw new PlatformNotSupportedException(); From 663355f5c4fc0316363d43eed860b5519684cc07 Mon Sep 17 00:00:00 2001 From: Kenneth Pouncey Date: Mon, 27 Jul 2020 14:01:16 +0200 Subject: [PATCH 11/37] 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. --- .../tests/Directory/CreateDirectory.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/libraries/System.IO.FileSystem/tests/Directory/CreateDirectory.cs b/src/libraries/System.IO.FileSystem/tests/Directory/CreateDirectory.cs index e6779e50acc790..fb5fab4defac4f 100644 --- a/src/libraries/System.IO.FileSystem/tests/Directory/CreateDirectory.cs +++ b/src/libraries/System.IO.FileSystem/tests/Directory/CreateDirectory.cs @@ -210,18 +210,26 @@ public void DirectoryEqualToMaxDirectory_CanBeCreatedAllAtOnce() Assert.Equal(path, result.FullName); Assert.True(Directory.Exists(result.FullName)); } + #endregion + + #region PlatformSpecific [Theory, MemberData(nameof(PathsWithComponentLongerThanMaxComponent))] - [PlatformSpecific(~TestPlatforms.Browser)] + [PlatformSpecific(~TestPlatforms.Browser)] // Browser does not have a limit on the maximum component length public void DirectoryWithComponentLongerThanMaxComponentAsPath_ThrowsException(string path) { AssertExtensions.ThrowsAny(() => 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_BrowserDoesNotThrowsException(string path) + { + DirectoryInfo result = Create(path); + Assert.True(Directory.Exists(path)); + } [Theory, MemberData(nameof(PathsWithInvalidColons))] [PlatformSpecific(TestPlatforms.Windows)] From 8c9ea54242e8c36e695701ae62a56b8bd0501e58 Mon Sep 17 00:00:00 2001 From: Kenneth Pouncey Date: Tue, 28 Jul 2020 06:50:12 +0200 Subject: [PATCH 12/37] Fix windows tests --- .../System.IO.FileSystem/tests/File/ReadWriteAllBytes.cs | 2 +- .../System.IO.FileSystem/tests/File/ReadWriteAllBytesAsync.cs | 2 +- .../System.IO.FileSystem/tests/File/ReadWriteAllLines.cs | 4 ++-- .../System.IO.FileSystem/tests/File/ReadWriteAllLinesAsync.cs | 2 +- .../System.IO.FileSystem/tests/File/ReadWriteAllText.cs | 2 +- .../System.IO.FileSystem/tests/File/ReadWriteAllTextAsync.cs | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllBytes.cs b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllBytes.cs index c7d63dd81707b0..29f160370945f2 100644 --- a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllBytes.cs +++ b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllBytes.cs @@ -107,7 +107,7 @@ public void WriteToReadOnlyFile() try { // Operation succeeds when being run by the Unix superuser - if (PlatformDetection.IsSuperUser) + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && PlatformDetection.IsSuperUser) { File.WriteAllBytes(path, Encoding.UTF8.GetBytes("text")); Assert.Equal(Encoding.UTF8.GetBytes("text"), File.ReadAllBytes(path)); diff --git a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllBytesAsync.cs b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllBytesAsync.cs index dd5b507aebfc72..05cfac95e0c21a 100644 --- a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllBytesAsync.cs +++ b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllBytesAsync.cs @@ -121,7 +121,7 @@ public async Task WriteToReadOnlyFileAsync() try { // Operation succeeds when being run by the Unix superuser - if (PlatformDetection.IsSuperUser) + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && PlatformDetection.IsSuperUser) { await File.WriteAllBytesAsync(path, Encoding.UTF8.GetBytes("text")); Assert.Equal(Encoding.UTF8.GetBytes("text"), await File.ReadAllBytesAsync(path)); diff --git a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllLines.cs b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllLines.cs index c83732a25d9fe9..796f1ad2cb0342 100644 --- a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllLines.cs +++ b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllLines.cs @@ -113,7 +113,7 @@ public void WriteToReadOnlyFile() try { // Operation succeeds when being run by the Unix superuser - if (PlatformDetection.IsSuperUser) + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && PlatformDetection.IsSuperUser) { Write(path, new string[] { "text" }); Assert.Equal(new string[] { "text" }, Read(path)); @@ -302,7 +302,7 @@ public void WriteToReadOnlyFile() try { // Operation succeeds when being run by the Unix superuser - if (PlatformDetection.IsSuperUser) + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && PlatformDetection.IsSuperUser) { Write(path, new string[] { "text" }); Assert.Equal(new string[] { "text" }, Read(path)); diff --git a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllLinesAsync.cs b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllLinesAsync.cs index 05b8a0ec6593df..4fe9b93b46ec5f 100644 --- a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllLinesAsync.cs +++ b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllLinesAsync.cs @@ -108,7 +108,7 @@ public async Task WriteToReadOnlyFile() try { // Operation succeeds when being run by the Unix superuser - if (PlatformDetection.IsSuperUser) + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && PlatformDetection.IsSuperUser) { await WriteAsync(path, new string[] { "text" }); Assert.Equal(new string[] { "text" }, await ReadAsync(path)); diff --git a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllText.cs b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllText.cs index 6029bd96aba64d..2b5c4f08087208 100644 --- a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllText.cs +++ b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllText.cs @@ -120,7 +120,7 @@ public void WriteToReadOnlyFile() try { // Operation succeeds when being run by the Unix superuser - if (PlatformDetection.IsSuperUser) + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && PlatformDetection.IsSuperUser) { Write(path, "text"); Assert.Equal("text", Read(path)); diff --git a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllTextAsync.cs b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllTextAsync.cs index 1d844b0b5a7924..f3b7190fb67559 100644 --- a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllTextAsync.cs +++ b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllTextAsync.cs @@ -116,7 +116,7 @@ public async Task WriteToReadOnlyFileAsync() try { // Operation succeeds when being run by the Unix superuser - if (PlatformDetection.IsSuperUser) + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && PlatformDetection.IsSuperUser) { await WriteAsync(path, "text"); Assert.Equal("text", await ReadAsync(path)); From 13594af7a15c8be49178bf20899880190884bb26 Mon Sep 17 00:00:00 2001 From: Kenneth Pouncey Date: Tue, 28 Jul 2020 12:15:12 +0200 Subject: [PATCH 13/37] 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 --- src/libraries/System.IO.FileSystem/tests/DirectoryInfo/Name.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.IO.FileSystem/tests/DirectoryInfo/Name.cs b/src/libraries/System.IO.FileSystem/tests/DirectoryInfo/Name.cs index f35d1c86443272..30021757a4d6d6 100644 --- a/src/libraries/System.IO.FileSystem/tests/DirectoryInfo/Name.cs +++ b/src/libraries/System.IO.FileSystem/tests/DirectoryInfo/Name.cs @@ -8,7 +8,7 @@ namespace System.IO.Tests public class DirectoryInfo_Name : FileSystemTest { [Fact] - [PlatformSpecific(~TestPlatforms.Browser)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/39998", TestPlatforms.Browser)] public void CurrentDirectory() { var info = new DirectoryInfo("."); From 6d8a03e85cc134a7bd360ed39f1421afd6e78794 Mon Sep 17 00:00:00 2001 From: Kenneth Pouncey Date: Wed, 29 Jul 2020 10:40:31 +0200 Subject: [PATCH 14/37] Add active issue for tests that need to support file locking. --- .../System.IO.FileSystem/tests/File/ReadWriteAllBytes.cs | 2 +- .../System.IO.FileSystem/tests/File/ReadWriteAllBytesAsync.cs | 2 +- .../System.IO.FileSystem/tests/File/ReadWriteAllLines.cs | 4 ++-- .../System.IO.FileSystem/tests/File/ReadWriteAllLinesAsync.cs | 2 +- .../System.IO.FileSystem/tests/File/ReadWriteAllText.cs | 2 +- .../System.IO.FileSystem/tests/File/ReadWriteAllTextAsync.cs | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllBytes.cs b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllBytes.cs index 29f160370945f2..a4326071b02ac1 100644 --- a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllBytes.cs +++ b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllBytes.cs @@ -81,7 +81,7 @@ public void Overwrite() } [Fact] - [PlatformSpecific(~TestPlatforms.Browser)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/40065", TestPlatforms.Browser)] public void OpenFile_ThrowsIOException() { string path = GetTestFilePath(); diff --git a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllBytesAsync.cs b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllBytesAsync.cs index 05cfac95e0c21a..7b4547f6c176d7 100644 --- a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllBytesAsync.cs +++ b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllBytesAsync.cs @@ -95,7 +95,7 @@ public async Task OverwriteAsync() } [Fact] - [PlatformSpecific(~TestPlatforms.Browser)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/40065", TestPlatforms.Browser)] public async Task OpenFile_ThrowsIOExceptionAsync() { string path = GetTestFilePath(); diff --git a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllLines.cs b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllLines.cs index 796f1ad2cb0342..abe639e46b85fe 100644 --- a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllLines.cs +++ b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllLines.cs @@ -79,7 +79,7 @@ public virtual void Overwrite() } [Fact] - [PlatformSpecific(~TestPlatforms.Browser)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/40065", TestPlatforms.Browser)] public void OpenFile_ThrowsIOException() { string path = GetTestFilePath(); @@ -268,7 +268,7 @@ public virtual void Overwrite() } [Fact] - [PlatformSpecific(~TestPlatforms.Browser)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/40065", TestPlatforms.Browser)] public void OpenFile_ThrowsIOException() { string path = GetTestFilePath(); diff --git a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllLinesAsync.cs b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllLinesAsync.cs index 4fe9b93b46ec5f..98856e0ca8d3ba 100644 --- a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllLinesAsync.cs +++ b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllLinesAsync.cs @@ -77,7 +77,7 @@ public virtual async Task OverwriteAsync() } [Fact] - [PlatformSpecific(~TestPlatforms.Browser)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/40065", TestPlatforms.Browser)] public async Task OpenFile_ThrowsIOExceptionAsync() { string path = GetTestFilePath(); diff --git a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllText.cs b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllText.cs index 2b5c4f08087208..2528f1571d765e 100644 --- a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllText.cs +++ b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllText.cs @@ -86,7 +86,7 @@ public virtual void Overwrite() } [Fact] - [PlatformSpecific(~TestPlatforms.Browser)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/40065", TestPlatforms.Browser)] public void OpenFile_ThrowsIOException() { string path = GetTestFilePath(); diff --git a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllTextAsync.cs b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllTextAsync.cs index f3b7190fb67559..0d719f512128f6 100644 --- a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllTextAsync.cs +++ b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllTextAsync.cs @@ -85,7 +85,7 @@ public virtual async Task OverwriteAsync() } [Fact] - [PlatformSpecific(~TestPlatforms.Browser)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/40065", TestPlatforms.Browser)] public async Task OpenFile_ThrowsIOExceptionAsync() { string path = GetTestFilePath(); From 67afdd00b6a55a33e3e8f6f5f7132bfe0e009527 Mon Sep 17 00:00:00 2001 From: Kenneth Pouncey Date: Wed, 29 Jul 2020 11:28:26 +0200 Subject: [PATCH 15/37] Add active issue for tests that need to support file locking. --- src/libraries/System.IO.FileSystem/tests/File/Create.cs | 2 +- .../System.IO.FileSystem/tests/FileStream/ctor_str_fm_fa_fs.cs | 2 +- .../tests/FileStream/ctor_str_fm_fa_fs.write.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libraries/System.IO.FileSystem/tests/File/Create.cs b/src/libraries/System.IO.FileSystem/tests/File/Create.cs index 79aca5e04555cb..67844d3d3dfadc 100644 --- a/src/libraries/System.IO.FileSystem/tests/File/Create.cs +++ b/src/libraries/System.IO.FileSystem/tests/File/Create.cs @@ -111,7 +111,7 @@ public void InvalidDirectory() } [Fact] - [PlatformSpecific(~TestPlatforms.Browser)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/40065", TestPlatforms.Browser)] public void FileInUse() { DirectoryInfo testDir = Directory.CreateDirectory(GetTestFilePath()); diff --git a/src/libraries/System.IO.FileSystem/tests/FileStream/ctor_str_fm_fa_fs.cs b/src/libraries/System.IO.FileSystem/tests/FileStream/ctor_str_fm_fa_fs.cs index 0cc73a9e33689d..805354e31cd447 100644 --- a/src/libraries/System.IO.FileSystem/tests/FileStream/ctor_str_fm_fa_fs.cs +++ b/src/libraries/System.IO.FileSystem/tests/FileStream/ctor_str_fm_fa_fs.cs @@ -121,7 +121,7 @@ public void FileShareOpenOrCreate() [Theory] [InlineData(FileMode.Create)] [InlineData(FileMode.Truncate)] - [PlatformSpecific(~TestPlatforms.Browser)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/40065", TestPlatforms.Browser)] public void NoTruncateOnFileShareViolation(FileMode fileMode) { string fileName = GetTestFilePath(); diff --git a/src/libraries/System.IO.FileSystem/tests/FileStream/ctor_str_fm_fa_fs.write.cs b/src/libraries/System.IO.FileSystem/tests/FileStream/ctor_str_fm_fa_fs.write.cs index 155bc18b18f244..e0d619187c3999 100644 --- a/src/libraries/System.IO.FileSystem/tests/FileStream/ctor_str_fm_fa_fs.write.cs +++ b/src/libraries/System.IO.FileSystem/tests/FileStream/ctor_str_fm_fa_fs.write.cs @@ -40,7 +40,7 @@ public void FileShareWriteExisting() } [Fact] - [PlatformSpecific(~TestPlatforms.Browser)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/40065", TestPlatforms.Browser)] public void FileShareWithoutWriteThrows() { string fileName = GetTestFilePath(); From 987b396e46c5ce5d88b0116e43227698c8da470a Mon Sep 17 00:00:00 2001 From: Kenneth Pouncey Date: Wed, 29 Jul 2020 11:42:11 +0200 Subject: [PATCH 16/37] Browser volume does not have a limit on segments --- .../System.IO.FileSystem/tests/File/Create.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/libraries/System.IO.FileSystem/tests/File/Create.cs b/src/libraries/System.IO.FileSystem/tests/File/Create.cs index 67844d3d3dfadc..447bb323baffd0 100644 --- a/src/libraries/System.IO.FileSystem/tests/File/Create.cs +++ b/src/libraries/System.IO.FileSystem/tests/File/Create.cs @@ -145,8 +145,12 @@ public void OverwriteReadOnly() Assert.True(File.Exists(testFile)); } + #endregion + + #region PlatformSpecific + [Fact] - [PlatformSpecific(~TestPlatforms.Browser)] + [PlatformSpecific(~TestPlatforms.Browser)] // Browser platform volume does not limit segments public void LongPathSegment() { DirectoryInfo testDir = Directory.CreateDirectory(GetTestFilePath()); @@ -155,10 +159,6 @@ public void LongPathSegment() Create(Path.Combine(testDir.FullName, new string('a', 300)))); } - #endregion - - #region PlatformSpecific - [Fact] [PlatformSpecific(TestPlatforms.AnyUnix)] public void LongDirectoryName() From 4b9f7980ab76cb49df52d04bf0c72e35798d1106 Mon Sep 17 00:00:00 2001 From: Kenneth Pouncey Date: Wed, 29 Jul 2020 11:46:00 +0200 Subject: [PATCH 17/37] Remove browser platform test --- src/libraries/System.IO.FileSystem/tests/FileStream/Flush.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libraries/System.IO.FileSystem/tests/FileStream/Flush.cs b/src/libraries/System.IO.FileSystem/tests/FileStream/Flush.cs index c36d778f80c8e3..b9552084b60e36 100644 --- a/src/libraries/System.IO.FileSystem/tests/FileStream/Flush.cs +++ b/src/libraries/System.IO.FileSystem/tests/FileStream/Flush.cs @@ -7,7 +7,6 @@ namespace System.IO.Tests { - [PlatformSpecific(~TestPlatforms.Browser)] public partial class FileStream_Flush : FileSystemTest { [Theory] From ddace824e6fd4445beb7aa6352321c78b65dd92a Mon Sep 17 00:00:00 2001 From: Kenneth Pouncey Date: Thu, 30 Jul 2020 06:48:41 +0200 Subject: [PATCH 18/37] Remove active issue for NotFoundErrorIsExpected --- .../System.IO.FileSystem/tests/Enumeration/ErrorHandlingTests.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libraries/System.IO.FileSystem/tests/Enumeration/ErrorHandlingTests.cs b/src/libraries/System.IO.FileSystem/tests/Enumeration/ErrorHandlingTests.cs index 0fe1b941431990..01ab8a5cdea23d 100644 --- a/src/libraries/System.IO.FileSystem/tests/Enumeration/ErrorHandlingTests.cs +++ b/src/libraries/System.IO.FileSystem/tests/Enumeration/ErrorHandlingTests.cs @@ -68,7 +68,6 @@ public void OpenErrorDoesNotHappenAgainOnMoveNext() } [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/39955", TestPlatforms.Browser)] public void NotFoundErrorIsExpected() { // Make sure we're returning the native error as expected (and not the PAL error on Unix) From 3344248a72de8bf42f1b5e714c2f7028f15c49d1 Mon Sep 17 00:00:00 2001 From: Kenneth Pouncey Date: Thu, 30 Jul 2020 07:13:56 +0200 Subject: [PATCH 19/37] Remove platform specific from SkippingHiddenFiles --- .../tests/Enumeration/SpecialDirectoryTests.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libraries/System.IO.FileSystem/tests/Enumeration/SpecialDirectoryTests.cs b/src/libraries/System.IO.FileSystem/tests/Enumeration/SpecialDirectoryTests.cs index 0831b8926f6cb2..39a747179481a8 100644 --- a/src/libraries/System.IO.FileSystem/tests/Enumeration/SpecialDirectoryTests.cs +++ b/src/libraries/System.IO.FileSystem/tests/Enumeration/SpecialDirectoryTests.cs @@ -56,7 +56,6 @@ protected virtual string[] GetNames(string directory, EnumerationOptions options } [Fact] - [PlatformSpecific(~TestPlatforms.Browser)] public void SkippingHiddenFiles() { // Files that begin with periods are considered hidden on Unix From c9294ee5676411d4fc9ebd3968d67ec3ce2414ed Mon Sep 17 00:00:00 2001 From: Kenneth Pouncey Date: Mon, 3 Aug 2020 09:56:37 +0200 Subject: [PATCH 20/37] 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. --- src/libraries/Native/Unix/System.Native/pal_io.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/libraries/Native/Unix/System.Native/pal_io.c b/src/libraries/Native/Unix/System.Native/pal_io.c index 85c5bf045bf3f0..c26f0512bcf411 100644 --- a/src/libraries/Native/Unix/System.Native/pal_io.c +++ b/src/libraries/Native/Unix/System.Native/pal_io.c @@ -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) | 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); @@ -259,6 +262,7 @@ static int32_t ConvertOpenFlags(int32_t flags) intptr_t SystemNative_Open(const char* path, int32_t flags, int32_t mode) { + //fprintf(stderr, "SystemNative_Open %s flags: %i mode: %i\n ", path, flags, mode); // these two ifdefs are for platforms where we dont have the open version of CLOEXEC and thus // must simulate it by doing a fcntl with the SETFFD version after the open instead #if !HAVE_O_CLOEXEC @@ -345,10 +349,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) | 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; From b0027792e027a7cd59620d4e43bf40ff3536a17e Mon Sep 17 00:00:00 2001 From: Kenneth Pouncey Date: Mon, 3 Aug 2020 09:57:06 +0200 Subject: [PATCH 21/37] 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. --- .../tests/Directory/GetFileSystemEntries_str.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libraries/System.IO.FileSystem/tests/Directory/GetFileSystemEntries_str.cs b/src/libraries/System.IO.FileSystem/tests/Directory/GetFileSystemEntries_str.cs index b7dad3023d002b..642439142ac000 100644 --- a/src/libraries/System.IO.FileSystem/tests/Directory/GetFileSystemEntries_str.cs +++ b/src/libraries/System.IO.FileSystem/tests/Directory/GetFileSystemEntries_str.cs @@ -175,7 +175,6 @@ public void TrailingSlashes() } [Fact] - [PlatformSpecific(~TestPlatforms.Browser)] public void HiddenFilesAreReturned() { // Note that APIs that take EnumerationOptions do NOT find hidden files by default From 8b2c3896126c85c19279513038d1a9a6993019c8 Mon Sep 17 00:00:00 2001 From: Kenneth Pouncey Date: Mon, 3 Aug 2020 10:27:04 +0200 Subject: [PATCH 22/37] Fix build for TARGET_WASM not defined --- src/libraries/Native/Unix/System.Native/pal_io.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libraries/Native/Unix/System.Native/pal_io.c b/src/libraries/Native/Unix/System.Native/pal_io.c index c26f0512bcf411..20e6f4fbdfad7e 100644 --- a/src/libraries/Native/Unix/System.Native/pal_io.c +++ b/src/libraries/Native/Unix/System.Native/pal_io.c @@ -94,7 +94,7 @@ c_static_assert(PAL_S_IFSOCK == S_IFSOCK); // 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) | TARGET_WASM +#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); @@ -349,7 +349,7 @@ 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) | TARGET_WASM +#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. From f5d769c54dcef816f07e2ef920d523a66f383f63 Mon Sep 17 00:00:00 2001 From: Kenneth Pouncey Date: Mon, 3 Aug 2020 10:50:27 +0200 Subject: [PATCH 23/37] Address review comment by add check for IsWindows to IsSuperUser. --- .../tests/TestUtilities/System/PlatformDetection.Unix.cs | 4 +--- .../System.IO.FileSystem/tests/File/ReadWriteAllBytes.cs | 2 +- .../System.IO.FileSystem/tests/File/ReadWriteAllBytesAsync.cs | 2 +- .../System.IO.FileSystem/tests/File/ReadWriteAllLines.cs | 4 ++-- .../System.IO.FileSystem/tests/File/ReadWriteAllLinesAsync.cs | 2 +- .../System.IO.FileSystem/tests/File/ReadWriteAllText.cs | 2 +- .../System.IO.FileSystem/tests/File/ReadWriteAllTextAsync.cs | 2 +- 7 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.Unix.cs b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.Unix.cs index a042993849156e..fb7db1e40d04ff 100644 --- a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.Unix.cs +++ b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.Unix.cs @@ -47,9 +47,7 @@ public static partial class PlatformDetection 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() : diff --git a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllBytes.cs b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllBytes.cs index a4326071b02ac1..1c46fa918f8f9e 100644 --- a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllBytes.cs +++ b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllBytes.cs @@ -107,7 +107,7 @@ public void WriteToReadOnlyFile() try { // Operation succeeds when being run by the Unix superuser - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && PlatformDetection.IsSuperUser) + if (PlatformDetection.IsSuperUser) { File.WriteAllBytes(path, Encoding.UTF8.GetBytes("text")); Assert.Equal(Encoding.UTF8.GetBytes("text"), File.ReadAllBytes(path)); diff --git a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllBytesAsync.cs b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllBytesAsync.cs index 7b4547f6c176d7..7d0bc78af0bab4 100644 --- a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllBytesAsync.cs +++ b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllBytesAsync.cs @@ -121,7 +121,7 @@ public async Task WriteToReadOnlyFileAsync() try { // Operation succeeds when being run by the Unix superuser - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && PlatformDetection.IsSuperUser) + if (PlatformDetection.IsSuperUser) { await File.WriteAllBytesAsync(path, Encoding.UTF8.GetBytes("text")); Assert.Equal(Encoding.UTF8.GetBytes("text"), await File.ReadAllBytesAsync(path)); diff --git a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllLines.cs b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllLines.cs index abe639e46b85fe..35cf39451bc63e 100644 --- a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllLines.cs +++ b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllLines.cs @@ -113,7 +113,7 @@ public void WriteToReadOnlyFile() try { // Operation succeeds when being run by the Unix superuser - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && PlatformDetection.IsSuperUser) + if (PlatformDetection.IsSuperUser) { Write(path, new string[] { "text" }); Assert.Equal(new string[] { "text" }, Read(path)); @@ -302,7 +302,7 @@ public void WriteToReadOnlyFile() try { // Operation succeeds when being run by the Unix superuser - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && PlatformDetection.IsSuperUser) + if (PlatformDetection.IsSuperUser) { Write(path, new string[] { "text" }); Assert.Equal(new string[] { "text" }, Read(path)); diff --git a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllLinesAsync.cs b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllLinesAsync.cs index 98856e0ca8d3ba..13bc72f32d5e40 100644 --- a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllLinesAsync.cs +++ b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllLinesAsync.cs @@ -108,7 +108,7 @@ public async Task WriteToReadOnlyFile() try { // Operation succeeds when being run by the Unix superuser - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && PlatformDetection.IsSuperUser) + if (PlatformDetection.IsSuperUser) { await WriteAsync(path, new string[] { "text" }); Assert.Equal(new string[] { "text" }, await ReadAsync(path)); diff --git a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllText.cs b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllText.cs index 2528f1571d765e..71c100d010cff3 100644 --- a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllText.cs +++ b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllText.cs @@ -120,7 +120,7 @@ public void WriteToReadOnlyFile() try { // Operation succeeds when being run by the Unix superuser - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && PlatformDetection.IsSuperUser) + if (PlatformDetection.IsSuperUser) { Write(path, "text"); Assert.Equal("text", Read(path)); diff --git a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllTextAsync.cs b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllTextAsync.cs index 0d719f512128f6..ad6c69e531c213 100644 --- a/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllTextAsync.cs +++ b/src/libraries/System.IO.FileSystem/tests/File/ReadWriteAllTextAsync.cs @@ -116,7 +116,7 @@ public async Task WriteToReadOnlyFileAsync() try { // Operation succeeds when being run by the Unix superuser - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && PlatformDetection.IsSuperUser) + if (PlatformDetection.IsSuperUser) { await WriteAsync(path, "text"); Assert.Equal("text", await ReadAsync(path)); From 577c0c096a2028704faef16e0c8dcd3505c0d9d5 Mon Sep 17 00:00:00 2001 From: Kenneth Pouncey Date: Mon, 3 Aug 2020 10:50:46 +0200 Subject: [PATCH 24/37] Address review comment by add check for IsWindows to IsSuperUser. --- .../tests/MemoryMappedFile.CreateFromFile.Tests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libraries/System.IO.MemoryMappedFiles/tests/MemoryMappedFile.CreateFromFile.Tests.cs b/src/libraries/System.IO.MemoryMappedFiles/tests/MemoryMappedFile.CreateFromFile.Tests.cs index d5edbbc05b2944..212129b124c059 100644 --- a/src/libraries/System.IO.MemoryMappedFiles/tests/MemoryMappedFile.CreateFromFile.Tests.cs +++ b/src/libraries/System.IO.MemoryMappedFiles/tests/MemoryMappedFile.CreateFromFile.Tests.cs @@ -697,13 +697,13 @@ private void WriteToReadOnlyFile(MemoryMappedFileAccess access, bool succeeds) public void WriteToReadOnlyFile_ReadWrite(MemoryMappedFileAccess access) { WriteToReadOnlyFile(access, access == MemoryMappedFileAccess.Read || - (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && PlatformDetection.IsSuperUser)); + PlatformDetection.IsSuperUser); } [Fact] public void WriteToReadOnlyFile_CopyOnWrite() { - WriteToReadOnlyFile(MemoryMappedFileAccess.CopyOnWrite, (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && PlatformDetection.IsSuperUser)); + WriteToReadOnlyFile(MemoryMappedFileAccess.CopyOnWrite, PlatformDetection.IsSuperUser); } /// From d865ea42c301f86e4b819fd5cd0b7da9463ccc0b Mon Sep 17 00:00:00 2001 From: Kenneth Pouncey Date: Mon, 3 Aug 2020 11:01:34 +0200 Subject: [PATCH 25/37] Platform Specific test for hidden files no longer needed. --- .../System.IO.FileSystem/tests/Enumeration/SkipAttributeTests.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libraries/System.IO.FileSystem/tests/Enumeration/SkipAttributeTests.cs b/src/libraries/System.IO.FileSystem/tests/Enumeration/SkipAttributeTests.cs index cac01bc3364f73..3a22c61b6f77e6 100644 --- a/src/libraries/System.IO.FileSystem/tests/Enumeration/SkipAttributeTests.cs +++ b/src/libraries/System.IO.FileSystem/tests/Enumeration/SkipAttributeTests.cs @@ -21,7 +21,6 @@ protected virtual string[] GetPaths(string directory, EnumerationOptions options } [Fact] - [PlatformSpecific(~TestPlatforms.Browser)] public void SkippingHiddenFiles() { DirectoryInfo testDirectory = Directory.CreateDirectory(GetTestFilePath()); From 3e5360162dab2f2d7df31e00ca2448e59b30dc14 Mon Sep 17 00:00:00 2001 From: Kenneth Pouncey Date: Mon, 3 Aug 2020 11:02:09 +0200 Subject: [PATCH 26/37] Platform Specific test fno longer needed. --- .../System.IO.FileSystem/tests/FileStream/SafeFileHandle.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libraries/System.IO.FileSystem/tests/FileStream/SafeFileHandle.cs b/src/libraries/System.IO.FileSystem/tests/FileStream/SafeFileHandle.cs index 54c0fc94f13166..03b3353931724a 100644 --- a/src/libraries/System.IO.FileSystem/tests/FileStream/SafeFileHandle.cs +++ b/src/libraries/System.IO.FileSystem/tests/FileStream/SafeFileHandle.cs @@ -66,7 +66,6 @@ public async Task ThrowWhenHandlePositionIsChanged_sync() } [Fact] - [PlatformSpecific(~TestPlatforms.Browser)] public async Task ThrowWhenHandlePositionIsChanged_async() { await ThrowWhenHandlePositionIsChanged(useAsync: true); From db35de8357f2c403acedddab39a22633e2774a3d Mon Sep 17 00:00:00 2001 From: Kenneth Pouncey Date: Tue, 4 Aug 2020 11:39:22 +0200 Subject: [PATCH 27/37] Use active issue for rename issue --- src/libraries/System.IO.FileSystem/tests/Directory/Move.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libraries/System.IO.FileSystem/tests/Directory/Move.cs b/src/libraries/System.IO.FileSystem/tests/Directory/Move.cs index 9564717d057bd6..02719fc0833d93 100644 --- a/src/libraries/System.IO.FileSystem/tests/Directory/Move.cs +++ b/src/libraries/System.IO.FileSystem/tests/Directory/Move.cs @@ -33,7 +33,7 @@ public void EmptyPath() } [Fact] - [PlatformSpecific(~TestPlatforms.Browser)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/40305", TestPlatforms.Browser)] public void NonExistentDirectory() { DirectoryInfo valid = Directory.CreateDirectory(GetTestFilePath()); @@ -202,7 +202,7 @@ public void IncludeSubdirectories() } [Fact] - [PlatformSpecific(~TestPlatforms.Browser)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/40305", TestPlatforms.Browser)] public void Path_Longer_Than_MaxLongPath_Throws_Exception() { string testDir = GetTestFilePath(); From 65f822b676f2a821e2ddecfb0379bafc9419091f Mon Sep 17 00:00:00 2001 From: Kenneth Pouncey Date: Wed, 5 Aug 2020 06:59:13 +0200 Subject: [PATCH 28/37] 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 --- src/libraries/System.IO.FileSystem/tests/Directory/Move.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/libraries/System.IO.FileSystem/tests/Directory/Move.cs b/src/libraries/System.IO.FileSystem/tests/Directory/Move.cs index 02719fc0833d93..4ef5cf22d79b5e 100644 --- a/src/libraries/System.IO.FileSystem/tests/Directory/Move.cs +++ b/src/libraries/System.IO.FileSystem/tests/Directory/Move.cs @@ -33,7 +33,6 @@ public void EmptyPath() } [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/40305", TestPlatforms.Browser)] public void NonExistentDirectory() { DirectoryInfo valid = Directory.CreateDirectory(GetTestFilePath()); @@ -202,7 +201,6 @@ public void IncludeSubdirectories() } [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/40305", TestPlatforms.Browser)] public void Path_Longer_Than_MaxLongPath_Throws_Exception() { string testDir = GetTestFilePath(); From 92090ed6908070d7ebc4935ec1e04688890caec3 Mon Sep 17 00:00:00 2001 From: Mitchell Hwang Date: Fri, 7 Aug 2020 10:55:21 -0400 Subject: [PATCH 29/37] Use ActiveIssue for SettingUpdatesProperties --- .../System.IO.FileSystem/tests/Base/BaseGetSetTimes.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.IO.FileSystem/tests/Base/BaseGetSetTimes.cs b/src/libraries/System.IO.FileSystem/tests/Base/BaseGetSetTimes.cs index a4232bfb7eef25..4aef0ae3b56f1d 100644 --- a/src/libraries/System.IO.FileSystem/tests/Base/BaseGetSetTimes.cs +++ b/src/libraries/System.IO.FileSystem/tests/Base/BaseGetSetTimes.cs @@ -41,7 +41,7 @@ public static TimeFunction Create(SetTime setter, GetTime getter, DateTimeKind k } [Fact] - [PlatformSpecific(~TestPlatforms.Browser)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/40528", TestPlatforms.Browser)] public void SettingUpdatesProperties() { T item = GetExistingItem(); From bd84dfb1a9cd433188902a40da98635c16fa9b54 Mon Sep 17 00:00:00 2001 From: Mitchell Hwang Date: Fri, 7 Aug 2020 10:59:13 -0400 Subject: [PATCH 30/37] Use ActiveIssue for TimesIncludeMillisecondPart --- .../System.IO.FileSystem/tests/Base/BaseGetSetTimes.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.IO.FileSystem/tests/Base/BaseGetSetTimes.cs b/src/libraries/System.IO.FileSystem/tests/Base/BaseGetSetTimes.cs index 4aef0ae3b56f1d..67d9655b1fee5b 100644 --- a/src/libraries/System.IO.FileSystem/tests/Base/BaseGetSetTimes.cs +++ b/src/libraries/System.IO.FileSystem/tests/Base/BaseGetSetTimes.cs @@ -78,7 +78,7 @@ public void CanGetAllTimesAfterCreation() } [ConditionalFact(nameof(isNotHFS))] // OSX HFS driver format does not support millisec granularity - [PlatformSpecific(~TestPlatforms.Browser)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/40530", TestPlatforms.Browser)] public void TimesIncludeMillisecondPart() { T item = GetExistingItem(); From b0821f5cb854fdf6d439ac54d619ada91140b6bd Mon Sep 17 00:00:00 2001 From: Mitchell Hwang Date: Fri, 7 Aug 2020 11:05:54 -0400 Subject: [PATCH 31/37] Use ActiveIssue for ErrorHandlingTests failures --- .../tests/Enumeration/ErrorHandlingTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libraries/System.IO.FileSystem/tests/Enumeration/ErrorHandlingTests.cs b/src/libraries/System.IO.FileSystem/tests/Enumeration/ErrorHandlingTests.cs index 01ab8a5cdea23d..675b86ccda22de 100644 --- a/src/libraries/System.IO.FileSystem/tests/Enumeration/ErrorHandlingTests.cs +++ b/src/libraries/System.IO.FileSystem/tests/Enumeration/ErrorHandlingTests.cs @@ -102,7 +102,7 @@ public void DeleteDirectoryAfterOpening() } [Fact] - [PlatformSpecific(~TestPlatforms.Browser)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/40531", TestPlatforms.Browser)] public void VariableLengthFileNames_AllCreatableFilesAreEnumerable() { DirectoryInfo testDirectory = Directory.CreateDirectory(GetTestFilePath()); @@ -120,7 +120,7 @@ public void VariableLengthFileNames_AllCreatableFilesAreEnumerable() } [Fact] - [PlatformSpecific(~TestPlatforms.Browser)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/40531", TestPlatforms.Browser)] public void VariableLengthDirectoryNames_AllCreatableDirectoriesAreEnumerable() { DirectoryInfo testDirectory = Directory.CreateDirectory(GetTestFilePath()); From c95fb8fa7ff49c2df943ff40b17cc2060814c366 Mon Sep 17 00:00:00 2001 From: Mitchell Hwang Date: Fri, 7 Aug 2020 11:15:26 -0400 Subject: [PATCH 32/37] Use ActiveIssue for SetUptoNanoseconds --- src/libraries/System.IO.FileSystem/tests/File/GetSetTimes.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.IO.FileSystem/tests/File/GetSetTimes.cs b/src/libraries/System.IO.FileSystem/tests/File/GetSetTimes.cs index 2e0c99e93c612c..07140ac9c4ee57 100644 --- a/src/libraries/System.IO.FileSystem/tests/File/GetSetTimes.cs +++ b/src/libraries/System.IO.FileSystem/tests/File/GetSetTimes.cs @@ -135,7 +135,7 @@ public void SetLastWriteTimeTicks() } [ConditionalFact(nameof(isNotHFS))] // OSX HFS driver format does not support nanosecond granularity. - [PlatformSpecific(~TestPlatforms.Browser)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/40532", TestPlatforms.Browser)] public void SetUptoNanoseconds() { string file = GetTestFilePath(); From a2d7e4e1bbdf750bae6e2ef01d7792a0c90a4728 Mon Sep 17 00:00:00 2001 From: Mitchell Hwang Date: Fri, 7 Aug 2020 12:16:26 -0400 Subject: [PATCH 33/37] Use ActiveIssue for GetSetTimes test failures --- .../System.IO.FileSystem/tests/FileInfo/GetSetTimes.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libraries/System.IO.FileSystem/tests/FileInfo/GetSetTimes.cs b/src/libraries/System.IO.FileSystem/tests/FileInfo/GetSetTimes.cs index bb9b3703eff3a8..27b2e845868bc9 100644 --- a/src/libraries/System.IO.FileSystem/tests/FileInfo/GetSetTimes.cs +++ b/src/libraries/System.IO.FileSystem/tests/FileInfo/GetSetTimes.cs @@ -104,7 +104,7 @@ public override IEnumerable TimeFunctions(bool requiresRoundtrippi } [ConditionalFact(nameof(isNotHFS))] - [PlatformSpecific(~TestPlatforms.Browser)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/40530", TestPlatforms.Browser)] public void CopyToMillisecondPresent() { FileInfo input = GetNonZeroMilliseconds(); @@ -119,7 +119,7 @@ public void CopyToMillisecondPresent() } [ConditionalFact(nameof(isNotHFS))] - [PlatformSpecific(~TestPlatforms.Browser)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/40530", TestPlatforms.Browser)] public void CopyToNanosecondsPresent() { FileInfo input = GetNonZeroNanoseconds(); @@ -162,7 +162,7 @@ public void MoveToMillisecondPresent_HFS() } [ConditionalFact(nameof(isNotHFS))] - [PlatformSpecific(~TestPlatforms.Browser)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/40530", TestPlatforms.Browser)] public void MoveToMillisecondPresent() { FileInfo input = GetNonZeroMilliseconds(); From 9a88676bb8c57ca26706618183ebf9074b4e8fb4 Mon Sep 17 00:00:00 2001 From: Mitchell Hwang Date: Fri, 7 Aug 2020 12:56:49 -0400 Subject: [PATCH 34/37] Use ActiveIssue for tests failing with DirectoryNotFoundException --- src/libraries/System.IO.FileSystem/tests/Directory/Delete.cs | 2 +- src/libraries/System.IO.FileSystem/tests/Directory/Move.cs | 2 +- .../System.IO.FileSystem/tests/DirectoryInfo/MoveTo.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libraries/System.IO.FileSystem/tests/Directory/Delete.cs b/src/libraries/System.IO.FileSystem/tests/Directory/Delete.cs index ca8c3f28bfe145..24d2df8c260325 100644 --- a/src/libraries/System.IO.FileSystem/tests/Directory/Delete.cs +++ b/src/libraries/System.IO.FileSystem/tests/Directory/Delete.cs @@ -245,7 +245,7 @@ public void RecursiveDelete() } [Fact] - [PlatformSpecific(~TestPlatforms.Browser)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/40536", TestPlatforms.Browser)] public void RecursiveDeleteWithTrailingSlash() { DirectoryInfo testDir = Directory.CreateDirectory(GetTestFilePath()); diff --git a/src/libraries/System.IO.FileSystem/tests/Directory/Move.cs b/src/libraries/System.IO.FileSystem/tests/Directory/Move.cs index 4ef5cf22d79b5e..c5a145c686cff8 100644 --- a/src/libraries/System.IO.FileSystem/tests/Directory/Move.cs +++ b/src/libraries/System.IO.FileSystem/tests/Directory/Move.cs @@ -173,7 +173,7 @@ public void DirectoryNameWithSpaces() } [Fact] - [PlatformSpecific(~TestPlatforms.Browser)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/40536", TestPlatforms.Browser)] public void TrailingDirectorySeparators() { string testDirSource = Path.Combine(TestDirectory, GetTestFileName()); diff --git a/src/libraries/System.IO.FileSystem/tests/DirectoryInfo/MoveTo.cs b/src/libraries/System.IO.FileSystem/tests/DirectoryInfo/MoveTo.cs index 1d6bac7ed0f537..fba22eb092824b 100644 --- a/src/libraries/System.IO.FileSystem/tests/DirectoryInfo/MoveTo.cs +++ b/src/libraries/System.IO.FileSystem/tests/DirectoryInfo/MoveTo.cs @@ -24,7 +24,7 @@ protected virtual void Move(DirectoryInfo sourceDir, string destDir) #region UniversalTests [Fact] - [PlatformSpecific(~TestPlatforms.Browser)] + [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 From d69b7bdac6b705d53dd3b297016114c28ff8ba72 Mon Sep 17 00:00:00 2001 From: Mitchell Hwang Date: Fri, 7 Aug 2020 13:38:14 -0400 Subject: [PATCH 35/37] Use ActiveIssue for tests failing with UnauthorizedAccessException --- src/libraries/System.IO.FileSystem/tests/File/Copy.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/libraries/System.IO.FileSystem/tests/File/Copy.cs b/src/libraries/System.IO.FileSystem/tests/File/Copy.cs index c224e465dc7435..e0b69578aca99a 100644 --- a/src/libraries/System.IO.FileSystem/tests/File/Copy.cs +++ b/src/libraries/System.IO.FileSystem/tests/File/Copy.cs @@ -108,7 +108,7 @@ public static IEnumerable CopyFileWithData_MemberData() [Theory] [MemberData(nameof(CopyFileWithData_MemberData))] - [PlatformSpecific(~TestPlatforms.Browser)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/40543", TestPlatforms.Browser)] public void CopyFileWithData(char[] data, bool readOnly) { string testFileSource = GetTestFilePath(); @@ -141,7 +141,10 @@ public void CopyFileWithData(char[] data, bool readOnly) } // 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) From c86d12aea67899332479a67b1191335b14e0a986 Mon Sep 17 00:00:00 2001 From: Mitchell Hwang Date: Mon, 10 Aug 2020 10:01:51 -0400 Subject: [PATCH 36/37] Remove debugging statement from pal_io --- src/libraries/Native/Unix/System.Native/pal_io.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libraries/Native/Unix/System.Native/pal_io.c b/src/libraries/Native/Unix/System.Native/pal_io.c index 20e6f4fbdfad7e..e0ed6cadfd687f 100644 --- a/src/libraries/Native/Unix/System.Native/pal_io.c +++ b/src/libraries/Native/Unix/System.Native/pal_io.c @@ -262,7 +262,6 @@ static int32_t ConvertOpenFlags(int32_t flags) intptr_t SystemNative_Open(const char* path, int32_t flags, int32_t mode) { - //fprintf(stderr, "SystemNative_Open %s flags: %i mode: %i\n ", path, flags, mode); // these two ifdefs are for platforms where we dont have the open version of CLOEXEC and thus // must simulate it by doing a fcntl with the SETFFD version after the open instead #if !HAVE_O_CLOEXEC From 3ff6524f7fe64a6c8eca232cde0ee8337bb748cb Mon Sep 17 00:00:00 2001 From: Mitchell Hwang Date: Mon, 10 Aug 2020 10:02:32 -0400 Subject: [PATCH 37/37] Address type in CreateDirectory method name --- .../System.IO.FileSystem/tests/Directory/CreateDirectory.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.IO.FileSystem/tests/Directory/CreateDirectory.cs b/src/libraries/System.IO.FileSystem/tests/Directory/CreateDirectory.cs index fb5fab4defac4f..78c234d5627cd5 100644 --- a/src/libraries/System.IO.FileSystem/tests/Directory/CreateDirectory.cs +++ b/src/libraries/System.IO.FileSystem/tests/Directory/CreateDirectory.cs @@ -225,7 +225,7 @@ public void DirectoryWithComponentLongerThanMaxComponentAsPath_ThrowsException(s [Theory, MemberData(nameof(PathsWithComponentLongerThanMaxComponent))] [PlatformSpecific(TestPlatforms.Browser)] // Browser specific test in case the check changes in the future - public void DirectoryWithComponentLongerThanMaxComponentAsPath_BrowserDoesNotThrowsException(string path) + public void DirectoryWithComponentLongerThanMaxComponentAsPath_BrowserDoesNotThrowException(string path) { DirectoryInfo result = Create(path); Assert.True(Directory.Exists(path));