From: Ankit Jain Date: Wed, 8 Mar 2023 16:26:04 +0000 (-0500) Subject: [wasi] Fixes to enable more tests (#82966) X-Git-Tag: accepted/tizen/unified/riscv/20231226.055536~3594 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=49553e8a9e89d9d209095eed848f7bcae848ac4b;p=platform%2Fupstream%2Fdotnet%2Fruntime.git [wasi] Fixes to enable more tests (#82966) * [wasi] Copy WasmFilesToIncludeInFileSystem to the bundle too This could be changed in the future to include in the single file bundle * [wasi] Enable System.IO.Packaging, and System.Data.DataSetExtensions tests * WasiAppBuilder: Create an empty /tmp * Disable System.Runtime.Serialization.Xml.XsdDataContractExporterTests.ExporterTypesTests.TypesTest_Negative - Issue: https://github.com/dotnet/runtime/issues/82967 * Enable System.Runtime.Serialization.Xml.Tests, and System.Runtime.Serialization.Xml.ReflectionOnly.Tests Remaining fixed by adding `/tmp` --- diff --git a/src/libraries/System.Runtime.Serialization.Xml/tests/XsdDataContractExporterTests/ExporterTypesTests.cs b/src/libraries/System.Runtime.Serialization.Xml/tests/XsdDataContractExporterTests/ExporterTypesTests.cs index 6c9ac36..c21b315 100644 --- a/src/libraries/System.Runtime.Serialization.Xml/tests/XsdDataContractExporterTests/ExporterTypesTests.cs +++ b/src/libraries/System.Runtime.Serialization.Xml/tests/XsdDataContractExporterTests/ExporterTypesTests.cs @@ -81,6 +81,7 @@ namespace System.Runtime.Serialization.Xml.XsdDataContractExporterTests [Theory] [SkipOnPlatform(TestPlatforms.Browser, "Inconsistent and unpredictable results.")] // TODO - Why does 'TypeWithReadWriteCollectionAndNoCtorOnCollection' only cause an exception sometimes, but not all the time? What's special about wasm here? + [ActiveIssue("https://github.com/dotnet/runtime/issues/82967", TestPlatforms.Wasi)] [InlineData(typeof(NoDataContractWithoutParameterlessConstructor), typeof(InvalidDataContractException), @"Type 'System.Runtime.Serialization.Xml.XsdDataContractExporterTests.ExporterTypesTests+NoDataContractWithoutParameterlessConstructor' cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute. Alternatively, you can ensure that the type is public and has a parameterless constructor - all public members of the type will then be serialized, and no attributes will be required.")] [InlineData(typeof(DataContractWithInvalidMember), typeof(InvalidDataContractException), @"Type 'System.Runtime.Serialization.Xml.XsdDataContractExporterTests.ExporterTypesTests+NoDataContractWithoutParameterlessConstructor' cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute. Alternatively, you can ensure that the type is public and has a parameterless constructor - all public members of the type will then be serialized, and no attributes will be required.")] [InlineData(typeof(SerializableWithInvalidMember), typeof(InvalidDataContractException), @"Type 'System.Runtime.Serialization.Xml.XsdDataContractExporterTests.ExporterTypesTests+NoDataContractWithoutParameterlessConstructor' cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute. Alternatively, you can ensure that the type is public and has a parameterless constructor - all public members of the type will then be serialized, and no attributes will be required.")] diff --git a/src/libraries/tests.proj b/src/libraries/tests.proj index 47fc849..21221cf 100644 --- a/src/libraries/tests.proj +++ b/src/libraries/tests.proj @@ -545,6 +545,10 @@ + + + + diff --git a/src/mono/wasi/build/WasiApp.targets b/src/mono/wasi/build/WasiApp.targets index 6085aa2..81b5b8a 100644 --- a/src/mono/wasi/build/WasiApp.targets +++ b/src/mono/wasi/build/WasiApp.targets @@ -354,6 +354,7 @@ InvariantGlobalization="$(InvariantGlobalization)" SatelliteAssemblies="@(_WasmSatelliteAssemblies)" IcuDataFileNames="@(WasmIcuDataFileNames)" + FilesToIncludeInFileSystem="@(WasmFilesToIncludeInFileSystem)" ExtraFilesToDeploy="@(WasmExtraFilesToDeploy)" NativeAssets="@(WasmNativeAsset)" DebugLevel="$(WasmDebugLevel)" diff --git a/src/tasks/WasmAppBuilder/WasmAppBuilder.cs b/src/tasks/WasmAppBuilder/WasmAppBuilder.cs index b744139..40a74d7 100644 --- a/src/tasks/WasmAppBuilder/WasmAppBuilder.cs +++ b/src/tasks/WasmAppBuilder/WasmAppBuilder.cs @@ -18,7 +18,6 @@ namespace Microsoft.WebAssembly.Build.Tasks; public class WasmAppBuilder : WasmAppBuilderBaseTask { - public ITaskItem[]? FilesToIncludeInFileSystem { get; set; } public ITaskItem[]? RemoteSources { get; set; } public bool IncludeThreadsWorker {get; set; } public int PThreadPoolSize {get; set; } @@ -265,7 +264,7 @@ public class WasmAppBuilder : WasmAppBuilderBaseTask } }); - if (FilesToIncludeInFileSystem != null) + if (FilesToIncludeInFileSystem.Length > 0) { string supportFilesDir = Path.Combine(AppDir, "supportFiles"); Directory.CreateDirectory(supportFilesDir); @@ -366,29 +365,26 @@ public class WasmAppBuilder : WasmAppBuilderBaseTask Utils.CopyIfDifferent(tmpMonoConfigPath, monoConfigPath, useHash: false); _fileWrites.Add(monoConfigPath); - if (ExtraFilesToDeploy != null) + foreach (ITaskItem item in ExtraFilesToDeploy!) { - foreach (ITaskItem item in ExtraFilesToDeploy!) - { - string src = item.ItemSpec; - string dst; - - string tgtPath = item.GetMetadata("TargetPath"); - if (!string.IsNullOrEmpty(tgtPath)) - { - dst = Path.Combine(AppDir!, tgtPath); - string? dstDir = Path.GetDirectoryName(dst); - if (!string.IsNullOrEmpty(dstDir) && !Directory.Exists(dstDir)) - Directory.CreateDirectory(dstDir!); - } - else - { - dst = Path.Combine(AppDir!, Path.GetFileName(src)); - } + string src = item.ItemSpec; + string dst; - if (!FileCopyChecked(src, dst, "ExtraFilesToDeploy")) - return false; + string tgtPath = item.GetMetadata("TargetPath"); + if (!string.IsNullOrEmpty(tgtPath)) + { + dst = Path.Combine(AppDir!, tgtPath); + string? dstDir = Path.GetDirectoryName(dst); + if (!string.IsNullOrEmpty(dstDir) && !Directory.Exists(dstDir)) + Directory.CreateDirectory(dstDir!); } + else + { + dst = Path.Combine(AppDir!, Path.GetFileName(src)); + } + + if (!FileCopyChecked(src, dst, "ExtraFilesToDeploy")) + return false; } UpdateRuntimeConfigJson(); diff --git a/src/tasks/WasmAppBuilder/WasmAppBuilderBaseTask.cs b/src/tasks/WasmAppBuilder/WasmAppBuilderBaseTask.cs index 5372ee5..4eb709a 100644 --- a/src/tasks/WasmAppBuilder/WasmAppBuilderBaseTask.cs +++ b/src/tasks/WasmAppBuilder/WasmAppBuilderBaseTask.cs @@ -39,6 +39,7 @@ public abstract class WasmAppBuilderBaseTask : Task public int DebugLevel { get; set; } public ITaskItem[] SatelliteAssemblies { get; set; } = Array.Empty(); public bool InvariantGlobalization { get; set; } + public ITaskItem[] FilesToIncludeInFileSystem { get; set; } = Array.Empty(); public ITaskItem[] ExtraFilesToDeploy { get; set; } = Array.Empty(); public string? DefaultHostConfig { get; set; } diff --git a/src/tasks/WasmAppBuilder/wasi/WasiAppBuilder.cs b/src/tasks/WasmAppBuilder/wasi/WasiAppBuilder.cs index 8ad5ee7..5d13cba 100644 --- a/src/tasks/WasmAppBuilder/wasi/WasiAppBuilder.cs +++ b/src/tasks/WasmAppBuilder/wasi/WasiAppBuilder.cs @@ -62,6 +62,7 @@ public class WasiAppBuilder : WasmAppBuilderBaseTask } } + // TODO: Files on disk are not solved for IsSingleFileBundle yet foreach (ITaskItem item in NativeAssets) { string dest = Path.Combine(AppDir, Path.GetFileName(item.ItemSpec)); @@ -77,30 +78,43 @@ public class WasiAppBuilder : WasmAppBuilderBaseTask FileCopyChecked(args.fullPath, Path.Combine(directory, name), "SatelliteAssemblies"); }); - foreach (ITaskItem item in ExtraFilesToDeploy!) - { - string src = item.ItemSpec; - string dst; + if (!DeployFiles(ExtraFilesToDeploy, nameof(ExtraFilesToDeploy))) + return false; + if (!DeployFiles(FilesToIncludeInFileSystem, nameof(FilesToIncludeInFileSystem))) + return false; - string tgtPath = item.GetMetadata("TargetPath"); - if (!string.IsNullOrEmpty(tgtPath)) - { - dst = Path.Combine(AppDir!, tgtPath); - string? dstDir = Path.GetDirectoryName(dst); - if (!string.IsNullOrEmpty(dstDir) && !Directory.Exists(dstDir)) - Directory.CreateDirectory(dstDir!); - } - else + Directory.CreateDirectory(Path.Combine(AppDir, "tmp")); + + UpdateRuntimeConfigJson(); + return !Log.HasLoggedErrors; + + bool DeployFiles(ITaskItem[] fileItems, string label) + { + foreach (ITaskItem item in fileItems) { - dst = Path.Combine(AppDir!, Path.GetFileName(src)); + string src = item.ItemSpec; + string dst; + + string tgtPath = item.GetMetadata("TargetPath"); + if (!string.IsNullOrEmpty(tgtPath)) + { + dst = Path.Combine(AppDir!, tgtPath); + string? dstDir = Path.GetDirectoryName(dst); + if (!string.IsNullOrEmpty(dstDir) && !Directory.Exists(dstDir)) + Directory.CreateDirectory(dstDir!); + } + else + { + dst = Path.Combine(AppDir!, Path.GetFileName(src)); + } + + if (!FileCopyChecked(src, dst, label)) + return false; } - if (!FileCopyChecked(src, dst, "ExtraFilesToDeploy")) - return false; + return true; } - UpdateRuntimeConfigJson(); - return !Log.HasLoggedErrors; } protected override void AddToRuntimeConfig(JsonObject wasmHostProperties, JsonArray runtimeArgsArray, JsonArray perHostConfigs)