From befeec4bb8e566e87c7f764853ac5cc9302c0776 Mon Sep 17 00:00:00 2001 From: Ilona Tomkowicz <32700855+ilonatommy@users.noreply.github.com> Date: Tue, 31 Jan 2023 14:53:15 +0100 Subject: [PATCH] [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 * 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 dae5d7460c3a23b108e1d141e72c3b0bcdc9d730. * 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 --------- Co-authored-by: Ankit Jain --- eng/testing/tests.wasm.targets | 5 +++-- src/mono/wasm/test-main.js | 32 ++++++++++++++++---------------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/eng/testing/tests.wasm.targets b/eng/testing/tests.wasm.targets index 486be5f..149d2115 100644 --- a/eng/testing/tests.wasm.targets +++ b/eng/testing/tests.wasm.targets @@ -36,6 +36,7 @@ ('$(ContinuousIntegrationBuild)' != 'true' or Exists('/.dockerenv')) and '$(Scenario)' == 'WasmTestOnBrowser'">true <_XHarnessTestsTimeout>00:30:00 + $(BundleDir) - --runtime-config $(BundleDir)/WasmTestRunner.runtimeconfig.json $(WasmHostArguments) $(StartArguments) $(WasmXHarnessMonoArgs) $(_AppArgs) + <_RuntimeConfigJsonPath>$([MSBuild]::NormalizePath($(BundleDir), 'WasmTestRunner.runtimeconfig.json')) + exec "$([MSBuild]::NormalizePath($(WasmAppHostDir), 'WasmAppHost.dll'))" --runtime-config "$(_RuntimeConfigJsonPath)" $(WasmHostArguments) $(StartArguments) $(WasmXHarnessMonoArgs) $(_AppArgs) diff --git a/src/mono/wasm/test-main.js b/src/mono/wasm/test-main.js index 8f37acc..979c8a2 100644 --- a/src/mono/wasm/test-main.js +++ b/src/mono/wasm/test-main.js @@ -10,7 +10,7 @@ /***************************************************************************** * Please don't use this as template for startup code. * There are simpler and better samples like src\mono\sample\wasm\browser\main.js - * This one is not ES6 nor CJS, doesn't use top level await and has edge case polyfills. + * This one is not ES6 nor CJS, doesn't use top level await and has edge case polyfills. * It handles strange things which happen with XHarness. ****************************************************************************/ @@ -63,19 +63,21 @@ async function getArgs() { queryArguments = Array.from(WScript.Arguments); } - let runArgs; - if (queryArguments.length > 0) { - runArgs = processArguments(queryArguments); - } else { - const response = fetch('/runArgs.json') - if (!response.ok) { - console.debug(`could not load /args.json: ${response.status}. Ignoring`); + let runArgsJson; + // ToDo: runArgs should be read for all kinds of hosts, but + // fetch is added to node>=18 and current Windows's emcc node<18 + if (is_browser) + { + const response = await globalThis.fetch('./runArgs.json'); + if (response.ok) { + runArgsJson = initRunArgs(await response.json()); + } else { + console.debug(`could not load /runArgs.json: ${response.status}. Ignoring`); } - runArgs = await response.json(); } - runArgs = initRunArgs(runArgs); - - return runArgs; + if (!runArgsJson) + runArgsJson = initRunArgs({}); + return processArguments(queryArguments, runArgsJson); } function initRunArgs(runArgs) { @@ -95,9 +97,7 @@ function initRunArgs(runArgs) { return runArgs; } -function processArguments(incomingArguments) { - const runArgs = initRunArgs({}); - +function processArguments(incomingArguments, runArgs) { console.log("Incoming arguments: " + incomingArguments.join(' ')); while (incomingArguments && incomingArguments.length > 0) { const currentArg = incomingArguments[0]; @@ -343,4 +343,4 @@ async function run() { } } -run(); \ No newline at end of file +run(); -- 2.7.4