From e123258f1f0eec355bdeb16807f161e53808e8de Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Mon, 13 Jun 2022 21:35:18 +0000 Subject: [PATCH 1/2] [wasm] Enable some previously failing WBT/AOT tests on windows Fixes https://github.com/dotnet/runtime/issues/61725 . --- src/tests/BuildWasmApps/Wasm.Build.Tests/MainWithArgsTests.cs | 2 -- .../NativeRebuildTests/ReferenceNewAssemblyRebuildTest.cs | 1 - src/tests/BuildWasmApps/Wasm.Build.Tests/WasmBuildAppTest.cs | 2 -- 3 files changed, 5 deletions(-) diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/MainWithArgsTests.cs b/src/tests/BuildWasmApps/Wasm.Build.Tests/MainWithArgsTests.cs index 4411b821634b75..b21c3db75c55c6 100644 --- a/src/tests/BuildWasmApps/Wasm.Build.Tests/MainWithArgsTests.cs +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/MainWithArgsTests.cs @@ -25,7 +25,6 @@ public MainWithArgsTests(ITestOutputHelper output, SharedBuildPerTestClassFixtur ).WithRunHosts(host).UnwrapItemsAsArrays(); [Theory] - [ActiveIssue("https://github.com/dotnet/runtime/issues/61725", TestPlatforms.Windows)] [MemberData(nameof(MainWithArgsTestData), parameters: new object[] { /*aot*/ false, RunHost.All })] [MemberData(nameof(MainWithArgsTestData), parameters: new object[] { /*aot*/ true, RunHost.All })] public void AsyncMainWithArgs(BuildArgs buildArgs, string[] args, RunHost host, string id) @@ -40,7 +39,6 @@ public static async System.Threading.Tasks.Task Main(string[] args) buildArgs, args, host, id); [Theory] - [ActiveIssue("https://github.com/dotnet/runtime/issues/61725", TestPlatforms.Windows)] [MemberData(nameof(MainWithArgsTestData), parameters: new object[] { /*aot*/ false, RunHost.All })] [MemberData(nameof(MainWithArgsTestData), parameters: new object[] { /*aot*/ true, RunHost.All })] public void TopLevelWithArgs(BuildArgs buildArgs, string[] args, RunHost host, string id) diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/NativeRebuildTests/ReferenceNewAssemblyRebuildTest.cs b/src/tests/BuildWasmApps/Wasm.Build.Tests/NativeRebuildTests/ReferenceNewAssemblyRebuildTest.cs index d920ac400559ab..6f733b14c33ec3 100644 --- a/src/tests/BuildWasmApps/Wasm.Build.Tests/NativeRebuildTests/ReferenceNewAssemblyRebuildTest.cs +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/NativeRebuildTests/ReferenceNewAssemblyRebuildTest.cs @@ -20,7 +20,6 @@ public ReferenceNewAssemblyRebuildTest(ITestOutputHelper output, SharedBuildPerT } [Theory] - [ActiveIssue("https://github.com/dotnet/runtime/issues/61725", TestPlatforms.Windows)] [MemberData(nameof(NativeBuildData))] public void ReferenceNewAssembly(BuildArgs buildArgs, bool nativeRelink, bool invariant, RunHost host, string id) { diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/WasmBuildAppTest.cs b/src/tests/BuildWasmApps/Wasm.Build.Tests/WasmBuildAppTest.cs index 1e8f600ec86b03..8a2eaa9f8b0b1c 100644 --- a/src/tests/BuildWasmApps/Wasm.Build.Tests/WasmBuildAppTest.cs +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/WasmBuildAppTest.cs @@ -16,7 +16,6 @@ public WasmBuildAppTest(ITestOutputHelper output, SharedBuildPerTestClassFixture {} [Theory] - [ActiveIssue("https://github.com/dotnet/runtime/issues/61725", TestPlatforms.Windows)] [MemberData(nameof(MainMethodTestData), parameters: new object[] { /*aot*/ true, RunHost.All })] [MemberData(nameof(MainMethodTestData), parameters: new object[] { /*aot*/ false, RunHost.All })] public void TopLevelMain(BuildArgs buildArgs, RunHost host, string id) @@ -25,7 +24,6 @@ public void TopLevelMain(BuildArgs buildArgs, RunHost host, string id) buildArgs, host, id); [Theory] - [ActiveIssue("https://github.com/dotnet/runtime/issues/61725", TestPlatforms.Windows)] [MemberData(nameof(MainMethodTestData), parameters: new object[] { /*aot*/ true, RunHost.All })] [MemberData(nameof(MainMethodTestData), parameters: new object[] { /*aot*/ false, RunHost.All })] public void AsyncMain(BuildArgs buildArgs, RunHost host, string id) From de658eb8ba4e5baf2323e2197675eceb765d69ee Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Mon, 13 Jun 2022 21:35:58 +0000 Subject: [PATCH 2/2] [wasm] WBT: Fix a failing satellite assembly test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The test fails because it is trying to find the string `got: こんにちは` in the app output, but it sees `?????`. This is due to xharness not setting the console output to UTF8, and then the tests not doing the same. Instead of that, we can move the check to be in the app itself, thus removing the need for any of this. Fixes https://github.com/dotnet/runtime/issues/58709 . --- .../SatelliteAssembliesTests.cs | 47 ++++++++++--------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/SatelliteAssembliesTests.cs b/src/tests/BuildWasmApps/Wasm.Build.Tests/SatelliteAssembliesTests.cs index 959a79221af885..1723e651acba3a 100644 --- a/src/tests/BuildWasmApps/Wasm.Build.Tests/SatelliteAssembliesTests.cs +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/SatelliteAssembliesTests.cs @@ -22,21 +22,19 @@ public SatelliteAssembliesTests(ITestOutputHelper output, SharedBuildPerTestClas public static IEnumerable SatelliteAssemblyTestData(bool aot, bool relinking, RunHost host) => ConfigWithAOTData(aot) .Multiply( - new object?[] { relinking, "es-ES", "got: hola" }, - new object?[] { relinking, null, "got: hello" }, - new object?[] { relinking, "ja-JP", "got: \u3053\u3093\u306B\u3061\u306F" }) + new object?[] { relinking, "es-ES" }, + new object?[] { relinking, null }, + new object?[] { relinking, "ja-JP" }) .WithRunHosts(host) .UnwrapItemsAsArrays(); [Theory] - [ActiveIssue("https://github.com/dotnet/runtime/issues/61725", TestPlatforms.Windows)] [MemberData(nameof(SatelliteAssemblyTestData), parameters: new object[] { /*aot*/ false, /*relinking*/ false, RunHost.All })] [MemberData(nameof(SatelliteAssemblyTestData), parameters: new object[] { /*aot*/ false, /*relinking*/ true, RunHost.All })] [MemberData(nameof(SatelliteAssemblyTestData), parameters: new object[] { /*aot*/ true, /*relinking*/ false, RunHost.All })] public void ResourcesFromMainAssembly(BuildArgs buildArgs, bool nativeRelink, string? argCulture, - string expectedOutput, RunHost host, string id) { @@ -62,25 +60,21 @@ public void ResourcesFromMainAssembly(BuildArgs buildArgs, }, DotnetWasmFromRuntimePack: dotnetWasmFromRuntimePack)); - string output = RunAndTestWasmApp( - buildArgs, expectedExitCode: 42, - args: argCulture, - host: host, id: id, - // check that downloading assets doesn't have timing race conditions - extraXHarnessMonoArgs: "--fetch-random-delay=200"); - - Assert.Contains(expectedOutput, output); + RunAndTestWasmApp( + buildArgs, expectedExitCode: 42, + args: argCulture, + host: host, id: id, + // check that downloading assets doesn't have timing race conditions + extraXHarnessMonoArgs: "--fetch-random-delay=200"); } [Theory] - [ActiveIssue("https://github.com/dotnet/runtime/issues/61725", TestPlatforms.Windows)] [MemberData(nameof(SatelliteAssemblyTestData), parameters: new object[] { /*aot*/ false, /*relinking*/ false, RunHost.All })] [MemberData(nameof(SatelliteAssemblyTestData), parameters: new object[] { /*aot*/ false, /*relinking*/ true, RunHost.All })] [MemberData(nameof(SatelliteAssemblyTestData), parameters: new object[] { /*aot*/ true, /*relinking*/ false, RunHost.All })] public void ResourcesFromProjectReference(BuildArgs buildArgs, bool nativeRelink, string? argCulture, - string expectedOutput, RunHost host, string id) { @@ -107,12 +101,10 @@ public void ResourcesFromProjectReference(BuildArgs buildArgs, CreateProgramForCultureTest(_projectDir, "LibraryWithResources.resx.words", "LibraryWithResources.Class1"); })); - string output = RunAndTestWasmApp(buildArgs, - expectedExitCode: 42, - args: argCulture, - host: host, id: id); - - Assert.Contains(expectedOutput, output); + RunAndTestWasmApp(buildArgs, + expectedExitCode: 42, + args: argCulture, + host: host, id: id); } #pragma warning disable xUnit1026 @@ -180,12 +172,23 @@ public class TestClass { public static int Main(string[] args) { + string expected; if (args.Length == 1) { string cultureToTest = args[0]; var newCulture = new CultureInfo(cultureToTest); Thread.CurrentThread.CurrentCulture = newCulture; Thread.CurrentThread.CurrentUICulture = newCulture; + + if (cultureToTest == ""es-ES"") + expected = ""hola""; + else if (cultureToTest == ""ja-JP"") + expected = ""\u3053\u3093\u306B\u3061\u306F""; + else + throw new Exception(""Cannot determine the expected output for {cultureToTest}""); + + } else { + expected = ""hello""; } var currentCultureName = Thread.CurrentThread.CurrentCulture.Name; @@ -193,7 +196,7 @@ public static int Main(string[] args) var rm = new ResourceManager(""##RESOURCE_NAME##"", typeof(##TYPE_NAME##).Assembly); Console.WriteLine($""For '{currentCultureName}' got: {rm.GetString(""hello"")}""); - return 42; + return rm.GetString(""hello"") == expected ? 42 : -1; } } }";