Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[browser] Fix encoding problem when publishing #82833

Merged
merged 11 commits into from
Mar 16, 2023
26 changes: 18 additions & 8 deletions src/mono/wasm/Wasm.Build.Tests/BuildPublishTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,23 @@ namespace Wasm.Build.Tests
{
public class BuildPublishTests : NativeRebuildTestsBase
{
private readonly char unicodeChar = '煉';

public BuildPublishTests(ITestOutputHelper output, SharedBuildPerTestClassFixture buildContext)
: base(output, buildContext)
{
}

[Theory]
[BuildAndRun(host: RunHost.Chrome, aot: false, config: "Release")]
[BuildAndRun(host: RunHost.Chrome, aot: false, config: "Debug")]
public void BuildThenPublishNoAOT(BuildArgs buildArgs, RunHost host, string id)
[BuildAndRun(host: RunHost.Chrome, aot: false, config: "Release", parameters: new object[] { false })]
radical marked this conversation as resolved.
Show resolved Hide resolved
[BuildAndRun(host: RunHost.Chrome, aot: false, config: "Debug", parameters: new object[] { false })]
[BuildAndRun(host: RunHost.Chrome, aot: false, config: "Release", parameters: new object[] { true })]
[BuildAndRun(host: RunHost.Chrome, aot: false, config: "Debug", parameters: new object[] { true })]
public void BuildThenPublishNoAOT(BuildArgs buildArgs, bool testsUnicode, RunHost host, string id)
{
string projectName = $"build_publish_{buildArgs.Config}";
string projectName = testsUnicode ?
$"build_publish_{buildArgs.Config}{unicodeChar}" :
radical marked this conversation as resolved.
Show resolved Hide resolved
$"build_publish_{buildArgs.Config}";

buildArgs = buildArgs with { ProjectName = projectName };
buildArgs = ExpandBuildArgs(buildArgs);
Expand Down Expand Up @@ -70,11 +76,15 @@ void Run() => RunAndTestWasmApp(
}

[Theory]
[BuildAndRun(host: RunHost.Chrome, aot: true, config: "Release")]
[BuildAndRun(host: RunHost.Chrome, aot: true, config: "Debug")]
public void BuildThenPublishWithAOT(BuildArgs buildArgs, RunHost host, string id)
[BuildAndRun(host: RunHost.Chrome, aot: true, config: "Release", parameters: new object[] { false })]
[BuildAndRun(host: RunHost.Chrome, aot: true, config: "Debug", parameters: new object[] { false })]
[BuildAndRun(host: RunHost.Chrome, aot: true, config: "Release", parameters: new object[] { true })]
[BuildAndRun(host: RunHost.Chrome, aot: true, config: "Debug", parameters: new object[] { true })]
public void BuildThenPublishWithAOT(BuildArgs buildArgs, bool testsUnicode, RunHost host, string id)
{
string projectName = $"build_publish_{buildArgs.Config}";
string projectName = testsUnicode ?
$"build_publish_{buildArgs.Config}{unicodeChar}" :
$"build_publish_{buildArgs.Config}";

buildArgs = buildArgs with { ProjectName = projectName };
buildArgs = ExpandBuildArgs(buildArgs, extraProperties: "<_WasmDevel>true</_WasmDevel>");
Expand Down
3 changes: 3 additions & 0 deletions src/tasks/Common/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ static string CreateTemporaryBatchFile(string command)
using StreamWriter sw = new(file);
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
// set encoding to UTF-8 -> full Unicode support is needed for usernames -
// `command` contains tmp dir path with the username
sw.WriteLine("chcp 65001>nul");
ilonatommy marked this conversation as resolved.
Show resolved Hide resolved
sw.WriteLine("setlocal");
sw.WriteLine("set errorlevel=dummy");
sw.WriteLine("set errorlevel=");
Expand Down