From 48b299cc81142b51071b623e75831802282caf9b Mon Sep 17 00:00:00 2001 From: Mitchell Hwang Date: Fri, 28 Aug 2020 17:29:35 -0400 Subject: [PATCH] Modfiy ErrorHandlingTests for Browser (#40659) Co-authored-by: Mitchell Hwang --- .../tests/Enumeration/ErrorHandlingTests.cs | 60 +++++++++++----------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/src/libraries/System.IO.FileSystem/tests/Enumeration/ErrorHandlingTests.cs b/src/libraries/System.IO.FileSystem/tests/Enumeration/ErrorHandlingTests.cs index 675b86c..7d45d65 100644 --- a/src/libraries/System.IO.FileSystem/tests/Enumeration/ErrorHandlingTests.cs +++ b/src/libraries/System.IO.FileSystem/tests/Enumeration/ErrorHandlingTests.cs @@ -101,40 +101,40 @@ namespace System.IO.Tests } } - [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/40531", TestPlatforms.Browser)] - public void VariableLengthFileNames_AllCreatableFilesAreEnumerable() - { - DirectoryInfo testDirectory = Directory.CreateDirectory(GetTestFilePath()); - var names = new List(); - - for (int length = 1; length < 10_000; length++) // arbitrarily large limit for the test + [Fact] + public void VariableLengthFileNames_AllCreatableFilesAreEnumerable() { - string name = new string('a', length); - try { File.Create(Path.Join(testDirectory.FullName, name)).Dispose(); } - catch { break; } - names.Add(name); - } - Assert.InRange(names.Count, 1, int.MaxValue); - Assert.Equal(names.OrderBy(n => n), Directory.GetFiles(testDirectory.FullName).Select(n => Path.GetFileName(n)).OrderBy(n => n)); - } + DirectoryInfo testDirectory = Directory.CreateDirectory(GetTestFilePath()); + var names = new List(); - [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/40531", TestPlatforms.Browser)] - public void VariableLengthDirectoryNames_AllCreatableDirectoriesAreEnumerable() - { - DirectoryInfo testDirectory = Directory.CreateDirectory(GetTestFilePath()); - var names = new List(); + var lengthCap = PlatformDetection.IsBrowser ? 256 : 10_000; // On Browser NAME_MAX is 255, otherwise arbitrarily large limit for the test + for (int length = 1; length < lengthCap; length++) + { + string name = new string('a', length); + try { File.Create(Path.Join(testDirectory.FullName, name)).Dispose(); } + catch { break; } + names.Add(name); + } + Assert.InRange(names.Count, 1, int.MaxValue); + Assert.Equal(names.OrderBy(n => n), Directory.GetFiles(testDirectory.FullName).Select(n => Path.GetFileName(n)).OrderBy(n => n)); + } - for (int length = 1; length < 10_000; length++) // arbitrarily large limit for the test + [Fact] + public void VariableLengthDirectoryNames_AllCreatableDirectoriesAreEnumerable() { - string name = new string('a', length); - try { Directory.CreateDirectory(Path.Join(testDirectory.FullName, name)); } - catch { break; } - names.Add(name); + DirectoryInfo testDirectory = Directory.CreateDirectory(GetTestFilePath()); + var names = new List(); + + var lengthCap = PlatformDetection.IsBrowser ? 256 : 10_000; // On Browser NAME_MAX is 255, otherwise arbitrarily large limit for the test + for (int length = 1; length < lengthCap; length++) + { + string name = new string('a', length); + try { Directory.CreateDirectory(Path.Join(testDirectory.FullName, name)); } + catch { break; } + names.Add(name); + } + Assert.InRange(names.Count, 1, int.MaxValue); + Assert.Equal(names.OrderBy(n => n), Directory.GetDirectories(testDirectory.FullName).Select(n => Path.GetFileName(n)).OrderBy(n => n)); } - Assert.InRange(names.Count, 1, int.MaxValue); - Assert.Equal(names.OrderBy(n => n), Directory.GetDirectories(testDirectory.FullName).Select(n => Path.GetFileName(n)).OrderBy(n => n)); - } } } -- 2.7.4