Skip to content

Commit 01aa3d9

Browse files
authored
[wasm] Change ICU WasmBuildTests to use wasmconsole and wasmbrowser templates (#108271)
* Clean up icu tests (automatic mode). * Block the failing test, mark problems with issue links.
1 parent 84b7c2f commit 01aa3d9

19 files changed

+417
-266
lines changed

src/mono/wasm/Wasm.Build.Tests/AssertWasmSdkBundleOptions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public record AssertWasmSdkBundleOptions(
1111
bool IsPublish,
1212
string TargetFramework,
1313
string BinFrameworkDir,
14-
string? PredefinedIcudt,
14+
string? CustomIcuFile,
1515
GlobalizationMode GlobalizationMode = GlobalizationMode.Sharded,
1616
string BootJsonFileName = "blazor.boot.json",
1717
NativeFilesType ExpectedFileType = NativeFilesType.FromRuntimePack,
@@ -25,7 +25,7 @@ public record AssertWasmSdkBundleOptions(
2525
IsPublish: IsPublish,
2626
TargetFramework: TargetFramework,
2727
BinFrameworkDir: BinFrameworkDir,
28-
PredefinedIcudt: PredefinedIcudt,
28+
CustomIcuFile: CustomIcuFile,
2929
GlobalizationMode: GlobalizationMode,
3030
ExpectedFileType: ExpectedFileType,
3131
RuntimeType: RuntimeType,

src/mono/wasm/Wasm.Build.Tests/Blazor/BlazorBuildOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public record BlazorBuildOptions
1818
bool ExpectFingerprintOnDotnetJs = false,
1919
RuntimeVariant RuntimeType = RuntimeVariant.SingleThreaded,
2020
GlobalizationMode GlobalizationMode = GlobalizationMode.Sharded,
21-
string PredefinedIcudt = "",
21+
string CustomIcuFile = "",
2222
bool AssertAppBundle = true,
2323
string? BinFrameworkDir = null
2424
);

src/mono/wasm/Wasm.Build.Tests/Blazor/BlazorWasmProjectProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public void AssertBundle(BlazorBuildOptions options)
2020
TargetFramework: options.TargetFramework,
2121
BinFrameworkDir: options.BinFrameworkDir ?? FindBinFrameworkDir(options.Config, options.IsPublish, options.TargetFramework),
2222
GlobalizationMode: options.GlobalizationMode,
23-
PredefinedIcudt: options.PredefinedIcudt,
23+
CustomIcuFile: options.CustomIcuFile,
2424
ExpectFingerprintOnDotnetJs: options.ExpectFingerprintOnDotnetJs,
2525
ExpectedFileType: options.ExpectedFileType,
2626
RuntimeType: options.RuntimeType,

src/mono/wasm/Wasm.Build.Tests/Blazor/IcuShardingTests.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ public async Task CustomIcuFileFromRuntimePack(string config, string fileName)
3232
id,
3333
config,
3434
WarnAsError: true,
35-
GlobalizationMode: GlobalizationMode.PredefinedIcu,
36-
PredefinedIcudt: fileName
35+
GlobalizationMode: GlobalizationMode.Custom,
36+
CustomIcuFile: fileName
3737
);
3838
AddItemsPropertiesToProject(
3939
projectFile,
@@ -65,8 +65,8 @@ public void NonExistingCustomFileAssertError(string config, string fileName, boo
6565
id,
6666
config,
6767
WarnAsError: false,
68-
GlobalizationMode: GlobalizationMode.PredefinedIcu,
69-
PredefinedIcudt: fileName
68+
GlobalizationMode: GlobalizationMode.Custom,
69+
CustomIcuFile: fileName
7070
));
7171
}
7272
catch (XunitException ex)
@@ -104,8 +104,8 @@ public async Task CustomFileNotFromRuntimePackAbsolutePath(string config)
104104
id,
105105
config,
106106
WarnAsError: false,
107-
GlobalizationMode: GlobalizationMode.PredefinedIcu,
108-
PredefinedIcudt: IcuTestsBase.CustomIcuPath
107+
GlobalizationMode: GlobalizationMode.Custom,
108+
CustomIcuFile: IcuTestsBase.CustomIcuPath
109109
));
110110
await BlazorRunForBuildWithDotnetRun(new BlazorRunOptions() { Config = config });
111111
}

