From 9f498d41cd968e1615981d9d330700903b0ada0b Mon Sep 17 00:00:00 2001 From: Steve Pfister Date: Fri, 10 Jul 2020 16:54:48 -0400 Subject: [PATCH] [Wasm] Enable System.IO.Compression.ZipFile tests (#39092) 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 --- .../tests/ZipFile.Create.cs | 28 ++++++++++++---------- src/libraries/tests.proj | 1 - 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/libraries/System.IO.Compression.ZipFile/tests/ZipFile.Create.cs b/src/libraries/System.IO.Compression.ZipFile/tests/ZipFile.Create.cs index b08b093..3ba4081 100644 --- a/src/libraries/System.IO.Compression.ZipFile/tests/ZipFile.Create.cs +++ b/src/libraries/System.IO.Compression.ZipFile/tests/ZipFile.Create.cs @@ -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); + } } } diff --git a/src/libraries/tests.proj b/src/libraries/tests.proj index fc3cd91..3a4cf8e 100644 --- a/src/libraries/tests.proj +++ b/src/libraries/tests.proj @@ -40,7 +40,6 @@ - -- 2.7.4