Skip to content

Commit

Permalink
tests for more unicode characters (#101059)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelsavara authored Apr 15, 2024
1 parent 3d0da2c commit a1180e8
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/mono/wasm/Wasm.Build.Tests/Blazor/BuildPublishTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public BuildPublishTests(ITestOutputHelper output, SharedBuildPerTestClassFixtur
[InlineData("Release")]
public async Task DefaultTemplate_WithoutWorkload(string config)
{
string id = $"blz_no_workload_{config}_{GetRandomId()}_{s_unicodeChar}";
string id = $"blz_no_workload_{config}_{GetRandomId()}_{s_unicodeChars}";
CreateBlazorWasmTemplateProject(id);

BlazorBuild(new BlazorBuildOptions(id, config));
Expand Down Expand Up @@ -63,7 +63,7 @@ public static TheoryData<string, bool> TestDataForDefaultTemplate_WithWorkload(b
public void DefaultTemplate_NoAOT_WithWorkload(string config, bool testUnicode)
{
string id = testUnicode ?
$"blz_no_aot_{config}_{GetRandomId()}_{s_unicodeChar}" :
$"blz_no_aot_{config}_{GetRandomId()}_{s_unicodeChars}" :
$"blz_no_aot_{config}_{GetRandomId()}";
CreateBlazorWasmTemplateProject(id);

Expand All @@ -84,7 +84,7 @@ public void DefaultTemplate_NoAOT_WithWorkload(string config, bool testUnicode)
public void DefaultTemplate_AOT_WithWorkload(string config, bool testUnicode)
{
string id = testUnicode ?
$"blz_aot_{config}_{GetRandomId()}_{s_unicodeChar}" :
$"blz_aot_{config}_{GetRandomId()}_{s_unicodeChars}" :
$"blz_aot_{config}_{GetRandomId()}";
CreateBlazorWasmTemplateProject(id);

Expand Down
2 changes: 1 addition & 1 deletion src/mono/wasm/Wasm.Build.Tests/Blazor/MiscTests3.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public MiscTests3(ITestOutputHelper output, SharedBuildPerTestClassFixture build
public async Task WithDllImportInMainAssembly(string config, bool build, bool publish)
{
// Based on https://github.com/dotnet/runtime/issues/59255
string id = $"blz_dllimp_{config}_{s_unicodeChar}";
string id = $"blz_dllimp_{config}_{s_unicodeChars}";
if (build && publish)
id += "build_then_publish";
else if (build)
Expand Down
2 changes: 1 addition & 1 deletion src/mono/wasm/Wasm.Build.Tests/BuildPublishTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ void CheckOutputForNativeBuild(bool expectAOT, bool expectRelinking, BuildArgs b
{
if (testUnicode)
{
string projectNameCore = buildArgs.ProjectName.Trim(new char[] {s_unicodeChar});
string projectNameCore = buildArgs.ProjectName.Replace(s_unicodeChars, "");
TestUtils.AssertMatches(@$"{projectNameCore}\S+.dll -> {projectNameCore}\S+.dll.bc", buildOutput, contains: expectAOT);
TestUtils.AssertMatches(@$"{projectNameCore}\S+.dll.bc -> {projectNameCore}\S+.dll.o", buildOutput, contains: expectAOT);
}
Expand Down
6 changes: 3 additions & 3 deletions src/mono/wasm/Wasm.Build.Tests/BuildTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public abstract class BuildTestBase : IClassFixture<SharedBuildPerTestClassFixtu
public const string DefaultTargetFrameworkForBlazor = "net9.0";
public const string TargetFrameworkForTasks = "net9.0";
private const string DefaultEnvironmentLocale = "en-US";
protected static readonly char s_unicodeChar = '\u7149';
protected static readonly string s_unicodeChars = "\u9FC0\u8712\u679B\u906B\u486B\u7149";
protected static readonly bool s_skipProjectCleanup;
protected static readonly string s_xharnessRunnerCommand;
protected readonly ITestOutputHelper _testOutput;
Expand Down Expand Up @@ -239,10 +239,10 @@ protected string RunAndTestWasmApp(BuildArgs buildArgs,

TestUtils.AssertSubstring("AOT: image 'System.Private.CoreLib' found.", output, contains: buildArgs.AOT);

if (s_isWindows && buildArgs.ProjectName.Contains(s_unicodeChar))
if (s_isWindows && buildArgs.ProjectName.Contains(s_unicodeChars))
{
// unicode chars in output on Windows are decoded in unknown way, so finding utf8 string is more complicated
string projectNameCore = buildArgs.ProjectName.Trim(new char[] {s_unicodeChar});
string projectNameCore = buildArgs.ProjectName.Replace(s_unicodeChars, "");
TestUtils.AssertMatches(@$"AOT: image '{projectNameCore}\S+' found.", output, contains: buildArgs.AOT);
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ protected BuildArgs GenerateProjectContents(BuildArgs buildArgs, bool nativeReli

// appending UTF-8 char makes sure project build&publish under all types of paths is supported
protected string GetTestProjectPath(string prefix, string config, bool appendUnicode=true) =>
appendUnicode ? $"{prefix}_{config}_{s_unicodeChar}" : $"{prefix}_{config}";
appendUnicode ? $"{prefix}_{config}_{s_unicodeChars}" : $"{prefix}_{config}";

}
}

0 comments on commit a1180e8

Please sign in to comment.