src/mono/wasm/Wasm.Build.Tests/BrowserRunner.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,13 @@ public async Task<IBrowser> SpawnBrowserAsync(
104104
string browserUrl,
105105
bool headless = true,
106106
int timeout = 10000,
107-
int maxRetries = 3
107+
int maxRetries = 3,
108+
string language = "en-US"
108109
) {
109110
var url = new Uri(browserUrl);
110111
Playwright = await Microsoft.Playwright.Playwright.CreateAsync();
111112
// codespaces: ignore certificate error -> Microsoft.Playwright.PlaywrightException : net::ERR_CERT_AUTHORITY_INVALID
112-
string[] chromeArgs = new[] { $"--explicitly-allowed-ports={url.Port}", "--ignore-certificate-errors" };
113+
string[] chromeArgs = new[] { $"--explicitly-allowed-ports={url.Port}", "--ignore-certificate-errors", $"--lang={language}" };
113114
_testOutput.WriteLine($"Launching chrome ('{s_chromePath.Value}') via playwright with args = {string.Join(',', chromeArgs)}");
114115

115116
int attempt = 0;
@@ -146,14 +147,15 @@ public async Task<IPage> RunAsync(
146147
ToolCommand cmd,
147148
string args,
148149
bool headless = true,
150+
string language = "en-US",
149151
Action<IPage, IConsoleMessage>? onConsoleMessage = null,
150152
Action<string>? onServerMessage = null,
151153
Action<string>? onError = null,
152154
Func<string, string>? modifyBrowserUrl = null)
153155
{
154156
var urlString = await StartServerAndGetUrlAsync(cmd, args, onServerMessage);
155-
var browser = await SpawnBrowserAsync(urlString, headless);
156-
var context = await browser.NewContextAsync();
157+
var browser = await SpawnBrowserAsync(urlString, headless, language: language);
158+
var context = await browser.NewContextAsync(new BrowserNewContextOptions { Locale = language });
157159
return await RunAsync(context, urlString, headless, onConsoleMessage, onError, modifyBrowserUrl);
158160
}
159161

src/mono/wasm/Wasm.Build.Tests/BuildProjectOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public record BuildProjectOptions
1313
Action? InitProject = null,
1414
bool? DotnetWasmFromRuntimePack = null,
1515
GlobalizationMode GlobalizationMode = GlobalizationMode.Sharded,
16-
string? PredefinedIcudt = null,
16+
string? CustomIcuFile = null,
1717
bool UseCache = true,
1818
bool ExpectSuccess = true,
1919
bool AssertAppBundle = true,

src/mono/wasm/Wasm.Build.Tests/BuildTestBase.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -630,8 +630,9 @@ public static int Main()
630630
public record BuildArgs(string ProjectName,
631631
string Config,
632632
bool AOT,
633-
string ProjectFileContents,
634-
string? ExtraBuildArgs);
633+
string Id,
634+
string? ExtraBuildArgs,
635+
string? ProjectFileContents=null);
635636
public record BuildProduct(string ProjectDir, string LogFile, bool Result, string BuildOutput);
636637

637638
public enum NativeFilesType { FromRuntimePack, Relinked, AOT };

src/mono/wasm/Wasm.Build.Tests/Common/AssertBundleOptionsBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public abstract record AssertBundleOptionsBase(
1212
bool IsPublish,
1313
string TargetFramework,
1414
string BinFrameworkDir,
15-
string? PredefinedIcudt,
15+
string? CustomIcuFile,
1616
string BundleDirName = "wwwroot",
1717
GlobalizationMode GlobalizationMode = GlobalizationMode.Sharded,
1818
string BootJsonFileName = "blazor.boot.json",

src/mono/wasm/Wasm.Build.Tests/Common/AssertTestMainJsAppBundleOptions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public record AssertTestMainJsAppBundleOptions(
1010
bool IsPublish,
1111
string TargetFramework,
1212
string BinFrameworkDir,
13-
string? PredefinedIcudt,
13+
string? CustomIcuFile,
1414
string ProjectName,
1515
string MainJS,
1616
GlobalizationMode GlobalizationMode = GlobalizationMode.Sharded,
@@ -28,7 +28,7 @@ public record AssertTestMainJsAppBundleOptions(
2828
IsPublish: IsPublish,
2929
TargetFramework: TargetFramework,
3030
BinFrameworkDir: BinFrameworkDir,
31-
PredefinedIcudt: PredefinedIcudt,
31+
CustomIcuFile: CustomIcuFile,
3232
GlobalizationMode: GlobalizationMode,
3333
ExpectedFileType: ExpectedFileType,
3434
RuntimeType: RuntimeType,

src/mono/wasm/Wasm.Build.Tests/Common/GlobalizationMode.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ public enum GlobalizationMode
99
Sharded, // chosen based on locale
1010
Invariant, // no icu
1111
FullIcu, // full icu data: icudt.dat is loaded
12-
PredefinedIcu, // user set WasmIcuDataFileName/BlazorIcuDataFileName value and we are loading that file
12+
Custom, // user set WasmIcuDataFileName/BlazorIcuDataFileName value and we are loading that file
1313
Hybrid // reduced icu, missing data is provided by platform-native functions (web api for wasm)
1414
};

0 commit comments

Comments
 (0)