Skip to content

Commit befeec4

Browse files
ilonatommyradical
andauthored
[wasm][libs] Fix WasmAppHost, and AppBundle for library tests (#77719)
* Removed fixed path separator + duplicated `browser-wasm`. * Working fix. * Fix for different `OutputPath` conventions. * Fixing the url printed on the console. * `ProcessQueryArguments` in test-main.js forces debug to be the 1st arg. * Removing special case for WBT. * We cannot skip checking for missing browser-wasm. * Both runArgs and queryArgs are important when running tests. * Revert changes in the shipped targets and move them to tests targets. * Update src/mono/wasm/host/BrowserArguments.cs Co-authored-by: Ankit Jain <[email protected]> * Fetch does not work for node<18 => get rid of json. * Separated runtime args from app args for both hosts. * Revert 7.0 file. * Focusing on enabling libs debugging for browser. * Should have been reverted with dae5d74. * Fix CI lib tests: avoid referencing undefined properties. * In all the cases runArgs should be first populated by defaults that can be later overwritten. * Update src/mono/wasm/test-main.js Co-authored-by: Ankit Jain <[email protected]> --------- Co-authored-by: Ankit Jain <[email protected]>
1 parent 4b5029c commit befeec4

File tree

2 files changed

+19
-18
lines changed

2 files changed

+19
-18
lines changed

eng/testing/tests.wasm.targets

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
('$(ContinuousIntegrationBuild)' != 'true' or Exists('/.dockerenv')) and
3737
'$(Scenario)' == 'WasmTestOnBrowser'">true</InstallChromeForTests>
3838
<_XHarnessTestsTimeout>00:30:00</_XHarnessTestsTimeout>
39+
<RunWorkingDirectory>$(BundleDir)</RunWorkingDirectory>
3940
</PropertyGroup>
4041

4142
<!-- On CI this is installed as part of pretest, but it should still be installed
@@ -139,10 +140,10 @@
139140
<BundleTestWasmAppDependsOn Condition="'$(IsBrowserWasmProject)' == 'true' and '$(BuildAOTTestsOn)' == 'local'">WasmTriggerPublishApp</BundleTestWasmAppDependsOn>
140141
<BundleTestWasmAppDependsOn Condition="'$(IsBrowserWasmProject)' == 'true' and '$(BuildAOTTestsOnHelix)' == 'true'">$(BundleTestWasmAppDependsOn);_BundleAOTTestWasmAppForHelix</BundleTestWasmAppDependsOn>
141142

142-
<RunCommand>$(WasmAppHostDir)/WasmAppHost</RunCommand>
143143
<!-- Use BundleDir here, since WasmAppDir is set in a target, and `dotnet run` reads
144144
$(Run*) without running any targets -->
145-
<RunArguments>--runtime-config $(BundleDir)/WasmTestRunner.runtimeconfig.json $(WasmHostArguments) $(StartArguments) $(WasmXHarnessMonoArgs) $(_AppArgs)</RunArguments>
145+
<_RuntimeConfigJsonPath>$([MSBuild]::NormalizePath($(BundleDir), 'WasmTestRunner.runtimeconfig.json'))</_RuntimeConfigJsonPath>
146+
<RunArguments>exec &quot;$([MSBuild]::NormalizePath($(WasmAppHostDir), 'WasmAppHost.dll'))&quot; --runtime-config &quot;$(_RuntimeConfigJsonPath)&quot; $(WasmHostArguments) $(StartArguments) $(WasmXHarnessMonoArgs) $(_AppArgs)</RunArguments>
146147
</PropertyGroup>
147148

148149
<PropertyGroup Condition="'$(BuildAOTTestsOnHelix)' == 'true'">

src/mono/wasm/test-main.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
/*****************************************************************************
1111
* Please don't use this as template for startup code.
1212
* There are simpler and better samples like src\mono\sample\wasm\browser\main.js
13-
* This one is not ES6 nor CJS, doesn't use top level await and has edge case polyfills.
13+
* This one is not ES6 nor CJS, doesn't use top level await and has edge case polyfills.
1414
* It handles strange things which happen with XHarness.
1515
****************************************************************************/
1616

@@ -63,19 +63,21 @@ async function getArgs() {
6363
queryArguments = Array.from(WScript.Arguments);
6464
}
6565

66-
let runArgs;
67-
if (queryArguments.length > 0) {
68-
runArgs = processArguments(queryArguments);
69-
} else {
70-
const response = fetch('/runArgs.json')
71-
if (!response.ok) {
72-
console.debug(`could not load /args.json: ${response.status}. Ignoring`);
66+
let runArgsJson;
67+
// ToDo: runArgs should be read for all kinds of hosts, but
68+
// fetch is added to node>=18 and current Windows's emcc node<18
69+
if (is_browser)
70+
{
71+
const response = await globalThis.fetch('./runArgs.json');
72+
if (response.ok) {
73+
runArgsJson = initRunArgs(await response.json());
74+
} else {
75+
console.debug(`could not load /runArgs.json: ${response.status}. Ignoring`);
7376
}
74-
runArgs = await response.json();
7577
}
76-
runArgs = initRunArgs(runArgs);
77-
78-
return runArgs;
78+
if (!runArgsJson)
79+
runArgsJson = initRunArgs({});
80+
return processArguments(queryArguments, runArgsJson);
7981
}
8082

8183
function initRunArgs(runArgs) {
@@ -95,9 +97,7 @@ function initRunArgs(runArgs) {
9597
return runArgs;
9698
}
9799

98-
function processArguments(incomingArguments) {
99-
const runArgs = initRunArgs({});
100-
100+
function processArguments(incomingArguments, runArgs) {
101101
console.log("Incoming arguments: " + incomingArguments.join(' '));
102102
while (incomingArguments && incomingArguments.length > 0) {
103103
const currentArg = incomingArguments[0];
@@ -343,4 +343,4 @@ async function run() {
343343
}
344344
}
345345

346-
run();
346+
run();

0 commit comments

Comments
 (0)