[Wasm] Enable System.IO.Compression.ZipFile tests (#39092)
authorSteve Pfister <steveisok@users.noreply.github.com>
Fri, 10 Jul 2020 20:54:48 +0000 (16:54 -0400)
committerGitHub <noreply@github.com>
Fri, 10 Jul 2020 20:54:48 +0000 (22:54 +0200)
Found that the emscripten VFS does not write user specified file attributes, so skip
part of ZipFile_Create.InvalidDates that expects this to be supported.

Co-authored-by: Steve Pfister <steve.pfister@microsoft.com>
src/libraries/System.IO.Compression.ZipFile/tests/ZipFile.Create.cs
src/libraries/tests.proj

index b08b093..3ba4081 100644 (file)
@@ -282,19 +282,23 @@ namespace System.IO.Compression.Tests
                 Assert.Equal(new DateTime(1980, 1, 1, 0, 0, 0), archive.Entries[0].LastWriteTime.DateTime);
             }
 
-            FileInfo fileWithBadDate = new FileInfo(GetTestFilePath());
-            fileWithBadDate.Create().Dispose();
-            fileWithBadDate.LastWriteTimeUtc = new DateTime(1970, 1, 1, 1, 1, 1);
-
-            string archivePath = GetTestFilePath();
-            using (FileStream output = File.Open(archivePath, FileMode.Create))
-            using (ZipArchive archive = new ZipArchive(output, ZipArchiveMode.Create))
-            {
-                archive.CreateEntryFromFile(fileWithBadDate.FullName, "SomeEntryName");
-            }
-            using (ZipArchive archive = ZipFile.OpenRead(archivePath))
+            // Browser VFS does not support saving file attributes, so skip
+            if (!PlatformDetection.IsBrowser)
             {
-                Assert.Equal(new DateTime(1980, 1, 1, 0, 0, 0), archive.Entries[0].LastWriteTime.DateTime);
+                FileInfo fileWithBadDate = new FileInfo(GetTestFilePath());
+                fileWithBadDate.Create().Dispose();
+                fileWithBadDate.LastWriteTimeUtc = new DateTime(1970, 1, 1, 1, 1, 1);
+
+                string archivePath = GetTestFilePath();
+                using (FileStream output = File.Open(archivePath, FileMode.Create))
+                using (ZipArchive archive = new ZipArchive(output, ZipArchiveMode.Create))
+                {
+                    archive.CreateEntryFromFile(fileWithBadDate.FullName, "SomeEntryName");
+                }
+                using (ZipArchive archive = ZipFile.OpenRead(archivePath))
+                {
+                    Assert.Equal(new DateTime(1980, 1, 1, 0, 0, 0), archive.Entries[0].LastWriteTime.DateTime);
+                }
             }
         }
 
index fc3cd91..3a4cf8e 100644 (file)
@@ -40,7 +40,6 @@
     <ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Globalization.Calendars\tests\System.Globalization.Calendars.Tests.csproj" />
     <ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Globalization.Extensions\tests\System.Globalization.Extensions.Tests.csproj" />
     <ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Globalization\tests\System.Globalization.Tests.csproj" />
-    <ProjectExclusions Include="$(MSBuildThisFileDirectory)System.IO.Compression.ZipFile\tests\System.IO.Compression.ZipFile.Tests.csproj" />
     <ProjectExclusions Include="$(MSBuildThisFileDirectory)System.IO.Compression\tests\System.IO.Compression.Tests.csproj" />
     <ProjectExclusions Include="$(MSBuildThisFileDirectory)System.IO.FileSystem.DriveInfo\tests\System.IO.FileSystem.DriveInfo.Tests.csproj" />
     <ProjectExclusions Include="$(MSBuildThisFileDirectory)System.IO.FileSystem\tests\System.IO.FileSystem.Tests.csproj" />