From b78c830d5aa5449a1dd696973348be9957cb26e6 Mon Sep 17 00:00:00 2001 From: Daniel-Genkin Date: Tue, 15 Jun 2021 10:44:32 -0400 Subject: [PATCH 01/25] Did some cleanup --- src/mono/wasm/runtime-test.js | 239 +++++++++++++++++++--------------- 1 file changed, 136 insertions(+), 103 deletions(-) diff --git a/src/mono/wasm/runtime-test.js b/src/mono/wasm/runtime-test.js index 74aa1083c033d1..174f488a67e38b 100644 --- a/src/mono/wasm/runtime-test.js +++ b/src/mono/wasm/runtime-test.js @@ -4,7 +4,8 @@ // //glue code to deal with the differences between chrome, ch, d8, jsc and sm. -var is_browser = typeof window != "undefined"; +const is_browser = typeof window != "undefined"; +const is_node = !is_browser && typeof process != 'undefined'; // if the engine doesn't provide a console if (typeof (console) === "undefined") { @@ -18,7 +19,7 @@ globalThis.testConsole = console; function proxyMethod (prefix, func, asJson) { return function() { - var args = [...arguments]; + let args = [...arguments]; if (asJson) { func (JSON.stringify({ method: prefix, @@ -82,7 +83,7 @@ if (typeof crypto === 'undefined') { } } -if (typeof performance == 'undefined') { +if (typeof performance === 'undefined') { // performance.now() is used by emscripten and doesn't work in JSC var performance = { now: function () { @@ -91,29 +92,108 @@ if (typeof performance == 'undefined') { } } +let testArguments = []; try { - if (typeof arguments == "undefined") - arguments = WScript.Arguments; - load = WScript.LoadScriptFile; - read = WScript.LoadBinaryFile; -} catch (e) { -} + if (typeof arguments === "undefined") { + if (is_node) + testArguments = process.argv.slice (2); -try { - if (typeof arguments == "undefined") { if (typeof scriptArgs !== "undefined") - arguments = scriptArgs; + testArguments = scriptArgs; + + else if (typeof WScript !== "undefined" && WScript.Arguments) + testArguments = WScript.Arguments; + } else{ + testArguments = arguments; } } catch (e) { + console.err(e) } -if (arguments === undefined) - arguments = []; +if (is_node) { + var { performance, PerformanceObserver } = require("perf_hooks"); +} + +const IOHandler = { + load: null, + read: null, + + init: function() { + // load: function that loads and executes a script + if (!globalThis.load){ + if (typeof WScript !== "undefined"){ // Chakra + IOHandler.load = WScript.LoadScriptFile; + + } else if (is_node) { // NodeJS + const fs = require ('fs'); + IOHandler.load = function (file) { + eval (fs.readFileSync(file).toString()); + }; + } else if (is_browser) { // vanila JS in browser + IOHandler.load = function (file) { + const script = document.createElement ("script"); + script.src = file; + document.head.appendChild (script); + } + } + } else { + IOHandler.load = load; // shells (v8, JavaScriptCore, Spidermonkey) + } -//end of all the nice shell glue code. + // read: function that just reads a file into a variable + if (!globalThis.read){ + if (typeof WScript !== "undefined"){ + IOHandler.read = WScript.LoadBinaryFile; // Chakra + + } else if (is_node) { // NodeJS + const fs = require ('fs'); + IOHandler.read = function (path) { + return fs.readFileSync(path); + }; + } else if (is_browser) { // vanila JS in browser + // TODO + } + } else { + IOHandler.read = read; // shells (v8, JavaScriptCore, Spidermonkey) + } + }, + + writeContentToFile: function(content, path) { + const stream = FS.open(path, 'w+'); + FS.write(stream, content, 0, content.length, 0); + FS.close(stream); + }, + + fetch: function(asset, params) { + if (is_node || is_browser) { + return fetch (asset, params); + } else { + return new Promise ((resolve, reject) => { + let bytes = null, error = null; + try { + bytes = read (asset, 'binary'); + } catch (exc) { + error = exc; + } + const response = { ok: (bytes && !error), url: asset, + arrayBuffer: function () { + return new Promise ((resolve2, reject2) => { + if (error) + reject2 (error); + else + resolve2 (new Uint8Array (bytes)); + } + )} + } + resolve (response); + }) + } + } +}; +IOHandler.init(); +// end of all the nice shell glue code. // set up a global variable to be accessed in App.init -var testArguments = arguments; function test_exit (exit_code) { if (is_browser) { @@ -144,67 +224,47 @@ function inspect_object (o) { } // Preprocess arguments -var args = testArguments; console.info("Arguments: " + testArguments); -profilers = []; -setenv = {}; -runtime_args = []; -enable_gc = true; -enable_zoneinfo = false; -working_dir='/'; -while (args !== undefined && args.length > 0) { - if (args [0].startsWith ("--profile=")) { - var arg = args [0].substring ("--profile=".length); +let profilers = []; +let setenv = {}; +let runtime_args = []; +let enable_gc = true; +let enable_zoneinfo = false; +let working_dir='/'; +while (testArguments !== undefined && testArguments.length > 0) { + if (testArguments [0].startsWith ("--profile=")) { + var arg = testArguments [0].substring ("--profile=".length); profilers.push (arg); - args = args.slice (1); - } else if (args [0].startsWith ("--setenv=")) { - var arg = args [0].substring ("--setenv=".length); + testArguments = testArguments.slice (1); + } else if (testArguments [0].startsWith ("--setenv=")) { + var arg = testArguments [0].substring ("--setenv=".length); var parts = arg.split ('='); if (parts.length != 2) - fail_exec ("Error: malformed argument: '" + args [0]); + fail_exec ("Error: malformed argument: '" + testArguments [0]); setenv [parts [0]] = parts [1]; - args = args.slice (1); - } else if (args [0].startsWith ("--runtime-arg=")) { - var arg = args [0].substring ("--runtime-arg=".length); - runtime_args.push (arg); - args = args.slice (1); - } else if (args [0] == "--disable-on-demand-gc") { + testArguments = testArguments.slice (1); + } else if (testArguments [0].startsWith ("--runtime-arg=")) { + var arg = testArguments [0].substring ("--runtime-arg=".length); + runtime_testArguments.push (arg); + testArguments = testArguments.slice (1); + } else if (testArguments [0] == "--disable-on-demand-gc") { enable_gc = false; - args = args.slice (1); - } else if (args [0].startsWith ("--working-dir=")) { - var arg = args [0].substring ("--working-dir=".length); + testArguments = testArguments.slice (1); + } else if (testArguments [0].startsWith ("--working-dir=")) { + var arg = testArguments [0].substring ("--working-dir=".length); working_dir = arg; - args = args.slice (1); + testArguments = testArguments.slice (1); } else { break; } } -testArguments = args; // cheap way to let the testing infrastructure know we're running in a browser context (or not) setenv["IsBrowserDomSupported"] = is_browser.toString().toLowerCase(); -function writeContentToFile(content, path) -{ - var stream = FS.open(path, 'w+'); - FS.write(stream, content, 0, content.length, 0); - FS.close(stream); -} - -function loadScript (url) -{ - if (is_browser) { - var script = document.createElement ("script"); - script.src = url; - document.head.appendChild (script); - } else { - load (url); - } -} - -loadScript ("mono-config.js"); +IOHandler.load ("mono-config.js"); var Module = { mainScriptUrlOrBlob: "dotnet.js", @@ -247,44 +307,16 @@ var Module = { /* var content = new Uint8Array (read (asset, 'binary')); var path = asset.substr(config.deploy_prefix.length); - writeContentToFile(content, path); + IOHandler.writeContentToFile(content, path); */ - - if (typeof window != 'undefined') { - return fetch (asset, { credentials: 'same-origin' }); - } else { - // The default mono_load_runtime_and_bcl defaults to using - // fetch to load the assets. It also provides a way to set a - // fetch promise callback. - // Here we wrap the file read in a promise and fake a fetch response - // structure. - return new Promise ((resolve, reject) => { - var bytes = null, error = null; - try { - bytes = read (asset, 'binary'); - } catch (exc) { - error = exc; - } - var response = { ok: (bytes && !error), url: asset, - arrayBuffer: function () { - return new Promise ((resolve2, reject2) => { - if (error) - reject2 (error); - else - resolve2 (new Uint8Array (bytes)); - } - )} - } - resolve (response); - }) - } + return IOHandler.fetch (asset, { credentials: 'same-origin' }); }; MONO.mono_load_runtime_and_bcl_args (config); }, }; -loadScript ("dotnet.js"); +IOHandler.load ("dotnet.js"); const IGNORE_PARAM_COUNT = -1; @@ -303,17 +335,17 @@ var App = { init (""); } - if (args.length == 0) { + if (testArguments.length == 0) { fail_exec ("Missing required --run argument"); return; } - if (args[0] == "--regression") { + if (testArguments[0] == "--regression") { var exec_regression = Module.cwrap ('mono_wasm_exec_regression', 'number', ['number', 'string']) var res = 0; try { - res = exec_regression (10, args[1]); + res = exec_regression (10, testArguments[1]); Module.print ("REGRESSION RESULT: " + res); } catch (e) { Module.print ("ABORT: " + e); @@ -330,23 +362,23 @@ var App = { if (runtime_args.length > 0) MONO.mono_wasm_set_runtime_options (runtime_args); - if (args[0] == "--run") { + if (testArguments[0] == "--run") { // Run an exe - if (args.length == 1) { + if (testArguments.length == 1) { fail_exec ("Error: Missing main executable argument."); return; } - main_assembly_name = args[1]; - var app_args = args.slice (2); + main_assembly_name = testArguments[1]; + var app_args = testArguments.slice (2); - var main_argc = args.length - 2 + 1; + var main_argc = testArguments.length - 2 + 1; var main_argv = Module._malloc (main_argc * 4); aindex = 0; - Module.setValue (main_argv + (aindex * 4), wasm_strdup (args [1]), "i32") + Module.setValue (main_argv + (aindex * 4), wasm_strdup (testArguments [1]), "i32") aindex += 1; - for (var i = 2; i < args.length; ++i) { - Module.setValue (main_argv + (aindex * 4), wasm_strdup (args [i]), "i32"); + for (var i = 2; i < testArguments.length; ++i) { + Module.setValue (main_argv + (aindex * 4), wasm_strdup (testArguments [i]), "i32"); aindex += 1; } wasm_set_main_args (main_argc, main_argv); @@ -368,10 +400,11 @@ var App = { } } else { - fail_exec ("Unhandled argument: " + args [0]); + fail_exec ("Unhandled argument: " + testArguments [0]); } }, call_test_method: function (method_name, args, signature) { + // note: arguments here is the array of arguments passsed to this function if ((arguments.length > 2) && (typeof (signature) !== "string")) throw new Error("Invalid number of arguments for call_test_method"); From 644d1657e791312297f9205c8a50abe211770315 Mon Sep 17 00:00:00 2001 From: Daniel-Genkin Date: Tue, 15 Jun 2021 12:55:11 -0400 Subject: [PATCH 02/25] faked loading async while supporting actual async loading --- src/mono/wasm/runtime-test.js | 38 ++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/src/mono/wasm/runtime-test.js b/src/mono/wasm/runtime-test.js index 174f488a67e38b..f01d119717245c 100644 --- a/src/mono/wasm/runtime-test.js +++ b/src/mono/wasm/runtime-test.js @@ -120,42 +120,42 @@ const IOHandler = { init: function() { // load: function that loads and executes a script - if (!globalThis.load){ + let loadFunc = globalThis.load; // shells (v8, JavaScriptCore, Spidermonkey) + if (!loadFunc){ if (typeof WScript !== "undefined"){ // Chakra - IOHandler.load = WScript.LoadScriptFile; + loadFunc = WScript.LoadScriptFile; } else if (is_node) { // NodeJS const fs = require ('fs'); - IOHandler.load = function (file) { + loadFunc = function (file) { eval (fs.readFileSync(file).toString()); }; } else if (is_browser) { // vanila JS in browser - IOHandler.load = function (file) { + loadFunc = function (file) { const script = document.createElement ("script"); script.src = file; document.head.appendChild (script); } } - } else { - IOHandler.load = load; // shells (v8, JavaScriptCore, Spidermonkey) } + IOHandler.load = async (file) => loadFunc(file); // read: function that just reads a file into a variable - if (!globalThis.read){ + let readFunc = globalThis.read; // shells (v8, JavaScriptCore, Spidermonkey) + if (!readFunc){ if (typeof WScript !== "undefined"){ - IOHandler.read = WScript.LoadBinaryFile; // Chakra + readFunc = WScript.LoadBinaryFile; // Chakra } else if (is_node) { // NodeJS const fs = require ('fs'); - IOHandler.read = function (path) { + readFunc = function (path) { return fs.readFileSync(path); }; } else if (is_browser) { // vanila JS in browser - // TODO + readFunc = fetch; } - } else { - IOHandler.read = read; // shells (v8, JavaScriptCore, Spidermonkey) } + IOHandler.read = async (file) => await readFunc(file); }, writeContentToFile: function(content, path) { @@ -264,8 +264,6 @@ while (testArguments !== undefined && testArguments.length > 0) { // cheap way to let the testing infrastructure know we're running in a browser context (or not) setenv["IsBrowserDomSupported"] = is_browser.toString().toLowerCase(); -IOHandler.load ("mono-config.js"); - var Module = { mainScriptUrlOrBlob: "dotnet.js", @@ -316,8 +314,6 @@ var Module = { }, }; -IOHandler.load ("dotnet.js"); - const IGNORE_PARAM_COUNT = -1; var App = { @@ -417,3 +413,13 @@ var App = { } } }; + +// load the config and runtime files which will start the runtime init and subsiquently the tests +IOHandler + .load ("mono-config.js") + .then(function () { + IOHandler.load ("dotnet.js"); + }) + .catch(function(err) { + fail_exec("failed to load the mono-config.js or dotnet.js files"); + }); From 93255add056f03897cfadc22571fab31894097bb Mon Sep 17 00:00:00 2001 From: Daniel-Genkin Date: Tue, 15 Jun 2021 16:00:44 -0400 Subject: [PATCH 03/25] more cleanup and fixes --- src/mono/wasm/runtime-test.js | 101 +++++++++++++++++----------------- 1 file changed, 50 insertions(+), 51 deletions(-) diff --git a/src/mono/wasm/runtime-test.js b/src/mono/wasm/runtime-test.js index f01d119717245c..93ce77c743dde2 100644 --- a/src/mono/wasm/runtime-test.js +++ b/src/mono/wasm/runtime-test.js @@ -8,40 +8,40 @@ const is_browser = typeof window != "undefined"; const is_node = !is_browser && typeof process != 'undefined'; // if the engine doesn't provide a console -if (typeof (console) === "undefined") { - var console = { +if (typeof (console) === "undefined"){ + console = { log: globalThis.print, clear: function () { } }; -} -globalThis.testConsole = console; - -function proxyMethod (prefix, func, asJson) { - return function() { - let args = [...arguments]; - if (asJson) { - func (JSON.stringify({ - method: prefix, - payload: args[0], - arguments: args - })); - } else { - func([prefix + args[0], ...args.slice(1)]); - } + function proxyMethod (prefix, func, asJson) { + let method = function() { + let args = [...arguments]; + if (asJson) { + func (JSON.stringify({ + method: prefix, + payload: args[0], + arguments: args + })); + } else { + func([prefix + args[0], ...args.slice(1)]); + } + }; + + return method; }; -}; -var methods = ["debug", "trace", "warn", "info", "error"]; -for (var m of methods) { - if (typeof(console[m]) != "function") { - console[m] = proxyMethod(`console.${m}: `, console.log, false); + var methods = ["debug", "trace", "warn", "info", "error"]; + for (var m of methods) { + if (typeof(console[m]) !== "function") { + console[m] = proxyMethod(`console.${m}: `, console.log, false); + } } -} -function proxyJson (func) { - for (var m of ["log", ...methods]) - console[m] = proxyMethod(`console.${m}`,func, true); + function proxyJson (func) { + for (var m of ["log", ...methods]) + console[m] = proxyMethod(`console.${m}`,func, true); + } } if (is_browser) { @@ -50,7 +50,7 @@ if (is_browser) { let consoleWebSocket = new WebSocket(consoleUrl); consoleWebSocket.onopen = function(event) { proxyJson(function (msg) { consoleWebSocket.send (msg); }); - globalThis.testConsole.log("browser: Console websocket connected."); + console.log("browser: Console websocket connected."); }; consoleWebSocket.onerror = function(event) { console.log(`websocket error: ${event}`); @@ -67,10 +67,6 @@ if (is_browser) { } //proxyJson(console.log); - -let print = globalThis.testConsole.log; -let printErr = globalThis.testConsole.error; - if (typeof crypto === 'undefined') { // **NOTE** this is a simple insecure polyfill for testing purposes only // /dev/random doesn't work on js shells, so define our own @@ -94,20 +90,21 @@ if (typeof performance === 'undefined') { let testArguments = []; try { - if (typeof arguments === "undefined") { - if (is_node) - testArguments = process.argv.slice (2); + if (is_node) { + testArguments = process.argv.slice (2); - if (typeof scriptArgs !== "undefined") + }else if (typeof arguments === "undefined") { + if (typeof scriptArgs !== "undefined") { testArguments = scriptArgs; - else if (typeof WScript !== "undefined" && WScript.Arguments) + }else if (typeof WScript !== "undefined" && WScript.Arguments){ testArguments = WScript.Arguments; + } } else{ testArguments = arguments; } } catch (e) { - console.err(e) + console.error(e) } if (is_node) { @@ -199,18 +196,21 @@ function test_exit (exit_code) { if (is_browser) { // Notify the selenium script Module.exit_code = exit_code; - Module.print ("WASM EXIT " + exit_code); + console.log ("WASM EXIT " + exit_code); var tests_done_elem = document.createElement ("label"); tests_done_elem.id = "tests_done"; tests_done_elem.innerHTML = exit_code.toString (); document.body.appendChild (tests_done_elem); + } else if (is_node) { + Module.exit_code = exit_code; + console.log ("WASM EXIT " + exit_code); } else { Module.wasm_exit (exit_code); } } function fail_exec (reason) { - Module.print (reason); + console.error (reason); test_exit (1); } @@ -224,7 +224,7 @@ function inspect_object (o) { } // Preprocess arguments -console.info("Arguments: " + testArguments); +console.log("Arguments: " + testArguments); let profilers = []; let setenv = {}; let runtime_args = []; @@ -247,7 +247,7 @@ while (testArguments !== undefined && testArguments.length > 0) { testArguments = testArguments.slice (1); } else if (testArguments [0].startsWith ("--runtime-arg=")) { var arg = testArguments [0].substring ("--runtime-arg=".length); - runtime_testArguments.push (arg); + runtime_args = testArguments.push (arg); testArguments = testArguments.slice (1); } else if (testArguments [0] == "--disable-on-demand-gc") { enable_gc = false; @@ -264,21 +264,19 @@ while (testArguments !== undefined && testArguments.length > 0) { // cheap way to let the testing infrastructure know we're running in a browser context (or not) setenv["IsBrowserDomSupported"] = is_browser.toString().toLowerCase(); -var Module = { +export var Module = { mainScriptUrlOrBlob: "dotnet.js", - print, - printErr, - onAbort: function(x) { - print ("ABORT: " + x); + console.log ("ABORT: " + x); var err = new Error(); - print ("Stacktrace: \n"); - print (err.stack); + console.log ("Stacktrace: \n"); + console.log (err.stack); test_exit (1); }, onRuntimeInitialized: function () { + console.log("test") // Have to set env vars here to enable setting MONO_LOG_LEVEL etc. for (var variable in setenv) { MONO.mono_wasm_setenv (variable, setenv [variable]); @@ -342,10 +340,10 @@ var App = { var res = 0; try { res = exec_regression (10, testArguments[1]); - Module.print ("REGRESSION RESULT: " + res); + console.log ("REGRESSION RESULT: " + res); } catch (e) { - Module.print ("ABORT: " + e); - print (e.stack); + console.error ("ABORT: " + e); + console.error (e.stack); res = 1; } @@ -421,5 +419,6 @@ IOHandler IOHandler.load ("dotnet.js"); }) .catch(function(err) { + console.error(err) fail_exec("failed to load the mono-config.js or dotnet.js files"); }); From 7f9105f3f04bf45465400c61c031150024a5917d Mon Sep 17 00:00:00 2001 From: Daniel-Genkin Date: Wed, 16 Jun 2021 10:45:18 -0400 Subject: [PATCH 04/25] removed export --- src/mono/wasm/runtime-test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/wasm/runtime-test.js b/src/mono/wasm/runtime-test.js index 93ce77c743dde2..afdc53dabea4df 100644 --- a/src/mono/wasm/runtime-test.js +++ b/src/mono/wasm/runtime-test.js @@ -264,7 +264,7 @@ while (testArguments !== undefined && testArguments.length > 0) { // cheap way to let the testing infrastructure know we're running in a browser context (or not) setenv["IsBrowserDomSupported"] = is_browser.toString().toLowerCase(); -export var Module = { +var Module = { mainScriptUrlOrBlob: "dotnet.js", onAbort: function(x) { From 9489f23e304a8af1c61d714c651c56b923482f33 Mon Sep 17 00:00:00 2001 From: Daniel-Genkin Date: Wed, 16 Jun 2021 11:00:27 -0400 Subject: [PATCH 05/25] more cleanup --- src/mono/wasm/runtime-test.js | 50 +++++++++++++++++------------------ 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/src/mono/wasm/runtime-test.js b/src/mono/wasm/runtime-test.js index afdc53dabea4df..ee4acd5b662805 100644 --- a/src/mono/wasm/runtime-test.js +++ b/src/mono/wasm/runtime-test.js @@ -13,37 +13,36 @@ if (typeof (console) === "undefined"){ log: globalThis.print, clear: function () { } }; - - function proxyMethod (prefix, func, asJson) { - let method = function() { - let args = [...arguments]; - if (asJson) { - func (JSON.stringify({ - method: prefix, - payload: args[0], - arguments: args - })); - } else { - func([prefix + args[0], ...args.slice(1)]); - } - }; - - return method; +} +function proxyMethod (prefix, func, asJson) { + let method = function() { + let args = [...arguments]; + if (asJson) { + func (JSON.stringify({ + method: prefix, + payload: args[0], + arguments: args + })); + } else { + func([prefix + args[0], ...args.slice(1)]); + } }; - var methods = ["debug", "trace", "warn", "info", "error"]; - for (var m of methods) { - if (typeof(console[m]) !== "function") { - console[m] = proxyMethod(`console.${m}: `, console.log, false); - } - } + return method; +}; - function proxyJson (func) { - for (var m of ["log", ...methods]) - console[m] = proxyMethod(`console.${m}`,func, true); +var methods = ["debug", "trace", "warn", "info", "error"]; +for (var m of methods) { + if (typeof(console[m]) !== "function") { + console[m] = proxyMethod(`console.${m}: `, console.log, false); } } +function proxyJson (func) { + for (var m of ["log", ...methods]) + console[m] = proxyMethod(`console.${m}`,func, true); +} + if (is_browser) { const consoleUrl = `${window.location.origin}/console`.replace('http://', 'ws://'); @@ -276,7 +275,6 @@ var Module = { }, onRuntimeInitialized: function () { - console.log("test") // Have to set env vars here to enable setting MONO_LOG_LEVEL etc. for (var variable in setenv) { MONO.mono_wasm_setenv (variable, setenv [variable]); From 57fd10cb6fa318f4b547f5d26cea781f8c3c6332 Mon Sep 17 00:00:00 2001 From: Daniel-Genkin Date: Wed, 16 Jun 2021 11:03:52 -0400 Subject: [PATCH 06/25] more cleanup --- src/mono/wasm/runtime-test.js | 37 +++++++++++++++++------------------ 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/src/mono/wasm/runtime-test.js b/src/mono/wasm/runtime-test.js index ee4acd5b662805..aacb5d07ceb01f 100644 --- a/src/mono/wasm/runtime-test.js +++ b/src/mono/wasm/runtime-test.js @@ -54,19 +54,11 @@ if (is_browser) { consoleWebSocket.onerror = function(event) { console.log(`websocket error: ${event}`); }; - - // We expect to be run by tests/runtime/run.js which passes in the arguments using http parameters - var url = new URL (decodeURI (window.location)); - arguments = []; - for (var v of url.searchParams) { - if (v [0] == "arg") { - arguments.push (v [1]); - } - } } -//proxyJson(console.log); -if (typeof crypto === 'undefined') { +if (is_node) { + var crypto = require('crypto'); +} else if (typeof crypto === 'undefined') { // **NOTE** this is a simple insecure polyfill for testing purposes only // /dev/random doesn't work on js shells, so define our own // See library_fs.js:createDefaultDevices () @@ -77,8 +69,9 @@ if (typeof crypto === 'undefined') { } } } - -if (typeof performance === 'undefined') { +if (is_node) { + var { performance, PerformanceObserver } = require("perf_hooks"); +} else if (typeof performance === 'undefined') { // performance.now() is used by emscripten and doesn't work in JSC var performance = { now: function () { @@ -87,11 +80,21 @@ if (typeof performance === 'undefined') { } } +// get arguments let testArguments = []; try { if (is_node) { testArguments = process.argv.slice (2); + }else if (is_browser) { + // We expect to be run by tests/runtime/run.js which passes in the arguments using http parameters + var url = new URL (decodeURI (window.location)); + for (var param of url.searchParams) { + if (param [0] == "arg") { + testArguments.push (param [1]); + } + } + }else if (typeof arguments === "undefined") { if (typeof scriptArgs !== "undefined") { testArguments = scriptArgs; @@ -106,10 +109,7 @@ try { console.error(e) } -if (is_node) { - var { performance, PerformanceObserver } = require("perf_hooks"); -} - +// abstract all IO into a compact universally available method so that it is consistent and reliable const IOHandler = { load: null, read: null, @@ -189,8 +189,6 @@ const IOHandler = { IOHandler.init(); // end of all the nice shell glue code. -// set up a global variable to be accessed in App.init - function test_exit (exit_code) { if (is_browser) { // Notify the selenium script @@ -411,6 +409,7 @@ var App = { }; // load the config and runtime files which will start the runtime init and subsiquently the tests +// uses promise chain as loading is async but we can't use await here IOHandler .load ("mono-config.js") .then(function () { From e6e56158ddc8dc8c4879d2b52b8f9288e43e38ee Mon Sep 17 00:00:00 2001 From: Daniel-Genkin Date: Wed, 16 Jun 2021 11:08:47 -0400 Subject: [PATCH 07/25] removed unused variables --- src/mono/wasm/runtime-test.js | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/src/mono/wasm/runtime-test.js b/src/mono/wasm/runtime-test.js index aacb5d07ceb01f..011f0bc3b494c0 100644 --- a/src/mono/wasm/runtime-test.js +++ b/src/mono/wasm/runtime-test.js @@ -70,7 +70,7 @@ if (is_node) { } } if (is_node) { - var { performance, PerformanceObserver } = require("perf_hooks"); + var { performance } = require("perf_hooks"); } else if (typeof performance === 'undefined') { // performance.now() is used by emscripten and doesn't work in JSC var performance = { @@ -211,22 +211,12 @@ function fail_exec (reason) { test_exit (1); } -function inspect_object (o) { - var r = ""; - for(var p in o) { - var t = typeof o[p]; - r += "'" + p + "' => '" + t + "', "; - } - return r; -} - // Preprocess arguments console.log("Arguments: " + testArguments); let profilers = []; let setenv = {}; let runtime_args = []; let enable_gc = true; -let enable_zoneinfo = false; let working_dir='/'; while (testArguments !== undefined && testArguments.length > 0) { if (testArguments [0].startsWith ("--profile=")) { @@ -308,8 +298,6 @@ var Module = { }, }; -const IGNORE_PARAM_COUNT = -1; - var App = { init: function () { var wasm_set_main_args = Module.cwrap ('mono_wasm_set_main_args', 'void', ['number', 'number']); From 1d60b575dc54ef39e6f9441ae077733fa50daaa7 Mon Sep 17 00:00:00 2001 From: Daniel-Genkin Date: Wed, 16 Jun 2021 11:31:14 -0400 Subject: [PATCH 08/25] var -> let or const --- src/mono/wasm/runtime-test.js | 60 +++++++++++++++++------------------ 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/src/mono/wasm/runtime-test.js b/src/mono/wasm/runtime-test.js index 011f0bc3b494c0..b47522d17388a6 100644 --- a/src/mono/wasm/runtime-test.js +++ b/src/mono/wasm/runtime-test.js @@ -31,15 +31,15 @@ function proxyMethod (prefix, func, asJson) { return method; }; -var methods = ["debug", "trace", "warn", "info", "error"]; -for (var m of methods) { +const methods = ["debug", "trace", "warn", "info", "error"]; +for (let m of methods) { if (typeof(console[m]) !== "function") { console[m] = proxyMethod(`console.${m}: `, console.log, false); } } function proxyJson (func) { - for (var m of ["log", ...methods]) + for (let m of ["log", ...methods]) console[m] = proxyMethod(`console.${m}`,func, true); } @@ -88,8 +88,8 @@ try { }else if (is_browser) { // We expect to be run by tests/runtime/run.js which passes in the arguments using http parameters - var url = new URL (decodeURI (window.location)); - for (var param of url.searchParams) { + const url = new URL (decodeURI (window.location)); + for (let param of url.searchParams) { if (param [0] == "arg") { testArguments.push (param [1]); } @@ -194,7 +194,7 @@ function test_exit (exit_code) { // Notify the selenium script Module.exit_code = exit_code; console.log ("WASM EXIT " + exit_code); - var tests_done_elem = document.createElement ("label"); + const tests_done_elem = document.createElement ("label"); tests_done_elem.id = "tests_done"; tests_done_elem.innerHTML = exit_code.toString (); document.body.appendChild (tests_done_elem); @@ -220,27 +220,27 @@ let enable_gc = true; let working_dir='/'; while (testArguments !== undefined && testArguments.length > 0) { if (testArguments [0].startsWith ("--profile=")) { - var arg = testArguments [0].substring ("--profile=".length); + const arg = testArguments [0].substring ("--profile=".length); profilers.push (arg); testArguments = testArguments.slice (1); } else if (testArguments [0].startsWith ("--setenv=")) { - var arg = testArguments [0].substring ("--setenv=".length); - var parts = arg.split ('='); + const arg = testArguments [0].substring ("--setenv=".length); + const parts = arg.split ('='); if (parts.length != 2) fail_exec ("Error: malformed argument: '" + testArguments [0]); setenv [parts [0]] = parts [1]; testArguments = testArguments.slice (1); } else if (testArguments [0].startsWith ("--runtime-arg=")) { - var arg = testArguments [0].substring ("--runtime-arg=".length); + const arg = testArguments [0].substring ("--runtime-arg=".length); runtime_args = testArguments.push (arg); testArguments = testArguments.slice (1); } else if (testArguments [0] == "--disable-on-demand-gc") { enable_gc = false; testArguments = testArguments.slice (1); } else if (testArguments [0].startsWith ("--working-dir=")) { - var arg = testArguments [0].substring ("--working-dir=".length); + const arg = testArguments [0].substring ("--working-dir=".length); working_dir = arg; testArguments = testArguments.slice (1); } else { @@ -251,12 +251,13 @@ while (testArguments !== undefined && testArguments.length > 0) { // cheap way to let the testing infrastructure know we're running in a browser context (or not) setenv["IsBrowserDomSupported"] = is_browser.toString().toLowerCase(); +// must be var as dotnet.js uses it var Module = { mainScriptUrlOrBlob: "dotnet.js", onAbort: function(x) { console.log ("ABORT: " + x); - var err = new Error(); + const err = new Error(); console.log ("Stacktrace: \n"); console.log (err.stack); test_exit (1); @@ -264,7 +265,7 @@ var Module = { onRuntimeInitialized: function () { // Have to set env vars here to enable setting MONO_LOG_LEVEL etc. - for (var variable in setenv) { + for (let variable in setenv) { MONO.mono_wasm_setenv (variable, setenv [variable]); } @@ -287,8 +288,8 @@ var Module = { // for testing purposes add BCL assets to VFS until we special case File.Open // to identify when an assembly from the BCL is being open and resolve it correctly. /* - var content = new Uint8Array (read (asset, 'binary')); - var path = asset.substr(config.deploy_prefix.length); + const content = new Uint8Array (read (asset, 'binary')); + const path = asset.substr(config.deploy_prefix.length); IOHandler.writeContentToFile(content, path); */ return IOHandler.fetch (asset, { credentials: 'same-origin' }); @@ -298,18 +299,17 @@ var Module = { }, }; -var App = { +const App = { init: function () { - var wasm_set_main_args = Module.cwrap ('mono_wasm_set_main_args', 'void', ['number', 'number']); - var wasm_strdup = Module.cwrap ('mono_wasm_strdup', 'number', ['string']); + const wasm_set_main_args = Module.cwrap ('mono_wasm_set_main_args', 'void', ['number', 'number']); + const wasm_strdup = Module.cwrap ('mono_wasm_strdup', 'number', ['string']); Module.wasm_exit = Module.cwrap ('mono_wasm_exit', 'void', ['number']); console.info("Initializing....."); - for (var i = 0; i < profilers.length; ++i) { - var init = Module.cwrap ('mono_wasm_load_profiler_' + profilers [i], 'void', ['string']) - + for (let i = 0; i < profilers.length; ++i) { + const init = Module.cwrap ('mono_wasm_load_profiler_' + profilers [i], 'void', ['string']) init (""); } @@ -319,9 +319,9 @@ var App = { } if (testArguments[0] == "--regression") { - var exec_regression = Module.cwrap ('mono_wasm_exec_regression', 'number', ['number', 'string']) + const exec_regression = Module.cwrap ('mono_wasm_exec_regression', 'number', ['number', 'string']) - var res = 0; + let res = 0; try { res = exec_regression (10, testArguments[1]); console.log ("REGRESSION RESULT: " + res); @@ -348,22 +348,22 @@ var App = { } main_assembly_name = testArguments[1]; - var app_args = testArguments.slice (2); + const app_args = testArguments.slice (2); - var main_argc = testArguments.length - 2 + 1; - var main_argv = Module._malloc (main_argc * 4); + const main_argc = testArguments.length - 2 + 1; + const main_argv = Module._malloc (main_argc * 4); aindex = 0; Module.setValue (main_argv + (aindex * 4), wasm_strdup (testArguments [1]), "i32") aindex += 1; - for (var i = 2; i < testArguments.length; ++i) { + for (let i = 2; i < testArguments.length; ++i) { Module.setValue (main_argv + (aindex * 4), wasm_strdup (testArguments [i]), "i32"); aindex += 1; } wasm_set_main_args (main_argc, main_argv); // Automatic signature isn't working correctly - let result = Module.mono_call_assembly_entry_point (main_assembly_name, [app_args], "m"); - let onError = function (error) + const result = Module.mono_call_assembly_entry_point (main_assembly_name, [app_args], "m"); + const onError = function (error) { console.error (error); if (error.stack) @@ -386,7 +386,7 @@ var App = { if ((arguments.length > 2) && (typeof (signature) !== "string")) throw new Error("Invalid number of arguments for call_test_method"); - var fqn = "[System.Private.Runtime.InteropServices.JavaScript.Tests]System.Runtime.InteropServices.JavaScript.Tests.HelperMarshal:" + method_name; + const fqn = "[System.Private.Runtime.InteropServices.JavaScript.Tests]System.Runtime.InteropServices.JavaScript.Tests.HelperMarshal:" + method_name; try { return BINDING.call_static_method(fqn, args || [], signature); } catch (exc) { From 3253d861a74bfb02cac55bf9b37608eca3d81d9d Mon Sep 17 00:00:00 2001 From: Daniel-Genkin Date: Wed, 16 Jun 2021 14:44:39 -0400 Subject: [PATCH 09/25] slight readability fix --- src/mono/wasm/runtime-test.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/mono/wasm/runtime-test.js b/src/mono/wasm/runtime-test.js index b47522d17388a6..2c3857a233a7ec 100644 --- a/src/mono/wasm/runtime-test.js +++ b/src/mono/wasm/runtime-test.js @@ -15,7 +15,7 @@ if (typeof (console) === "undefined"){ }; } function proxyMethod (prefix, func, asJson) { - let method = function() { + return function() { let args = [...arguments]; if (asJson) { func (JSON.stringify({ @@ -27,8 +27,6 @@ function proxyMethod (prefix, func, asJson) { func([prefix + args[0], ...args.slice(1)]); } }; - - return method; }; const methods = ["debug", "trace", "warn", "info", "error"]; From eef11f481f45cf9d19f546948d7ee4bfe7b7918d Mon Sep 17 00:00:00 2001 From: Daniel-Genkin Date: Thu, 17 Jun 2021 09:56:57 -0400 Subject: [PATCH 10/25] Addressed PR comments --- src/mono/wasm/runtime-test.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/mono/wasm/runtime-test.js b/src/mono/wasm/runtime-test.js index 2c3857a233a7ec..bcfc99084013fd 100644 --- a/src/mono/wasm/runtime-test.js +++ b/src/mono/wasm/runtime-test.js @@ -50,7 +50,7 @@ if (is_browser) { console.log("browser: Console websocket connected."); }; consoleWebSocket.onerror = function(event) { - console.log(`websocket error: ${event}`); + console.error(`websocket error: ${event}`); }; } @@ -104,7 +104,7 @@ try { testArguments = arguments; } } catch (e) { - console.error(e) + console.error(e); } // abstract all IO into a compact universally available method so that it is consistent and reliable @@ -257,7 +257,7 @@ var Module = { console.log ("ABORT: " + x); const err = new Error(); console.log ("Stacktrace: \n"); - console.log (err.stack); + console.err (err.stack); test_exit (1); }, @@ -307,7 +307,7 @@ const App = { console.info("Initializing....."); for (let i = 0; i < profilers.length; ++i) { - const init = Module.cwrap ('mono_wasm_load_profiler_' + profilers [i], 'void', ['string']) + const init = Module.cwrap ('mono_wasm_load_profiler_' + profilers [i], 'void', ['string']); init (""); } @@ -317,7 +317,7 @@ const App = { } if (testArguments[0] == "--regression") { - const exec_regression = Module.cwrap ('mono_wasm_exec_regression', 'number', ['number', 'string']) + const exec_regression = Module.cwrap ('mono_wasm_exec_regression', 'number', ['number', 'string']); let res = 0; try { @@ -351,7 +351,7 @@ const App = { const main_argc = testArguments.length - 2 + 1; const main_argv = Module._malloc (main_argc * 4); aindex = 0; - Module.setValue (main_argv + (aindex * 4), wasm_strdup (testArguments [1]), "i32") + Module.setValue (main_argv + (aindex * 4), wasm_strdup (testArguments [1]), "i32"); aindex += 1; for (let i = 2; i < testArguments.length; ++i) { Module.setValue (main_argv + (aindex * 4), wasm_strdup (testArguments [i]), "i32"); @@ -402,6 +402,6 @@ IOHandler IOHandler.load ("dotnet.js"); }) .catch(function(err) { - console.error(err) + console.error(err); fail_exec("failed to load the mono-config.js or dotnet.js files"); }); From ac87c4252f81b56ea60738e6e0f6e4a158a4f111 Mon Sep 17 00:00:00 2001 From: Daniel-Genkin Date: Thu, 17 Jun 2021 09:58:31 -0400 Subject: [PATCH 11/25] Fixed typo --- src/mono/wasm/runtime-test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/wasm/runtime-test.js b/src/mono/wasm/runtime-test.js index bcfc99084013fd..2eb1203d6141ca 100644 --- a/src/mono/wasm/runtime-test.js +++ b/src/mono/wasm/runtime-test.js @@ -257,7 +257,7 @@ var Module = { console.log ("ABORT: " + x); const err = new Error(); console.log ("Stacktrace: \n"); - console.err (err.stack); + console.error (err.stack); test_exit (1); }, From 4afc45f9118ce704f18745d0b3db7cbd640d17bc Mon Sep 17 00:00:00 2001 From: Daniel-Genkin Date: Fri, 18 Jun 2021 10:23:10 -0400 Subject: [PATCH 12/25] works but in a hacky way as the Module and FS defined in dotnet.js need to be manually updated to be in the globalThis object --- src/mono/wasm/runtime-test.js | 23 +++++++++++++++-------- src/mono/wasm/wasm.proj | 2 +- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/mono/wasm/runtime-test.js b/src/mono/wasm/runtime-test.js index 2eb1203d6141ca..7bb25893d6dd92 100644 --- a/src/mono/wasm/runtime-test.js +++ b/src/mono/wasm/runtime-test.js @@ -143,7 +143,7 @@ const IOHandler = { } else if (is_node) { // NodeJS const fs = require ('fs'); readFunc = function (path) { - return fs.readFileSync(path); + return fs.readFileSync(path).toString(); }; } else if (is_browser) { // vanila JS in browser readFunc = fetch; @@ -159,13 +159,20 @@ const IOHandler = { }, fetch: function(asset, params) { - if (is_node || is_browser) { + if (is_browser) { return fetch (asset, params); + } else { return new Promise ((resolve, reject) => { let bytes = null, error = null; try { - bytes = read (asset, 'binary'); + if (is_node){ + const fs = require ('fs'); + const buffer = fs.readFileSync(asset); + bytes = buffer.buffer; + } else { + bytes = read (asset, 'binary'); + } } catch (exc) { error = exc; } @@ -250,7 +257,7 @@ while (testArguments !== undefined && testArguments.length > 0) { setenv["IsBrowserDomSupported"] = is_browser.toString().toLowerCase(); // must be var as dotnet.js uses it -var Module = { +globalThis.Module = { mainScriptUrlOrBlob: "dotnet.js", onAbort: function(x) { @@ -264,7 +271,7 @@ var Module = { onRuntimeInitialized: function () { // Have to set env vars here to enable setting MONO_LOG_LEVEL etc. for (let variable in setenv) { - MONO.mono_wasm_setenv (variable, setenv [variable]); + Module.MONO.mono_wasm_setenv (variable, setenv [variable]); } if (!enable_gc) { @@ -293,7 +300,7 @@ var Module = { return IOHandler.fetch (asset, { credentials: 'same-origin' }); }; - MONO.mono_load_runtime_and_bcl_args (config); + Module.MONO.mono_load_runtime_and_bcl_args (config); }, }; @@ -336,7 +343,7 @@ const App = { } if (runtime_args.length > 0) - MONO.mono_wasm_set_runtime_options (runtime_args); + Module.MONO.mono_wasm_set_runtime_options (runtime_args); if (testArguments[0] == "--run") { // Run an exe @@ -386,7 +393,7 @@ const App = { const fqn = "[System.Private.Runtime.InteropServices.JavaScript.Tests]System.Runtime.InteropServices.JavaScript.Tests.HelperMarshal:" + method_name; try { - return BINDING.call_static_method(fqn, args || [], signature); + return Module.BINDING.call_static_method(fqn, args || [], signature); } catch (exc) { console.error("exception thrown in", fqn); throw exc; diff --git a/src/mono/wasm/wasm.proj b/src/mono/wasm/wasm.proj index 81ce7272efebcc..7331e301acd53f 100644 --- a/src/mono/wasm/wasm.proj +++ b/src/mono/wasm/wasm.proj @@ -69,7 +69,7 @@ <_EmccCommonFlags Include="-s ALLOW_MEMORY_GROWTH=1" /> <_EmccCommonFlags Include="-s NO_EXIT_RUNTIME=1" /> <_EmccCommonFlags Include="-s FORCE_FILESYSTEM=1" /> - <_EmccCommonFlags Include="-s "EXPORTED_RUNTIME_METHODS=['ccall', 'FS_createPath', 'FS_createDataFile', 'cwrap', 'setValue', 'getValue', 'UTF8ToString', 'UTF8ArrayToString', 'addFunction']"" /> + <_EmccCommonFlags Include="-s "EXPORTED_RUNTIME_METHODS=['ccall', 'FS_createPath', 'FS_createDataFile', 'cwrap', 'setValue', 'getValue', 'UTF8ToString', 'UTF8ArrayToString', 'addFunction', 'MONO', 'BINDING', 'DOTNET']"" /> <_EmccCommonFlags Include="-s "EXPORTED_FUNCTIONS=['_putchar']"" /> <_EmccCommonFlags Include="--source-map-base http://example.com" /> <_EmccCommonFlags Include="-emit-llvm" /> From 92f50d513689b3a33364dea55a29841baec9b76c Mon Sep 17 00:00:00 2001 From: Daniel-Genkin Date: Fri, 18 Jun 2021 10:27:48 -0400 Subject: [PATCH 13/25] commented IOHandler --- src/mono/wasm/runtime-test.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/mono/wasm/runtime-test.js b/src/mono/wasm/runtime-test.js index 7bb25893d6dd92..7c75a1f99019aa 100644 --- a/src/mono/wasm/runtime-test.js +++ b/src/mono/wasm/runtime-test.js @@ -109,8 +109,8 @@ try { // abstract all IO into a compact universally available method so that it is consistent and reliable const IOHandler = { - load: null, - read: null, + load: null, // load js file into project and evaluate it + read: null, // return the contents of a file as a string init: function() { // load: function that loads and executes a script @@ -152,17 +152,17 @@ const IOHandler = { IOHandler.read = async (file) => await readFunc(file); }, - writeContentToFile: function(content, path) { + writeContentToFile: function(content, path) { // writes a string to a file const stream = FS.open(path, 'w+'); FS.write(stream, content, 0, content.length, 0); FS.close(stream); }, - fetch: function(asset, params) { + fetch: function(asset, params) { // returns an async fetch request in the form of {ok: boolean, url: string, arrayBuffer: Promise} if (is_browser) { return fetch (asset, params); - } else { + } else { // shells and node return new Promise ((resolve, reject) => { let bytes = null, error = null; try { From ddc2d511e3f4cb8c1918f6a87a8e25495da8ace6 Mon Sep 17 00:00:00 2001 From: Daniel-Genkin Date: Fri, 18 Jun 2021 10:43:23 -0400 Subject: [PATCH 14/25] fixed issue with this and scoping (but this is already addressed by the use strict PR) --- src/mono/wasm/runtime/library_mono.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/mono/wasm/runtime/library_mono.js b/src/mono/wasm/runtime/library_mono.js index 685aaaf375d85e..7dc2eb113ae4ea 100644 --- a/src/mono/wasm/runtime/library_mono.js +++ b/src/mono/wasm/runtime/library_mono.js @@ -60,15 +60,15 @@ var MonoSupportLib = { _id_table: {}, pump_message: function () { - if (!this.mono_background_exec) - this.mono_background_exec = Module.cwrap ("mono_background_exec", null); + if (!MONO.mono_background_exec) + MONO.mono_background_exec = Module.cwrap ("mono_background_exec", null); while (MONO.timeout_queue.length > 0) { --MONO.pump_count; MONO.timeout_queue.shift()(); } while (MONO.pump_count > 0) { --MONO.pump_count; - this.mono_background_exec (); + MONO.mono_background_exec (); } }, @@ -2458,17 +2458,17 @@ var MonoSupportLib = { }, mono_set_timeout: function (timeout, id) { - if (!this.mono_set_timeout_exec) - this.mono_set_timeout_exec = Module.cwrap ("mono_set_timeout_exec", null, [ 'number' ]); + if (!MONO.mono_set_timeout_exec) + MONO.mono_set_timeout_exec = Module.cwrap ("mono_set_timeout_exec", null, [ 'number' ]); if (typeof globalThis.setTimeout === 'function') { globalThis.setTimeout (function () { - this.mono_set_timeout_exec (id); + MONO.mono_set_timeout_exec (id); }, timeout); } else { ++MONO.pump_count; MONO.timeout_queue.push(function() { - this.mono_set_timeout_exec (id); + MONO.mono_set_timeout_exec (id); }) } }, From 8c2bdf15293bf52d310f816e413902cf9649283b Mon Sep 17 00:00:00 2001 From: Daniel-Genkin Date: Fri, 18 Jun 2021 15:28:59 -0400 Subject: [PATCH 15/25] No more need to edit dotnet.js to make it work + much nicer syntax however now native code for the tests fails --- src/mono/wasm/runtime-test.js | 36 ++++++++++++++++++++--------------- src/mono/wasm/wasm.proj | 6 +++--- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/src/mono/wasm/runtime-test.js b/src/mono/wasm/runtime-test.js index 7c75a1f99019aa..d62191c50cc0c6 100644 --- a/src/mono/wasm/runtime-test.js +++ b/src/mono/wasm/runtime-test.js @@ -120,9 +120,17 @@ const IOHandler = { loadFunc = WScript.LoadScriptFile; } else if (is_node) { // NodeJS - const fs = require ('fs'); - loadFunc = function (file) { - eval (fs.readFileSync(file).toString()); + loadFunc = async function (file) { + let req = require(file); + + // sometimes the require returns a function which returns a promise (such as in dotnet.js). + // othertimes it returns the variable or object that is needed. We handle both cases + if (typeof(req) === 'function') { + req = await req(Module); // pass Module so emsdk can use it + } + + // add to the globalThis the file under the namespace of the upercase filename without js extension + globalThis[file.substring(2,file.length - 3).replace("-","_").toUpperCase()] = req; }; } else if (is_browser) { // vanila JS in browser loadFunc = function (file) { @@ -132,7 +140,7 @@ const IOHandler = { } } } - IOHandler.load = async (file) => loadFunc(file); + IOHandler.load = async (file) => await loadFunc(file); // read: function that just reads a file into a variable let readFunc = globalThis.read; // shells (v8, JavaScriptCore, Spidermonkey) @@ -257,7 +265,7 @@ while (testArguments !== undefined && testArguments.length > 0) { setenv["IsBrowserDomSupported"] = is_browser.toString().toLowerCase(); // must be var as dotnet.js uses it -globalThis.Module = { +var Module = { mainScriptUrlOrBlob: "dotnet.js", onAbort: function(x) { @@ -278,17 +286,17 @@ globalThis.Module = { Module.ccall ('mono_wasm_enable_on_demand_gc', 'void', ['number'], [0]); } - config.loaded_cb = function () { - let wds = FS.stat (working_dir); - if (wds === undefined || !FS.isDir (wds.mode)) { + MONO_CONFIG.loaded_cb = function () { + let wds = Module.FS.stat (working_dir); + if (wds === undefined || !Module.FS.isDir (wds.mode)) { fail_exec (`Could not find working directory ${working_dir}`); return; } - FS.chdir (working_dir); + Module.FS.chdir (working_dir); App.init (); }; - config.fetch_file_cb = function (asset) { + MONO_CONFIG.fetch_file_cb = function (asset) { // console.log("fetch_file_cb('" + asset + "')"); // for testing purposes add BCL assets to VFS until we special case File.Open // to identify when an assembly from the BCL is being open and resolve it correctly. @@ -300,7 +308,7 @@ globalThis.Module = { return IOHandler.fetch (asset, { credentials: 'same-origin' }); }; - Module.MONO.mono_load_runtime_and_bcl_args (config); + Module.MONO.mono_load_runtime_and_bcl_args (MONO_CONFIG); }, }; @@ -404,10 +412,8 @@ const App = { // load the config and runtime files which will start the runtime init and subsiquently the tests // uses promise chain as loading is async but we can't use await here IOHandler - .load ("mono-config.js") - .then(function () { - IOHandler.load ("dotnet.js"); - }) + .load ("./mono-config.js") + .then(IOHandler.load ("./dotnet.js")) .catch(function(err) { console.error(err); fail_exec("failed to load the mono-config.js or dotnet.js files"); diff --git a/src/mono/wasm/wasm.proj b/src/mono/wasm/wasm.proj index 7331e301acd53f..5a9b5d1138351a 100644 --- a/src/mono/wasm/wasm.proj +++ b/src/mono/wasm/wasm.proj @@ -69,12 +69,12 @@ <_EmccCommonFlags Include="-s ALLOW_MEMORY_GROWTH=1" /> <_EmccCommonFlags Include="-s NO_EXIT_RUNTIME=1" /> <_EmccCommonFlags Include="-s FORCE_FILESYSTEM=1" /> - <_EmccCommonFlags Include="-s "EXPORTED_RUNTIME_METHODS=['ccall', 'FS_createPath', 'FS_createDataFile', 'cwrap', 'setValue', 'getValue', 'UTF8ToString', 'UTF8ArrayToString', 'addFunction', 'MONO', 'BINDING', 'DOTNET']"" /> + <_EmccCommonFlags Include="-s "EXPORTED_RUNTIME_METHODS=['ccall', 'FS_createPath', 'FS_createDataFile', 'cwrap', 'setValue', 'getValue', 'UTF8ToString', 'UTF8ArrayToString', 'addFunction', 'MONO', 'BINDING', 'DOTNET', 'FS']"" /> <_EmccCommonFlags Include="-s "EXPORTED_FUNCTIONS=['_putchar']"" /> <_EmccCommonFlags Include="--source-map-base http://example.com" /> <_EmccCommonFlags Include="-emit-llvm" /> - - <_EmccCommonFlags Include="-s MODULARIZE=1" Condition="'$(WasmEnableES6)' != 'false'" /> + <_EmccCommonFlags Include="-s MODULARIZE=1" /> + <_EmccCommonFlags Include="-s EXPORT_ES6=1" Condition="'$(WasmEnableES6)' != 'false'" /> From 6cc767e42adcfb39be2ff5fc764aa802916f4b90 Mon Sep 17 00:00:00 2001 From: Daniel-Genkin Date: Sat, 19 Jun 2021 11:26:24 -0400 Subject: [PATCH 16/25] fixed last error --- src/mono/wasm/runtime-test.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mono/wasm/runtime-test.js b/src/mono/wasm/runtime-test.js index d62191c50cc0c6..4f29f4ca336f93 100644 --- a/src/mono/wasm/runtime-test.js +++ b/src/mono/wasm/runtime-test.js @@ -311,6 +311,7 @@ var Module = { Module.MONO.mono_load_runtime_and_bcl_args (MONO_CONFIG); }, }; +globalThis.Module = Module; // needed as some functions (such as call_static_method) need access to Module. const App = { init: function () { From 5b80d1af4894ebb9d937d6083c779d45e27741d4 Mon Sep 17 00:00:00 2001 From: Daniel-Genkin Date: Sat, 19 Jun 2021 12:23:08 -0400 Subject: [PATCH 17/25] Added node TargetOS --- Directory.Build.props | 1 + src/mono/sample/wasm/console/package.json | 19 +++++++++++++++++++ src/mono/wasm/build/WasmApp.targets | 9 +++++++++ src/mono/wasm/wasm.proj | 4 +++- 4 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 src/mono/sample/wasm/console/package.json diff --git a/Directory.Build.props b/Directory.Build.props index 7efd3a57291691..600f7b256da6fc 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -198,6 +198,7 @@ true true true + true true true diff --git a/src/mono/sample/wasm/console/package.json b/src/mono/sample/wasm/console/package.json new file mode 100644 index 00000000000000..cc40743e7d9fdb --- /dev/null +++ b/src/mono/sample/wasm/console/package.json @@ -0,0 +1,19 @@ +{ + "name": "console-sample-in-node", + "version": "1.0.0", + "description": "Runs the MONO WASM Console sample in the NodeJS environment", + "main": "runtime.js", + "scripts": { + "test": "node --trace-warnings runtime.js --run Wasm.Console.Sample.dll" + }, + "author": "Microsoft", + "license": "MIT", + "dependencies": { + "crypto": "^1.0.1", + "fs": "0.0.1-security", + "node-fetch": "^2.6.1", + "path": "^0.12.7", + "perf_hooks": "0.0.1", + "ws": "^7.5.0" + } +} diff --git a/src/mono/wasm/build/WasmApp.targets b/src/mono/wasm/build/WasmApp.targets index 2141cce41b69b2..702c0134447fcf 100644 --- a/src/mono/wasm/build/WasmApp.targets +++ b/src/mono/wasm/build/WasmApp.targets @@ -200,4 +200,13 @@ WasmAssembliesToBundle: @(WasmAssembliesToBundle) WasmAssembliesFinal: @(WasmAssembliesFinal)" /> + + + + + + diff --git a/src/mono/wasm/wasm.proj b/src/mono/wasm/wasm.proj index 5a9b5d1138351a..3c461cccfb96c0 100644 --- a/src/mono/wasm/wasm.proj +++ b/src/mono/wasm/wasm.proj @@ -73,7 +73,8 @@ <_EmccCommonFlags Include="-s "EXPORTED_FUNCTIONS=['_putchar']"" /> <_EmccCommonFlags Include="--source-map-base http://example.com" /> <_EmccCommonFlags Include="-emit-llvm" /> - <_EmccCommonFlags Include="-s MODULARIZE=1" /> + + <_EmccCommonFlags Include="-s MODULARIZE=1" Condition="'$(TargetOS)' == 'Node'"/> <_EmccCommonFlags Include="-s EXPORT_ES6=1" Condition="'$(WasmEnableES6)' != 'false'" /> @@ -274,6 +275,7 @@ + From f01285d6b7c8ca5cc6252d279c57908cfd8131e5 Mon Sep 17 00:00:00 2001 From: Daniel-Genkin Date: Sat, 19 Jun 2021 12:36:43 -0400 Subject: [PATCH 18/25] Added run-node script generation --- .../wasm/console/Wasm.Console.Sample.csproj | 2 ++ src/mono/sample/wasm/console/package.json | 1 - src/mono/wasm/build/README.md | 1 + src/mono/wasm/build/WasmApp.targets | 31 ++++++++++++++++++- 4 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/mono/sample/wasm/console/Wasm.Console.Sample.csproj b/src/mono/sample/wasm/console/Wasm.Console.Sample.csproj index 7097ef20ab9bd6..3585e344176bf7 100644 --- a/src/mono/sample/wasm/console/Wasm.Console.Sample.csproj +++ b/src/mono/sample/wasm/console/Wasm.Console.Sample.csproj @@ -3,6 +3,7 @@ true $(MonoProjectRoot)\wasm\runtime-test.js true + true @@ -10,4 +11,5 @@ + diff --git a/src/mono/sample/wasm/console/package.json b/src/mono/sample/wasm/console/package.json index cc40743e7d9fdb..14114d59e24266 100644 --- a/src/mono/sample/wasm/console/package.json +++ b/src/mono/sample/wasm/console/package.json @@ -9,7 +9,6 @@ "author": "Microsoft", "license": "MIT", "dependencies": { - "crypto": "^1.0.1", "fs": "0.0.1-security", "node-fetch": "^2.6.1", "path": "^0.12.7", diff --git a/src/mono/wasm/build/README.md b/src/mono/wasm/build/README.md index ea7b73ebe2214f..b82271a70f3b92 100644 --- a/src/mono/wasm/build/README.md +++ b/src/mono/wasm/build/README.md @@ -45,6 +45,7 @@ The various task inputs correspond to properties as: - `run-v8.sh` script is emitted to `$(WasmRunV8ScriptPath)` which defaults to `$(WasmAppDir)`. - To control it's generation use `$(WasmGenerateRunV8Script)` (false by default) + - Note that if building for NodeJS you can also use `$(WasmGenerateRunV8Script)` to generate a `run-node.sh` or `run-v8.cmd` file (depending on OS used to build). This should be a step towards eventually having this build as a sdk. diff --git a/src/mono/wasm/build/WasmApp.targets b/src/mono/wasm/build/WasmApp.targets index 702c0134447fcf..d47995c041bf82 100644 --- a/src/mono/wasm/build/WasmApp.targets +++ b/src/mono/wasm/build/WasmApp.targets @@ -154,6 +154,7 @@ + @@ -175,6 +176,34 @@ + + + $(WasmAppDir)run-node.sh + $(WasmAppDir)run-node.cmd + + + + + + + + + + + + + + + + - + From 9ddb6596b89ed2c215a80e8c7249207efc4c8084 Mon Sep 17 00:00:00 2001 From: Daniel-Genkin Date: Sat, 19 Jun 2021 18:15:05 -0400 Subject: [PATCH 19/25] merge mono config branch --- Directory.Build.props | 1 + src/mono/sample/mbr/browser/index.html | 1 - src/mono/sample/mbr/browser/runtime.js | 20 +- src/mono/sample/wasm/browser-bench/index.html | 1 - src/mono/sample/wasm/browser-bench/runtime.js | 27 +- .../sample/wasm/browser-profile/index.html | 59 ---- .../sample/wasm/browser-profile/runtime.js | 86 +++++- src/mono/sample/wasm/browser/index.html | 1 - src/mono/sample/wasm/browser/runtime.js | 19 +- .../wasm/console/Wasm.Console.Sample.csproj | 2 + src/mono/sample/wasm/console/package.json | 18 ++ src/mono/wasm/build/README.md | 1 + src/mono/wasm/build/WasmApp.targets | 40 ++- .../tests/debugger-test/debugger-driver.html | 1 - .../tests/debugger-test/runtime-debugger.js | 18 +- src/mono/wasm/runtime-test.js | 264 +++++++++--------- src/mono/wasm/runtime/library_mono.js | 39 ++- src/mono/wasm/wasm.proj | 8 +- src/tasks/WasmAppBuilder/WasmAppBuilder.cs | 6 +- .../Wasm.Build.Tests/BuildTestBase.cs | 2 +- .../WebAssembly/Browser/AOT/index.html | 1 - .../WebAssembly/Browser/AOT/runtime.js | 19 +- .../Browser/NormalInterp/index.html | 1 - .../Browser/NormalInterp/runtime.js | 19 +- 24 files changed, 418 insertions(+), 236 deletions(-) create mode 100644 src/mono/sample/wasm/console/package.json diff --git a/Directory.Build.props b/Directory.Build.props index 7efd3a57291691..600f7b256da6fc 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -198,6 +198,7 @@ true true true + true true true diff --git a/src/mono/sample/mbr/browser/index.html b/src/mono/sample/mbr/browser/index.html index 472cf5f29ea053..eb19b7bb2f5954 100644 --- a/src/mono/sample/mbr/browser/index.html +++ b/src/mono/sample/mbr/browser/index.html @@ -29,7 +29,6 @@ }, }; - diff --git a/src/mono/sample/mbr/browser/runtime.js b/src/mono/sample/mbr/browser/runtime.js index 0856b8d0e03033..5949c5edb4bd3b 100644 --- a/src/mono/sample/mbr/browser/runtime.js +++ b/src/mono/sample/mbr/browser/runtime.js @@ -2,17 +2,29 @@ // The .NET Foundation licenses this file to you under the MIT license. var Module = { + config: null, + + preInit: async function() { + Module.config = await MONO.mono_wasm_load_config("./mono-config.json"); + }, + + // Called when the runtime is initialized and wasm is ready onRuntimeInitialized: function () { - config.loaded_cb = function () { + if (!Module.config || Module.config.error){ + console.log("An error occured while loading the config file"); + return; + } + + Module.config.loaded_cb = function () { App.init (); }; - config.environment_variables = { + Module.config.environment_variables = { "DOTNET_MODIFIABLE_ASSEMBLIES": "debug" }; - config.fetch_file_cb = function (asset) { + Module.config.fetch_file_cb = function (asset) { return fetch (asset, { credentials: 'same-origin' }); } - MONO.mono_load_runtime_and_bcl_args (config); + MONO.mono_load_runtime_and_bcl_args (Module.config); }, }; diff --git a/src/mono/sample/wasm/browser-bench/index.html b/src/mono/sample/wasm/browser-bench/index.html index eebbae65eb1052..658bfb573ddbfc 100644 --- a/src/mono/sample/wasm/browser-bench/index.html +++ b/src/mono/sample/wasm/browser-bench/index.html @@ -51,7 +51,6 @@ } }; - diff --git a/src/mono/sample/wasm/browser-bench/runtime.js b/src/mono/sample/wasm/browser-bench/runtime.js index a39b0b97b14901..07b54173be0bc0 100644 --- a/src/mono/sample/wasm/browser-bench/runtime.js +++ b/src/mono/sample/wasm/browser-bench/runtime.js @@ -1,9 +1,20 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. - var Module = { + config: null, + + preInit: async function() { + Module.config = await MONO.mono_wasm_load_config("./mono-config.json"); + }, + + // Called when the runtime is initialized and wasm is ready onRuntimeInitialized: function () { - config.loaded_cb = function () { + if (!Module.config || Module.config.error){ + console.log("An error occured while loading the config file"); + return; + } + + Module.config.loaded_cb = function () { try { App.init (); } catch (error) { @@ -11,13 +22,21 @@ var Module = { throw (error); } }; - config.fetch_file_cb = function (asset) { + Module.config.fetch_file_cb = function (asset) { return fetch (asset, { credentials: 'same-origin' }); } + if (Module.config.enable_profiler) + { + Module.config.aot_profiler_options = { + write_at:"Sample.Test::StopProfile", + send_to: "System.Runtime.InteropServices.JavaScript.Runtime::DumpAotProfileData" + } + } + try { - MONO.mono_load_runtime_and_bcl_args (config); + MONO.mono_load_runtime_and_bcl_args (Module.config); } catch (error) { test_exit(1); throw(error); diff --git a/src/mono/sample/wasm/browser-profile/index.html b/src/mono/sample/wasm/browser-profile/index.html index 50eb0ff28c2efe..de4a5599e94ad0 100644 --- a/src/mono/sample/wasm/browser-profile/index.html +++ b/src/mono/sample/wasm/browser-profile/index.html @@ -10,67 +10,8 @@ Result from Sample.Test.TestMeaning: - - - diff --git a/src/mono/sample/wasm/browser-profile/runtime.js b/src/mono/sample/wasm/browser-profile/runtime.js index 1ce1c0b736034c..8b7ef3258c685d 100644 --- a/src/mono/sample/wasm/browser-profile/runtime.js +++ b/src/mono/sample/wasm/browser-profile/runtime.js @@ -1,22 +1,35 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -var Module = { +var Module = { + is_testing: false, + config: null, + + preInit: async function() { + Module.config = await MONO.mono_wasm_load_config("./mono-config.json"); + }, + + // Called when the runtime is initialized and wasm is ready onRuntimeInitialized: function () { - config.loaded_cb = function () { + if (!Module.config || Module.config.error){ + console.log("An error occured while loading the config file"); + return; + } + + Module.config.loaded_cb = function () { try { - App.init (); + Module.init(); } catch (error) { - test_exit(1); + Module.test_exit(1); throw (error); } }; - config.fetch_file_cb = function (asset) { + Module.config.fetch_file_cb = function (asset) { return fetch (asset, { credentials: 'same-origin' }); } - if (config.enable_profiler) + if (Module.config.enable_profiler) { - config.aot_profiler_options = { + Module.config.aot_profiler_options = { write_at:"Sample.Test::StopProfile", send_to: "System.Runtime.InteropServices.JavaScript.Runtime::DumpAotProfileData" } @@ -24,10 +37,63 @@ var Module = { try { - MONO.mono_load_runtime_and_bcl_args (config); + MONO.mono_load_runtime_and_bcl_args (Module.config); } catch (error) { - test_exit(1); + Module.test_exit(1); throw(error); } + }, + + init: function () { + console.log("not ready yet") + var ret = BINDING.call_static_method("[Wasm.BrowserProfile.Sample] Sample.Test:TestMeaning", []); + document.getElementById("out").innerHTML = ret; + console.log ("ready"); + + if (Module.is_testing) + { + console.debug(`ret: ${ret}`); + let exit_code = ret == 42 ? 0 : 1; + Module.test_exit(exit_code); + } + + if (Module.config.enable_profiler) { + BINDING.call_static_method("[Wasm.BrowserProfile.Sample] Sample.Test:StopProfile", []); + Module.saveProfile(); + } + }, + + onLoad: function() { + var url = new URL(decodeURI(window.location)); + let args = url.searchParams.getAll('arg'); + Module.is_testing = args !== undefined && (args.find(arg => arg == '--testing') !== undefined); + }, + + test_exit: function(exit_code) { + if (!Module.is_testing) { + console.log(`test_exit: ${exit_code}`); + return; + } + + /* Set result in a tests_done element, to be read by xharness */ + var tests_done_elem = document.createElement("label"); + tests_done_elem.id = "tests_done"; + tests_done_elem.innerHTML = exit_code.toString(); + document.body.appendChild(tests_done_elem); + + console.log(`WASM EXIT ${exit_code}`); + }, + + saveProfile: function () { + var a = document.createElement('a'); + var blob = new Blob([Module.aot_profile_data]); + a.href = URL.createObjectURL(blob); + a.download = "data.aotprofile"; + // Append anchor to body. + document.body.appendChild(a); + a.click(); + + // Remove anchor from body + document.body.removeChild(a); } -}; \ No newline at end of file +}; diff --git a/src/mono/sample/wasm/browser/index.html b/src/mono/sample/wasm/browser/index.html index bd8e5015a0ee5f..5f170bb38e7bcb 100644 --- a/src/mono/sample/wasm/browser/index.html +++ b/src/mono/sample/wasm/browser/index.html @@ -48,7 +48,6 @@ }, }; - diff --git a/src/mono/sample/wasm/browser/runtime.js b/src/mono/sample/wasm/browser/runtime.js index a39b0b97b14901..748138d8ebeb9c 100644 --- a/src/mono/sample/wasm/browser/runtime.js +++ b/src/mono/sample/wasm/browser/runtime.js @@ -2,8 +2,21 @@ // The .NET Foundation licenses this file to you under the MIT license. var Module = { + + config: null, + + preInit: async function() { + Module.config = await MONO.mono_wasm_load_config("./mono-config.json"); + }, + + // Called when the runtime is initialized and wasm is ready onRuntimeInitialized: function () { - config.loaded_cb = function () { + if (!Module.config || Module.config.error){ + console.log("No config found"); + return; + } + + Module.config.loaded_cb = function () { try { App.init (); } catch (error) { @@ -11,13 +24,13 @@ var Module = { throw (error); } }; - config.fetch_file_cb = function (asset) { + Module.config.fetch_file_cb = function (asset) { return fetch (asset, { credentials: 'same-origin' }); } try { - MONO.mono_load_runtime_and_bcl_args (config); + MONO.mono_load_runtime_and_bcl_args (Module.config); } catch (error) { test_exit(1); throw(error); diff --git a/src/mono/sample/wasm/console/Wasm.Console.Sample.csproj b/src/mono/sample/wasm/console/Wasm.Console.Sample.csproj index 7097ef20ab9bd6..3585e344176bf7 100644 --- a/src/mono/sample/wasm/console/Wasm.Console.Sample.csproj +++ b/src/mono/sample/wasm/console/Wasm.Console.Sample.csproj @@ -3,6 +3,7 @@ true $(MonoProjectRoot)\wasm\runtime-test.js true + true @@ -10,4 +11,5 @@ + diff --git a/src/mono/sample/wasm/console/package.json b/src/mono/sample/wasm/console/package.json new file mode 100644 index 00000000000000..14114d59e24266 --- /dev/null +++ b/src/mono/sample/wasm/console/package.json @@ -0,0 +1,18 @@ +{ + "name": "console-sample-in-node", + "version": "1.0.0", + "description": "Runs the MONO WASM Console sample in the NodeJS environment", + "main": "runtime.js", + "scripts": { + "test": "node --trace-warnings runtime.js --run Wasm.Console.Sample.dll" + }, + "author": "Microsoft", + "license": "MIT", + "dependencies": { + "fs": "0.0.1-security", + "node-fetch": "^2.6.1", + "path": "^0.12.7", + "perf_hooks": "0.0.1", + "ws": "^7.5.0" + } +} diff --git a/src/mono/wasm/build/README.md b/src/mono/wasm/build/README.md index ea7b73ebe2214f..b82271a70f3b92 100644 --- a/src/mono/wasm/build/README.md +++ b/src/mono/wasm/build/README.md @@ -45,6 +45,7 @@ The various task inputs correspond to properties as: - `run-v8.sh` script is emitted to `$(WasmRunV8ScriptPath)` which defaults to `$(WasmAppDir)`. - To control it's generation use `$(WasmGenerateRunV8Script)` (false by default) + - Note that if building for NodeJS you can also use `$(WasmGenerateRunV8Script)` to generate a `run-node.sh` or `run-v8.cmd` file (depending on OS used to build). This should be a step towards eventually having this build as a sdk. diff --git a/src/mono/wasm/build/WasmApp.targets b/src/mono/wasm/build/WasmApp.targets index 2141cce41b69b2..26c37e382fd803 100644 --- a/src/mono/wasm/build/WasmApp.targets +++ b/src/mono/wasm/build/WasmApp.targets @@ -65,7 +65,7 @@ - @(WasmFilesToIncludeInFileSystem) - Files to include in the vfs - @(WasmNativeAsset) - Native files to be added to `NativeAssets` in the bundle. - - @(WasmExtraConfig) - json elements to add to `mono-config.js` + - @(WasmExtraConfig) - json elements to add to `mono-config.json` Eg. - Value attribute can have a number, bool, quoted string, or json string @@ -154,6 +154,7 @@ + @@ -175,6 +176,34 @@ + + + $(WasmAppDir)run-node.sh + $(WasmAppDir)run-node.cmd + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/mono/wasm/debugger/tests/debugger-test/debugger-driver.html b/src/mono/wasm/debugger/tests/debugger-test/debugger-driver.html index 87ba804792ef39..b1bfcd859d0644 100644 --- a/src/mono/wasm/debugger/tests/debugger-test/debugger-driver.html +++ b/src/mono/wasm/debugger/tests/debugger-test/debugger-driver.html @@ -83,7 +83,6 @@ return App.int_add (a, b); } - diff --git a/src/mono/wasm/debugger/tests/debugger-test/runtime-debugger.js b/src/mono/wasm/debugger/tests/debugger-test/runtime-debugger.js index 4c641eb2c6a0d7..2980f060fee35c 100644 --- a/src/mono/wasm/debugger/tests/debugger-test/runtime-debugger.js +++ b/src/mono/wasm/debugger/tests/debugger-test/runtime-debugger.js @@ -2,8 +2,20 @@ // The .NET Foundation licenses this file to you under the MIT license. var Module = { - onRuntimeInitialized: function () { - config.loaded_cb = function () { + config: null, + + preInit: async function() { + Module.config = await MONO.mono_wasm_load_config("./mono-config.json"); + }, + + // Called when the runtime is initialized and wasm is ready + onRuntimeInitialized: function () { + if (!Module.config || Module.config.error){ + console.log("An error occured while loading the config file"); + return; + } + + Module.config.loaded_cb = function () { App.init (); }; // For custom logging patch the functions below @@ -15,6 +27,6 @@ var Module = { MONO.mono_wasm_setenv ("MONO_LOG_LEVEL", "debug"); MONO.mono_wasm_setenv ("MONO_LOG_MASK", "all"); */ - MONO.mono_load_runtime_and_bcl_args (config) + MONO.mono_load_runtime_and_bcl_args (Module.config) }, }; diff --git a/src/mono/wasm/runtime-test.js b/src/mono/wasm/runtime-test.js index 174f488a67e38b..530a60d003d5b1 100644 --- a/src/mono/wasm/runtime-test.js +++ b/src/mono/wasm/runtime-test.js @@ -8,15 +8,12 @@ const is_browser = typeof window != "undefined"; const is_node = !is_browser && typeof process != 'undefined'; // if the engine doesn't provide a console -if (typeof (console) === "undefined") { - var console = { +if (typeof (console) === "undefined"){ + console = { log: globalThis.print, clear: function () { } }; } - -globalThis.testConsole = console; - function proxyMethod (prefix, func, asJson) { return function() { let args = [...arguments]; @@ -32,15 +29,15 @@ function proxyMethod (prefix, func, asJson) { }; }; -var methods = ["debug", "trace", "warn", "info", "error"]; -for (var m of methods) { - if (typeof(console[m]) != "function") { +const methods = ["debug", "trace", "warn", "info", "error"]; +for (let m of methods) { + if (typeof(console[m]) !== "function") { console[m] = proxyMethod(`console.${m}: `, console.log, false); } } function proxyJson (func) { - for (var m of ["log", ...methods]) + for (let m of ["log", ...methods]) console[m] = proxyMethod(`console.${m}`,func, true); } @@ -50,28 +47,16 @@ if (is_browser) { let consoleWebSocket = new WebSocket(consoleUrl); consoleWebSocket.onopen = function(event) { proxyJson(function (msg) { consoleWebSocket.send (msg); }); - globalThis.testConsole.log("browser: Console websocket connected."); + console.log("browser: Console websocket connected."); }; consoleWebSocket.onerror = function(event) { - console.log(`websocket error: ${event}`); + console.error(`websocket error: ${event}`); }; - - // We expect to be run by tests/runtime/run.js which passes in the arguments using http parameters - var url = new URL (decodeURI (window.location)); - arguments = []; - for (var v of url.searchParams) { - if (v [0] == "arg") { - arguments.push (v [1]); - } - } } -//proxyJson(console.log); - -let print = globalThis.testConsole.log; -let printErr = globalThis.testConsole.error; - -if (typeof crypto === 'undefined') { +if (is_node) { + var crypto = require('crypto'); +} else if (typeof crypto === 'undefined') { // **NOTE** this is a simple insecure polyfill for testing purposes only // /dev/random doesn't work on js shells, so define our own // See library_fs.js:createDefaultDevices () @@ -82,8 +67,9 @@ if (typeof crypto === 'undefined') { } } } - -if (typeof performance === 'undefined') { +if (is_node) { + var { performance } = require("perf_hooks"); +} else if (typeof performance === 'undefined') { // performance.now() is used by emscripten and doesn't work in JSC var performance = { now: function () { @@ -92,86 +78,109 @@ if (typeof performance === 'undefined') { } } +// get arguments let testArguments = []; try { - if (typeof arguments === "undefined") { - if (is_node) - testArguments = process.argv.slice (2); + if (is_node) { + testArguments = process.argv.slice (2); + + }else if (is_browser) { + // We expect to be run by tests/runtime/run.js which passes in the arguments using http parameters + const url = new URL (decodeURI (window.location)); + for (let param of url.searchParams) { + if (param [0] == "arg") { + testArguments.push (param [1]); + } + } - if (typeof scriptArgs !== "undefined") + }else if (typeof arguments === "undefined") { + if (typeof scriptArgs !== "undefined") { testArguments = scriptArgs; - else if (typeof WScript !== "undefined" && WScript.Arguments) + }else if (typeof WScript !== "undefined" && WScript.Arguments){ testArguments = WScript.Arguments; + } } else{ testArguments = arguments; } } catch (e) { - console.err(e) -} - -if (is_node) { - var { performance, PerformanceObserver } = require("perf_hooks"); + console.error(e); } +// abstract all IO into a compact universally available method so that it is consistent and reliable const IOHandler = { - load: null, - read: null, + load: null, // load js file into project and evaluate it + read: null, // return the contents of a file as a string init: function() { // load: function that loads and executes a script - if (!globalThis.load){ + let loadFunc = globalThis.load; // shells (v8, JavaScriptCore, Spidermonkey) + if (!loadFunc){ if (typeof WScript !== "undefined"){ // Chakra - IOHandler.load = WScript.LoadScriptFile; + loadFunc = WScript.LoadScriptFile; } else if (is_node) { // NodeJS - const fs = require ('fs'); - IOHandler.load = function (file) { - eval (fs.readFileSync(file).toString()); + loadFunc = async function (file) { + let req = require(file); + + // sometimes the require returns a function which returns a promise (such as in dotnet.js). + // othertimes it returns the variable or object that is needed. We handle both cases + if (typeof(req) === 'function') { + req = await req(Module); // pass Module so emsdk can use it + } + + // add to the globalThis the file under the namespace of the upercase filename without js extension + globalThis[file.substring(2,file.length - 3).replace("-","_").toUpperCase()] = req; }; } else if (is_browser) { // vanila JS in browser - IOHandler.load = function (file) { + loadFunc = function (file) { const script = document.createElement ("script"); script.src = file; document.head.appendChild (script); } } - } else { - IOHandler.load = load; // shells (v8, JavaScriptCore, Spidermonkey) } + IOHandler.load = async (file) => await loadFunc(file); // read: function that just reads a file into a variable - if (!globalThis.read){ + let readFunc = globalThis.read; // shells (v8, JavaScriptCore, Spidermonkey) + if (!readFunc){ if (typeof WScript !== "undefined"){ - IOHandler.read = WScript.LoadBinaryFile; // Chakra + readFunc = WScript.LoadBinaryFile; // Chakra } else if (is_node) { // NodeJS const fs = require ('fs'); - IOHandler.read = function (path) { - return fs.readFileSync(path); + readFunc = function (path) { + return fs.readFileSync(path).toString(); }; } else if (is_browser) { // vanila JS in browser - // TODO + readFunc = fetch; } - } else { - IOHandler.read = read; // shells (v8, JavaScriptCore, Spidermonkey) } + IOHandler.read = async (file) => await readFunc(file); }, - writeContentToFile: function(content, path) { + writeContentToFile: function(content, path) { // writes a string to a file const stream = FS.open(path, 'w+'); FS.write(stream, content, 0, content.length, 0); FS.close(stream); }, - fetch: function(asset, params) { - if (is_node || is_browser) { + fetch: function(asset, params) { // returns an async fetch request in the form of {ok: boolean, url: string, arrayBuffer: Promise} + if (is_browser) { return fetch (asset, params); - } else { + + } else { // shells and node return new Promise ((resolve, reject) => { let bytes = null, error = null; try { - bytes = read (asset, 'binary'); + if (is_node){ + const fs = require ('fs'); + const buffer = fs.readFileSync(asset); + bytes = buffer.buffer; + } else { + bytes = read (asset, 'binary'); + } } catch (exc) { error = exc; } @@ -193,67 +202,58 @@ const IOHandler = { IOHandler.init(); // end of all the nice shell glue code. -// set up a global variable to be accessed in App.init - function test_exit (exit_code) { if (is_browser) { // Notify the selenium script Module.exit_code = exit_code; - Module.print ("WASM EXIT " + exit_code); - var tests_done_elem = document.createElement ("label"); + console.log ("WASM EXIT " + exit_code); + const tests_done_elem = document.createElement ("label"); tests_done_elem.id = "tests_done"; tests_done_elem.innerHTML = exit_code.toString (); document.body.appendChild (tests_done_elem); + } else if (is_node) { + Module.exit_code = exit_code; + console.log ("WASM EXIT " + exit_code); } else { Module.wasm_exit (exit_code); } } function fail_exec (reason) { - Module.print (reason); + console.error (reason); test_exit (1); } -function inspect_object (o) { - var r = ""; - for(var p in o) { - var t = typeof o[p]; - r += "'" + p + "' => '" + t + "', "; - } - return r; -} - // Preprocess arguments -console.info("Arguments: " + testArguments); +console.log("Arguments: " + testArguments); let profilers = []; let setenv = {}; let runtime_args = []; let enable_gc = true; -let enable_zoneinfo = false; let working_dir='/'; while (testArguments !== undefined && testArguments.length > 0) { if (testArguments [0].startsWith ("--profile=")) { - var arg = testArguments [0].substring ("--profile=".length); + const arg = testArguments [0].substring ("--profile=".length); profilers.push (arg); testArguments = testArguments.slice (1); } else if (testArguments [0].startsWith ("--setenv=")) { - var arg = testArguments [0].substring ("--setenv=".length); - var parts = arg.split ('='); + const arg = testArguments [0].substring ("--setenv=".length); + const parts = arg.split ('='); if (parts.length != 2) fail_exec ("Error: malformed argument: '" + testArguments [0]); setenv [parts [0]] = parts [1]; testArguments = testArguments.slice (1); } else if (testArguments [0].startsWith ("--runtime-arg=")) { - var arg = testArguments [0].substring ("--runtime-arg=".length); - runtime_testArguments.push (arg); + const arg = testArguments [0].substring ("--runtime-arg=".length); + runtime_args = testArguments.push (arg); testArguments = testArguments.slice (1); } else if (testArguments [0] == "--disable-on-demand-gc") { enable_gc = false; testArguments = testArguments.slice (1); } else if (testArguments [0].startsWith ("--working-dir=")) { - var arg = testArguments [0].substring ("--working-dir=".length); + const arg = testArguments [0].substring ("--working-dir=".length); working_dir = arg; testArguments = testArguments.slice (1); } else { @@ -264,74 +264,79 @@ while (testArguments !== undefined && testArguments.length > 0) { // cheap way to let the testing infrastructure know we're running in a browser context (or not) setenv["IsBrowserDomSupported"] = is_browser.toString().toLowerCase(); -IOHandler.load ("mono-config.js"); - +// must be var as dotnet.js uses it var Module = { mainScriptUrlOrBlob: "dotnet.js", - print, - printErr, + preInit: async function() { + Module.config = await MONO.mono_wasm_load_config("./mono-config.json"); + }, onAbort: function(x) { - print ("ABORT: " + x); - var err = new Error(); - print ("Stacktrace: \n"); - print (err.stack); + console.log ("ABORT: " + x); + const err = new Error(); + console.log ("Stacktrace: \n"); + console.error (err.stack); test_exit (1); }, + onConfigLoaded: function (config) { + if (!config || config.error){ + console.log("An error occured while loading the config file"); + return; + } + + Module.config = config; + }, + onRuntimeInitialized: function () { // Have to set env vars here to enable setting MONO_LOG_LEVEL etc. - for (var variable in setenv) { - MONO.mono_wasm_setenv (variable, setenv [variable]); + for (let variable in setenv) { + Module.MONO.mono_wasm_setenv (variable, setenv [variable]); } if (!enable_gc) { Module.ccall ('mono_wasm_enable_on_demand_gc', 'void', ['number'], [0]); } - config.loaded_cb = function () { - let wds = FS.stat (working_dir); - if (wds === undefined || !FS.isDir (wds.mode)) { + MONO_CONFIG.loaded_cb = function () { + let wds = Module.FS.stat (working_dir); + if (wds === undefined || !Module.FS.isDir (wds.mode)) { fail_exec (`Could not find working directory ${working_dir}`); return; } - FS.chdir (working_dir); + Module.FS.chdir (working_dir); App.init (); }; - config.fetch_file_cb = function (asset) { + MONO_CONFIG.fetch_file_cb = function (asset) { // console.log("fetch_file_cb('" + asset + "')"); // for testing purposes add BCL assets to VFS until we special case File.Open // to identify when an assembly from the BCL is being open and resolve it correctly. /* - var content = new Uint8Array (read (asset, 'binary')); - var path = asset.substr(config.deploy_prefix.length); + const content = new Uint8Array (read (asset, 'binary')); + const path = asset.substr(config.deploy_prefix.length); IOHandler.writeContentToFile(content, path); */ return IOHandler.fetch (asset, { credentials: 'same-origin' }); }; - MONO.mono_load_runtime_and_bcl_args (config); + Module.MONO.mono_load_runtime_and_bcl_args (MONO_CONFIG); }, }; +globalThis.Module = Module; // needed as some functions (such as call_static_method) need access to Module. -IOHandler.load ("dotnet.js"); - -const IGNORE_PARAM_COUNT = -1; - -var App = { +const App = { init: function () { - var wasm_set_main_args = Module.cwrap ('mono_wasm_set_main_args', 'void', ['number', 'number']); - var wasm_strdup = Module.cwrap ('mono_wasm_strdup', 'number', ['string']); + const wasm_set_main_args = Module.cwrap ('mono_wasm_set_main_args', 'void', ['number', 'number']); + const wasm_strdup = Module.cwrap ('mono_wasm_strdup', 'number', ['string']); Module.wasm_exit = Module.cwrap ('mono_wasm_exit', 'void', ['number']); console.info("Initializing....."); - for (var i = 0; i < profilers.length; ++i) { - var init = Module.cwrap ('mono_wasm_load_profiler_' + profilers [i], 'void', ['string']) - + for (let i = 0; i < profilers.length; ++i) { + const init = Module.cwrap ('mono_wasm_load_profiler_' + profilers [i], 'void', ['string']); init (""); } @@ -341,15 +346,15 @@ var App = { } if (testArguments[0] == "--regression") { - var exec_regression = Module.cwrap ('mono_wasm_exec_regression', 'number', ['number', 'string']) + const exec_regression = Module.cwrap ('mono_wasm_exec_regression', 'number', ['number', 'string']); - var res = 0; + let res = 0; try { res = exec_regression (10, testArguments[1]); - Module.print ("REGRESSION RESULT: " + res); + console.log ("REGRESSION RESULT: " + res); } catch (e) { - Module.print ("ABORT: " + e); - print (e.stack); + console.error ("ABORT: " + e); + console.error (e.stack); res = 1; } @@ -360,7 +365,7 @@ var App = { } if (runtime_args.length > 0) - MONO.mono_wasm_set_runtime_options (runtime_args); + Module.MONO.mono_wasm_set_runtime_options (runtime_args); if (testArguments[0] == "--run") { // Run an exe @@ -370,22 +375,22 @@ var App = { } main_assembly_name = testArguments[1]; - var app_args = testArguments.slice (2); + const app_args = testArguments.slice (2); - var main_argc = testArguments.length - 2 + 1; - var main_argv = Module._malloc (main_argc * 4); + const main_argc = testArguments.length - 2 + 1; + const main_argv = Module._malloc (main_argc * 4); aindex = 0; - Module.setValue (main_argv + (aindex * 4), wasm_strdup (testArguments [1]), "i32") + Module.setValue (main_argv + (aindex * 4), wasm_strdup (testArguments [1]), "i32"); aindex += 1; - for (var i = 2; i < testArguments.length; ++i) { + for (let i = 2; i < testArguments.length; ++i) { Module.setValue (main_argv + (aindex * 4), wasm_strdup (testArguments [i]), "i32"); aindex += 1; } wasm_set_main_args (main_argc, main_argv); // Automatic signature isn't working correctly - let result = Module.mono_call_assembly_entry_point (main_assembly_name, [app_args], "m"); - let onError = function (error) + const result = Module.mono_call_assembly_entry_point (main_assembly_name, [app_args], "m"); + const onError = function (error) { console.error (error); if (error.stack) @@ -408,12 +413,21 @@ var App = { if ((arguments.length > 2) && (typeof (signature) !== "string")) throw new Error("Invalid number of arguments for call_test_method"); - var fqn = "[System.Private.Runtime.InteropServices.JavaScript.Tests]System.Runtime.InteropServices.JavaScript.Tests.HelperMarshal:" + method_name; + const fqn = "[System.Private.Runtime.InteropServices.JavaScript.Tests]System.Runtime.InteropServices.JavaScript.Tests.HelperMarshal:" + method_name; try { - return BINDING.call_static_method(fqn, args || [], signature); + return Module.BINDING.call_static_method(fqn, args || [], signature); } catch (exc) { console.error("exception thrown in", fqn); throw exc; } } }; + +// load the config and runtime files which will start the runtime init and subsiquently the tests +// uses promise chain as loading is async but we can't use await here +IOHandler + .load ("./dotnet.js") + .catch(function(err) { + console.error(err); + fail_exec("failed to load the mono-config.js or dotnet.js files"); + }); diff --git a/src/mono/wasm/runtime/library_mono.js b/src/mono/wasm/runtime/library_mono.js index 685aaaf375d85e..c7c425508e9085 100644 --- a/src/mono/wasm/runtime/library_mono.js +++ b/src/mono/wasm/runtime/library_mono.js @@ -60,15 +60,15 @@ var MonoSupportLib = { _id_table: {}, pump_message: function () { - if (!this.mono_background_exec) - this.mono_background_exec = Module.cwrap ("mono_background_exec", null); + if (!MONO.mono_background_exec) + MONO.mono_background_exec = Module.cwrap ("mono_background_exec", null); while (MONO.timeout_queue.length > 0) { --MONO.pump_count; MONO.timeout_queue.shift()(); } while (MONO.pump_count > 0) { --MONO.pump_count; - this.mono_background_exec (); + MONO.mono_background_exec (); } }, @@ -86,6 +86,7 @@ var MonoSupportLib = { module ["mono_wasm_new_root"] = MONO.mono_wasm_new_root.bind(MONO); module ["mono_wasm_new_roots"] = MONO.mono_wasm_new_roots.bind(MONO); module ["mono_wasm_release_roots"] = MONO.mono_wasm_release_roots.bind(MONO); + module ["mono_wasm_load_config"] = MONO.mono_wasm_load_config.bind(MONO); }, _base64Converter: { @@ -2323,6 +2324,28 @@ var MonoSupportLib = { console.debug('mono_wasm_debug_event_raised:aef14bca-5519-4dfe-b35a-f867abc123ae', JSON.stringify(event), JSON.stringify(args)); }, + + /** + * Loads the mono config file (typically called mono-config.json) + * + * @param {string} configFilePath - relative path to the config file + * @throws Will throw an error if the config file loading fails + */ + mono_wasm_load_config: async function (configFilePath) { + try { + let config = null; + // NOTE: when we add nodejs make sure to include the nodejs fetch package + if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_NODE) { + const configRaw = await fetch(configFilePath); + config = await configRaw.json(); + } else { // shell or worker + config = JSON.parse(read(configFilePath)); // read is a v8 debugger command + } + return config; + } catch(e) { + return {message: "failed to load config file", error: e}; + } + } }, mono_wasm_add_typed_value: function (type, str_value, value) { @@ -2458,17 +2481,17 @@ var MonoSupportLib = { }, mono_set_timeout: function (timeout, id) { - if (!this.mono_set_timeout_exec) - this.mono_set_timeout_exec = Module.cwrap ("mono_set_timeout_exec", null, [ 'number' ]); + if (!MONO.mono_set_timeout_exec) + MONO.mono_set_timeout_exec = Module.cwrap ("mono_set_timeout_exec", null, [ 'number' ]); if (typeof globalThis.setTimeout === 'function') { globalThis.setTimeout (function () { - this.mono_set_timeout_exec (id); + MONO.mono_set_timeout_exec (id); }, timeout); } else { ++MONO.pump_count; MONO.timeout_queue.push(function() { - this.mono_set_timeout_exec (id); + MONO.mono_set_timeout_exec (id); }) } }, @@ -2510,7 +2533,7 @@ var MonoSupportLib = { assembly_b64, pdb_b64 }); - }, + } }; autoAddDeps(MonoSupportLib, '$MONO') diff --git a/src/mono/wasm/wasm.proj b/src/mono/wasm/wasm.proj index 81ce7272efebcc..0fe35d63d5d8e7 100644 --- a/src/mono/wasm/wasm.proj +++ b/src/mono/wasm/wasm.proj @@ -69,12 +69,13 @@ <_EmccCommonFlags Include="-s ALLOW_MEMORY_GROWTH=1" /> <_EmccCommonFlags Include="-s NO_EXIT_RUNTIME=1" /> <_EmccCommonFlags Include="-s FORCE_FILESYSTEM=1" /> - <_EmccCommonFlags Include="-s "EXPORTED_RUNTIME_METHODS=['ccall', 'FS_createPath', 'FS_createDataFile', 'cwrap', 'setValue', 'getValue', 'UTF8ToString', 'UTF8ArrayToString', 'addFunction']"" /> + <_EmccCommonFlags Include="-s "EXPORTED_RUNTIME_METHODS=['ccall', 'FS_createPath', 'FS_createDataFile', 'cwrap', 'setValue', 'getValue', 'UTF8ToString', 'UTF8ArrayToString', 'addFunction', 'MONO', 'BINDING', 'DOTNET', 'FS']"" /> <_EmccCommonFlags Include="-s "EXPORTED_FUNCTIONS=['_putchar']"" /> <_EmccCommonFlags Include="--source-map-base http://example.com" /> <_EmccCommonFlags Include="-emit-llvm" /> - - <_EmccCommonFlags Include="-s MODULARIZE=1" Condition="'$(WasmEnableES6)' != 'false'" /> + + <_EmccCommonFlags Include="-s MODULARIZE=0"/> + <_EmccCommonFlags Include="-s EXPORT_ES6=1" Condition="'$(WasmEnableES6)' != 'false'" /> @@ -274,6 +275,7 @@ + diff --git a/src/tasks/WasmAppBuilder/WasmAppBuilder.cs b/src/tasks/WasmAppBuilder/WasmAppBuilder.cs index 9ef7679c292b66..49d984490a64b2 100644 --- a/src/tasks/WasmAppBuilder/WasmAppBuilder.cs +++ b/src/tasks/WasmAppBuilder/WasmAppBuilder.cs @@ -51,7 +51,7 @@ public class WasmAppBuilder : Task public ITaskItem[]? ExtraFilesToDeploy { get; set; } // - // Extra json elements to add to mono-config.js + // Extra json elements to add to mono-config.json // // Metadata: // - Value: can be a number, bool, quoted string, or json string @@ -246,11 +246,11 @@ public override bool Execute () config.Extra[name] = valueObject; } - string monoConfigPath = Path.Combine(AppDir, "mono-config.js"); + string monoConfigPath = Path.Combine(AppDir, "mono-config.json"); using (var sw = File.CreateText(monoConfigPath)) { var json = JsonSerializer.Serialize (config, new JsonSerializerOptions { WriteIndented = true }); - sw.Write($"config = {json};"); + sw.Write(json); } _fileWrites.Add(monoConfigPath); diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/BuildTestBase.cs b/src/tests/BuildWasmApps/Wasm.Build.Tests/BuildTestBase.cs index b5f1f7e0b95f73..99e721dfa65f78 100644 --- a/src/tests/BuildWasmApps/Wasm.Build.Tests/BuildTestBase.cs +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/BuildTestBase.cs @@ -347,7 +347,7 @@ protected static void AssertBasicAppBundle(string bundleDir, string projectName, "runtime.js", "dotnet.timezones.blat", "dotnet.wasm", - "mono-config.js", + "mono-config.json", "dotnet.js", "run-v8.sh" }); diff --git a/src/tests/FunctionalTests/WebAssembly/Browser/AOT/index.html b/src/tests/FunctionalTests/WebAssembly/Browser/AOT/index.html index efab9ac4324a21..642987d23c5e2b 100644 --- a/src/tests/FunctionalTests/WebAssembly/Browser/AOT/index.html +++ b/src/tests/FunctionalTests/WebAssembly/Browser/AOT/index.html @@ -47,7 +47,6 @@ }, }; - diff --git a/src/tests/FunctionalTests/WebAssembly/Browser/AOT/runtime.js b/src/tests/FunctionalTests/WebAssembly/Browser/AOT/runtime.js index a39b0b97b14901..a7b616b6e611e3 100644 --- a/src/tests/FunctionalTests/WebAssembly/Browser/AOT/runtime.js +++ b/src/tests/FunctionalTests/WebAssembly/Browser/AOT/runtime.js @@ -2,8 +2,21 @@ // The .NET Foundation licenses this file to you under the MIT license. var Module = { + + config: null, + + preInit: async function() { + Module.config = await MONO.mono_wasm_load_config("./mono-config.json"); + }, + onRuntimeInitialized: function () { - config.loaded_cb = function () { + if (!Module.config || Module.config.error){ + console.log("No config found"); + test_exit(1); + throw(Module.config.error); + } + + Module.config.loaded_cb = function () { try { App.init (); } catch (error) { @@ -11,13 +24,13 @@ var Module = { throw (error); } }; - config.fetch_file_cb = function (asset) { + Module.config.fetch_file_cb = function (asset) { return fetch (asset, { credentials: 'same-origin' }); } try { - MONO.mono_load_runtime_and_bcl_args (config); + MONO.mono_load_runtime_and_bcl_args (Module.config); } catch (error) { test_exit(1); throw(error); diff --git a/src/tests/FunctionalTests/WebAssembly/Browser/NormalInterp/index.html b/src/tests/FunctionalTests/WebAssembly/Browser/NormalInterp/index.html index 03f68679a5b85c..9de05f5031b325 100644 --- a/src/tests/FunctionalTests/WebAssembly/Browser/NormalInterp/index.html +++ b/src/tests/FunctionalTests/WebAssembly/Browser/NormalInterp/index.html @@ -47,7 +47,6 @@ }, }; - diff --git a/src/tests/FunctionalTests/WebAssembly/Browser/NormalInterp/runtime.js b/src/tests/FunctionalTests/WebAssembly/Browser/NormalInterp/runtime.js index a39b0b97b14901..917f7b12447a32 100644 --- a/src/tests/FunctionalTests/WebAssembly/Browser/NormalInterp/runtime.js +++ b/src/tests/FunctionalTests/WebAssembly/Browser/NormalInterp/runtime.js @@ -2,8 +2,21 @@ // The .NET Foundation licenses this file to you under the MIT license. var Module = { + + config: null, + + preInit: async function() { + Module.config = await MONO.mono_wasm_load_config("./mono-config.json"); + }, + onRuntimeInitialized: function () { - config.loaded_cb = function () { + if (!Module.config || Module.config.error){ + console.log("No config found"); + test_exit(1); + throw(Module.config.error); + } + + Module.config.loaded_cb = function () { try { App.init (); } catch (error) { @@ -11,13 +24,13 @@ var Module = { throw (error); } }; - config.fetch_file_cb = function (asset) { + Module.config.fetch_file_cb = function (asset) { return fetch (asset, { credentials: 'same-origin' }); } try { - MONO.mono_load_runtime_and_bcl_args (config); + MONO.mono_load_runtime_and_bcl_args (Module.config); } catch (error) { test_exit(1); throw(error); From fa8bd01baf89db727116f26014b3cc828aa72ea3 Mon Sep 17 00:00:00 2001 From: Daniel-Genkin Date: Sun, 20 Jun 2021 09:31:09 -0400 Subject: [PATCH 20/25] updated config loading --- src/mono/wasm/runtime-test.js | 17 ++++------------- src/mono/wasm/runtime/library_mono.js | 4 +++- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/mono/wasm/runtime-test.js b/src/mono/wasm/runtime-test.js index 530a60d003d5b1..538797e39be416 100644 --- a/src/mono/wasm/runtime-test.js +++ b/src/mono/wasm/runtime-test.js @@ -269,7 +269,7 @@ var Module = { mainScriptUrlOrBlob: "dotnet.js", preInit: async function() { - Module.config = await MONO.mono_wasm_load_config("./mono-config.json"); + Module.config = await Module.MONO.mono_wasm_load_config("./mono-config.json"); }, onAbort: function(x) { @@ -280,15 +280,6 @@ var Module = { test_exit (1); }, - onConfigLoaded: function (config) { - if (!config || config.error){ - console.log("An error occured while loading the config file"); - return; - } - - Module.config = config; - }, - onRuntimeInitialized: function () { // Have to set env vars here to enable setting MONO_LOG_LEVEL etc. for (let variable in setenv) { @@ -299,7 +290,7 @@ var Module = { Module.ccall ('mono_wasm_enable_on_demand_gc', 'void', ['number'], [0]); } - MONO_CONFIG.loaded_cb = function () { + Module.config.loaded_cb = function () { let wds = Module.FS.stat (working_dir); if (wds === undefined || !Module.FS.isDir (wds.mode)) { fail_exec (`Could not find working directory ${working_dir}`); @@ -309,7 +300,7 @@ var Module = { Module.FS.chdir (working_dir); App.init (); }; - MONO_CONFIG.fetch_file_cb = function (asset) { + Module.config.fetch_file_cb = function (asset) { // console.log("fetch_file_cb('" + asset + "')"); // for testing purposes add BCL assets to VFS until we special case File.Open // to identify when an assembly from the BCL is being open and resolve it correctly. @@ -321,7 +312,7 @@ var Module = { return IOHandler.fetch (asset, { credentials: 'same-origin' }); }; - Module.MONO.mono_load_runtime_and_bcl_args (MONO_CONFIG); + Module.MONO.mono_load_runtime_and_bcl_args (Module.config); }, }; globalThis.Module = Module; // needed as some functions (such as call_static_method) need access to Module. diff --git a/src/mono/wasm/runtime/library_mono.js b/src/mono/wasm/runtime/library_mono.js index c7c425508e9085..ba4676b2a29958 100644 --- a/src/mono/wasm/runtime/library_mono.js +++ b/src/mono/wasm/runtime/library_mono.js @@ -2335,9 +2335,11 @@ var MonoSupportLib = { try { let config = null; // NOTE: when we add nodejs make sure to include the nodejs fetch package - if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_NODE) { + if (ENVIRONMENT_IS_WEB) { const configRaw = await fetch(configFilePath); config = await configRaw.json(); + } else if (ENVIRONMENT_IS_NODE){ + config = require(configFilePath) } else { // shell or worker config = JSON.parse(read(configFilePath)); // read is a v8 debugger command } From a7d3007de4734b22afae2bf390187e58e3974957 Mon Sep 17 00:00:00 2001 From: Daniel-Genkin Date: Mon, 21 Jun 2021 11:56:46 -0400 Subject: [PATCH 21/25] Added node build target to MSbuild and tests --- Directory.Build.props | 17 +++++---- eng/Subsets.props | 2 +- eng/build.ps1 | 10 +++--- eng/build.sh | 10 +++--- eng/liveBuilds.targets | 6 ++-- eng/testing/tests.mobile.targets | 4 +-- eng/testing/tests.targets | 16 ++++----- .../Net/Prerequisites/LocalEchoServer.props | 2 +- .../tests/Microsoft.CSharp.Tests.csproj | 2 +- ...nsions.FileProviders.Physical.Tests.csproj | 2 +- .../Microsoft.NETCore.Platforms.Tests.csproj | 2 +- ...System.Collections.Concurrent.Tests.csproj | 2 +- .../System.Collections.Immutable.Tests.csproj | 2 +- ...System.Collections.NonGeneric.Tests.csproj | 2 +- .../tests/System.Collections.Tests.csproj | 2 +- ...System.Composition.TypedParts.Tests.csproj | 2 +- ...guration.ConfigurationManager.Tests.csproj | 2 +- ...ics.DiagnosticSource.Switches.Tests.csproj | 2 +- ...m.Diagnostics.FileVersionInfo.Tests.csproj | 2 +- .../System.Diagnostics.Process.Tests.csproj | 2 +- ...System.Diagnostics.StackTrace.Tests.csproj | 4 +-- .../tests/System.Drawing.Common.Tests.csproj | 2 +- .../System.Drawing.Primitives.Tests.csproj | 2 +- .../System.IO.Compression.Brotli.Tests.csproj | 2 +- .../System.IO.FileSystem.Watcher.Tests.csproj | 2 +- .../System.IO.IsolatedStorage.Tests.csproj | 2 +- .../tests/System.IO.Pipes.Tests.csproj | 2 +- .../tests/System.Linq.Tests.csproj | 2 +- .../System.Net.Connections.Tests.csproj | 2 +- .../System.Net.Http.Functional.Tests.csproj | 6 ++-- .../System.Net.HttpListener.Tests.csproj | 2 +- ...Net.NameResolution.Functional.Tests.csproj | 2 +- ...System.Net.NameResolution.Pal.Tests.csproj | 2 +- ...NetworkInformation.Functional.Tests.csproj | 2 +- .../System.Net.Ping.Functional.Tests.csproj | 2 +- .../tests/System.Net.Requests.Tests.csproj | 2 +- .../System.Net.Security.Tests.csproj | 2 +- .../System.Net.Security.Unit.Tests.csproj | 2 +- .../System.Net.Sockets.Tests.csproj | 2 +- .../tests/System.Net.WebClient.Tests.csproj | 2 +- .../System.Net.WebSockets.Client.Tests.csproj | 6 ++-- .../System.Reflection.Metadata.Tests.csproj | 2 +- ...eflection.MetadataLoadContext.Tests.csproj | 2 +- .../tests/System.Reflection.Tests.csproj | 4 +-- .../tests/System.Runtime.Loader.Tests.csproj | 6 ++-- .../System.Text.Json.Tests.csproj | 2 +- ...ystem.Text.RegularExpressions.Tests.csproj | 2 +- .../System.Threading.Channels.Tests.csproj | 2 +- src/libraries/pretest.proj | 2 +- src/libraries/sendtohelixhelp.proj | 36 +++++++++---------- src/libraries/tests.proj | 12 +++---- src/mono/nuget/mono-packages.proj | 2 +- .../AotCompilerTask/MonoAOTCompiler.props | 2 +- src/tests/Common/helixpublishwitharcade.proj | 4 +-- src/tests/Common/tests.targets | 2 +- .../FunctionalTests/Directory.Build.props | 2 +- src/tests/Interop/ICastable/Castable.csproj | 2 +- 57 files changed, 114 insertions(+), 113 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 600f7b256da6fc..fff858c32c8c06 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -17,7 +17,7 @@ Solaris Linux windows - true + true @@ -27,7 +27,7 @@ arm armel arm64 - wasm + wasm x64 x64 $(TargetArchitecture) @@ -123,7 +123,7 @@ <_portableOS Condition="'$(_runtimeOSFamily)' == 'FreeBSD'">freebsd <_portableOS Condition="'$(_runtimeOSFamily)' == 'illumos'">illumos <_portableOS Condition="'$(_runtimeOSFamily)' == 'Solaris'">solaris - <_portableOS Condition="'$(_runtimeOS)' == 'Browser'">browser + <_portableOS Condition="'$(_runtimeOS)' == 'Browser' or '$(_runtimeOS)' == 'Node'">browser <_portableOS Condition="'$(_runtimeOS)' == 'maccatalyst'">maccatalyst <_portableOS Condition="'$(_runtimeOS)' == 'ios'">ios <_portableOS Condition="'$(_runtimeOS)' == 'iOSSimulator'">iossimulator @@ -145,9 +145,9 @@ <_toolRuntimeRID Condition="'$(_runtimeOS)' == 'linux-musl' and $(TargetArchitecture.StartsWith('arm')) and !$(_hostArch.StartsWith('arm'))">linux-x64 - <_toolRuntimeRID Condition="'$(_runtimeOS)' == 'browser'">linux-x64 - <_toolRuntimeRID Condition="'$(_runtimeOS)' == 'browser' and $([MSBuild]::IsOSPlatform('WINDOWS'))">win-x64 - <_toolRuntimeRID Condition="'$(_runtimeOS)' == 'browser' and $([MSBuild]::IsOSPlatform('OSX'))">osx-x64 + <_toolRuntimeRID Condition="'$(_runtimeOS)' == 'browser' or '$(_runtimeOS)' == 'node'">linux-x64 + <_toolRuntimeRID Condition="('$(_runtimeOS)' == 'browser' or '$(_runtimeOS)' == 'node') and $([MSBuild]::IsOSPlatform('WINDOWS'))">win-x64 + <_toolRuntimeRID Condition="('$(_runtimeOS)' == 'browser' or '$(_runtimeOS)' == 'node') and $([MSBuild]::IsOSPlatform('OSX'))">osx-x64 <_toolRuntimeRID Condition="'$(_runtimeOS)' == 'android'">linux-x64 @@ -178,7 +178,7 @@ <_outputRID Condition="'$(TargetOS)' == 'tvOS'">tvos-$(TargetArchitecture) <_outputRID Condition="'$(TargetOS)' == 'tvOSSimulator'">tvossimulator-$(TargetArchitecture) <_outputRID Condition="'$(TargetOS)' == 'Android'">android-$(TargetArchitecture) - <_outputRID Condition="'$(TargetOS)' == 'Browser'">browser-$(TargetArchitecture) + <_outputRID Condition="'$(TargetOS)' == 'Browser' or '$(TargetOS)' == 'Node'">browser-$(TargetArchitecture) $(PackageRID) $(_outputRID) @@ -197,8 +197,7 @@ true true true - true - true + true true true diff --git a/eng/Subsets.props b/eng/Subsets.props index bf6b25bffc7317..3ab4fe5fb551c3 100644 --- a/eng/Subsets.props +++ b/eng/Subsets.props @@ -225,7 +225,7 @@ - + diff --git a/eng/build.ps1 b/eng/build.ps1 index 5980695e3a2c34..5ecc79f289be4a 100644 --- a/eng/build.ps1 +++ b/eng/build.ps1 @@ -6,7 +6,7 @@ Param( [string][Alias('f')]$framework, [string]$vs, [string][Alias('v')]$verbosity = "minimal", - [ValidateSet("windows","Linux","OSX","Android","Browser")][string]$os, + [ValidateSet("windows","Linux","OSX","Android","Browser", "Node")][string]$os, [switch]$allconfigurations, [switch]$coverage, [string]$testscope, @@ -37,7 +37,7 @@ function Get-Help() { Write-Host " -help (-h) Print help and exit." Write-Host " -librariesConfiguration (-lc) Libraries build configuration: Debug or Release." Write-Host " [Default: Debug]" - Write-Host " -os Target operating system: windows, Linux, OSX, Android or Browser." + Write-Host " -os Target operating system: windows, Linux, OSX, Android, Browser or Node." Write-Host " [Default: Your machine's OS.]" Write-Host " -runtimeConfiguration (-rc) Runtime build configuration: Debug, Release or Checked." Write-Host " Checked is exclusive to the CLR runtime. It is the same as Debug, except code is" @@ -249,12 +249,12 @@ foreach ($argument in $PSBoundParameters.Keys) $failedBuilds = @() -if ($os -eq "Browser") { +if ($os -eq "Browser" -or $os -eq "Node") { # override default arch for Browser, we only support wasm $arch = "wasm" if ($msbuild -eq $True) { - Write-Error "Using the -msbuild option isn't supported when building for Browser on Windows, we need need ninja for Emscripten." + Write-Error "Using the -msbuild option isn't supported when building for Browser or Node on Windows, we need need ninja for Emscripten." exit 1 } } @@ -263,7 +263,7 @@ foreach ($config in $configuration) { $argumentsWithConfig = $arguments + " -configuration $((Get-Culture).TextInfo.ToTitleCase($config))"; foreach ($singleArch in $arch) { $argumentsWithArch = "/p:TargetArchitecture=$singleArch " + $argumentsWithConfig - if ($os -eq "Browser") { + if ($os -eq "Browser" -or $os -eq "Node") { $env:__DistroRid="browser-$singleArch" } else { $env:__DistroRid="win-$singleArch" diff --git a/eng/build.sh b/eng/build.sh index 128e720d3c0b2d..71163b22b45a06 100755 --- a/eng/build.sh +++ b/eng/build.sh @@ -29,7 +29,7 @@ usage() echo " --librariesConfiguration (-lc) Libraries build configuration: Debug or Release." echo " [Default: Debug]" echo " --os Target operating system: windows, Linux, FreeBSD, OSX, MacCatalyst, tvOS," - echo " tvOSSimulator, iOS, iOSSimulator, Android, Browser, NetBSD, illumos or Solaris." + echo " tvOSSimulator, iOS, iOSSimulator, Android, Browser, Node, NetBSD, illumos or Solaris." echo " [Default: Your machine's OS.]" echo " --projects Project or solution file(s) to build." echo " --runtimeConfiguration (-rc) Runtime build configuration: Debug, Release or Checked." @@ -277,13 +277,15 @@ while [[ $# > 0 ]]; do os="Android" ;; browser) os="Browser" ;; + node) + os="Node" ;; illumos) os="illumos" ;; solaris) os="Solaris" ;; *) echo "Unsupported target OS '$2'." - echo "The allowed values are windows, Linux, FreeBSD, OSX, MacCatalyst, tvOS, tvOSSimulator, iOS, iOSSimulator, Android, Browser, illumos and Solaris." + echo "The allowed values are windows, Linux, FreeBSD, OSX, MacCatalyst, tvOS, tvOSSimulator, iOS, iOSSimulator, Android, Browser, Node, illumos and Solaris." exit 1 ;; esac @@ -461,8 +463,8 @@ if [ ${#actInt[@]} -eq 0 ]; then arguments="-restore -build $arguments" fi -if [ "$os" = "Browser" ] && [ "$arch" != "wasm" ]; then - # override default arch for Browser, we only support wasm +if [[ "$os" = "Browser" ] || [ "$os" = "Node" ]] && [ "$arch" != "wasm" ]; then + # override default arch for Browser and Node, we only support wasm arch=wasm fi diff --git a/eng/liveBuilds.targets b/eng/liveBuilds.targets index 11ea3bf8f3aea7..8b597eeeb01ad9 100644 --- a/eng/liveBuilds.targets +++ b/eng/liveBuilds.targets @@ -164,14 +164,14 @@ $(LibrariesNativeArtifactsPath)*.pdb" IsNative="true" Exclude="@(ExcludeNativeLibrariesRuntimeFiles)" /> - - - $(IntermediateOutputPath)mobile - + <_runnerFilesToPublish Include="$(AndroidTestRunnerDir)*" Condition="'$(TargetOS)' == 'Android'" /> <_runnerFilesToPublish Include="$(AppleTestRunnerDir)*" Condition="'$(TargetOS)' == 'MacCatalyst' or '$(TargetOS)' == 'iOS' or '$(TargetOS)' == 'iOSSimulator' or '$(TargetOS)' == 'tvOS' or '$(TargetOS)' == 'tvOSSimulator'" /> - <_runnerFilesToPublish Include="$(WasmTestRunnerDir)*" Condition="'$(TargetOS)' == 'Browser'" /> + <_runnerFilesToPublish Include="$(WasmTestRunnerDir)*" Condition="'$(TargetOS)' == 'Browser' or '$(TargetOS)' == 'Node'" /> <_resolvedFilesToPublishToFileName Include="@(ResolvedFileToPublish -> '%(FileName)%(Extension)')" /> diff --git a/eng/testing/tests.targets b/eng/testing/tests.targets index dd40856e629b1b..ac4171ee7b3699 100644 --- a/eng/testing/tests.targets +++ b/eng/testing/tests.targets @@ -4,13 +4,13 @@ RunnerTemplate.sh AppleRunnerTemplate.sh AndroidRunnerTemplate.sh - WasmRunnerTemplate.sh - WasmRunnerTemplate.cmd + WasmRunnerTemplate.sh + WasmRunnerTemplate.cmd $(MSBuildThisFileDirectory)$(RunScriptInputName) RunTests.sh - RunTests.cmd + RunTests.cmd $([MSBuild]::NormalizePath('$(OutDir)', '$(RunScriptOutputName)')) %RUNTIME_PATH%\ @@ -35,19 +35,19 @@ - + <_ZipSourceDirectory>$(OutDir) - <_ZipSourceDirectory Condition="'$(TargetOS)' == 'Browser' or '$(TestSingleFile)' == 'true'">$(BundleDir) + <_ZipSourceDirectory Condition="'$(TargetOS)' == 'Browser' or '$(TargetOS)' == 'Node' or '$(TestSingleFile)' == 'true'">$(BundleDir) @@ -64,7 +64,7 @@ $(RunScriptCommand) $RSP_FILE - $(RunScriptCommand) %RSP_FILE% + $(RunScriptCommand) %RSP_FILE% $([MSBuild]::Escape('$(RunScriptCommand)')) @@ -108,7 +108,7 @@ $([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), '$(NETCoreAppCurrentVersion)'))">$(RunTestsCommand) --runtime-path "$(NetCoreAppCurrentTestHostPath.TrimEnd('\/'))" $(RunTestsCommand) --rsp-file "$(TestRspFile)" "$(RunScriptOutputPath)" $(AssemblyName) $(TargetArchitecture) $(TargetOS.ToLowerInvariant()) $(TestProjectName) $(AdditionalXHarnessArguments) - "$(RunScriptOutputPath)" $(JSEngine) $(AssemblyName).dll $(Scenario) + "$(RunScriptOutputPath)" $(JSEngine) $(AssemblyName).dll $(Scenario) diff --git a/src/libraries/Common/tests/System/Net/Prerequisites/LocalEchoServer.props b/src/libraries/Common/tests/System/Net/Prerequisites/LocalEchoServer.props index 97bdbf298b8426..113efb2d561ff4 100644 --- a/src/libraries/Common/tests/System/Net/Prerequisites/LocalEchoServer.props +++ b/src/libraries/Common/tests/System/Net/Prerequisites/LocalEchoServer.props @@ -1,5 +1,5 @@ - + WasmTestOnBrowser $(TestArchiveRoot)browseronly/ $(TestArchiveTestsRoot)$(OSPlatformConfig)/ diff --git a/src/libraries/Microsoft.CSharp/tests/Microsoft.CSharp.Tests.csproj b/src/libraries/Microsoft.CSharp/tests/Microsoft.CSharp.Tests.csproj index fd58dca4e44f61..7dfe19965330e7 100644 --- a/src/libraries/Microsoft.CSharp/tests/Microsoft.CSharp.Tests.csproj +++ b/src/libraries/Microsoft.CSharp/tests/Microsoft.CSharp.Tests.csproj @@ -8,7 +8,7 @@ --> $(Features.Replace('strict', '') - true + true diff --git a/src/libraries/Microsoft.Extensions.FileProviders.Physical/tests/Microsoft.Extensions.FileProviders.Physical.Tests.csproj b/src/libraries/Microsoft.Extensions.FileProviders.Physical/tests/Microsoft.Extensions.FileProviders.Physical.Tests.csproj index d57fed0ca59497..c3242950754b56 100644 --- a/src/libraries/Microsoft.Extensions.FileProviders.Physical/tests/Microsoft.Extensions.FileProviders.Physical.Tests.csproj +++ b/src/libraries/Microsoft.Extensions.FileProviders.Physical/tests/Microsoft.Extensions.FileProviders.Physical.Tests.csproj @@ -4,7 +4,7 @@ Microsoft.Extensions.FileProviders.Physical $(NetCoreAppCurrent);net461 true - true + true diff --git a/src/libraries/Microsoft.NETCore.Platforms/tests/Microsoft.NETCore.Platforms.Tests.csproj b/src/libraries/Microsoft.NETCore.Platforms/tests/Microsoft.NETCore.Platforms.Tests.csproj index d39b20d6d9f5e2..0d8d2d511b81f9 100644 --- a/src/libraries/Microsoft.NETCore.Platforms/tests/Microsoft.NETCore.Platforms.Tests.csproj +++ b/src/libraries/Microsoft.NETCore.Platforms/tests/Microsoft.NETCore.Platforms.Tests.csproj @@ -1,7 +1,7 @@ $(NetCoreAppCurrent);net472 - true + true diff --git a/src/libraries/System.Collections.Concurrent/tests/System.Collections.Concurrent.Tests.csproj b/src/libraries/System.Collections.Concurrent/tests/System.Collections.Concurrent.Tests.csproj index d0beb0ebc46996..24a695b68d7e6f 100644 --- a/src/libraries/System.Collections.Concurrent/tests/System.Collections.Concurrent.Tests.csproj +++ b/src/libraries/System.Collections.Concurrent/tests/System.Collections.Concurrent.Tests.csproj @@ -3,7 +3,7 @@ true true $(NetCoreAppCurrent) - true + true 0436 $(NetCoreAppCurrent);net461 - true + true true $(NetCoreAppCurrent) - true + true diff --git a/src/libraries/System.Collections/tests/System.Collections.Tests.csproj b/src/libraries/System.Collections/tests/System.Collections.Tests.csproj index 66f5dee8d5ba6d..0865eb1642f290 100644 --- a/src/libraries/System.Collections/tests/System.Collections.Tests.csproj +++ b/src/libraries/System.Collections/tests/System.Collections.Tests.csproj @@ -2,7 +2,7 @@ $(NetCoreAppCurrent) true - true + true diff --git a/src/libraries/System.Composition.TypedParts/tests/System.Composition.TypedParts.Tests.csproj b/src/libraries/System.Composition.TypedParts/tests/System.Composition.TypedParts.Tests.csproj index 293590ae99aff9..1f587fb6e9e049 100644 --- a/src/libraries/System.Composition.TypedParts/tests/System.Composition.TypedParts.Tests.csproj +++ b/src/libraries/System.Composition.TypedParts/tests/System.Composition.TypedParts.Tests.csproj @@ -1,7 +1,7 @@ $(NetCoreAppCurrent);net461 - true + true diff --git a/src/libraries/System.Configuration.ConfigurationManager/tests/System.Configuration.ConfigurationManager.Tests.csproj b/src/libraries/System.Configuration.ConfigurationManager/tests/System.Configuration.ConfigurationManager.Tests.csproj index 3a766de5aaebd3..05c844ae26096a 100644 --- a/src/libraries/System.Configuration.ConfigurationManager/tests/System.Configuration.ConfigurationManager.Tests.csproj +++ b/src/libraries/System.Configuration.ConfigurationManager/tests/System.Configuration.ConfigurationManager.Tests.csproj @@ -5,7 +5,7 @@ true true $(NetCoreAppCurrent)-windows;net461 - true + true $(NetCoreAppCurrent) true - true + true diff --git a/src/libraries/System.Diagnostics.FileVersionInfo/tests/System.Diagnostics.FileVersionInfo.Tests/System.Diagnostics.FileVersionInfo.Tests.csproj b/src/libraries/System.Diagnostics.FileVersionInfo/tests/System.Diagnostics.FileVersionInfo.Tests/System.Diagnostics.FileVersionInfo.Tests.csproj index ad027e8be25474..f0b8d215972941 100644 --- a/src/libraries/System.Diagnostics.FileVersionInfo/tests/System.Diagnostics.FileVersionInfo.Tests/System.Diagnostics.FileVersionInfo.Tests.csproj +++ b/src/libraries/System.Diagnostics.FileVersionInfo/tests/System.Diagnostics.FileVersionInfo.Tests/System.Diagnostics.FileVersionInfo.Tests.csproj @@ -2,7 +2,7 @@ $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser true - true + true diff --git a/src/libraries/System.Diagnostics.Process/tests/System.Diagnostics.Process.Tests.csproj b/src/libraries/System.Diagnostics.Process/tests/System.Diagnostics.Process.Tests.csproj index 776b69684d3d7b..9ec482b23d57d1 100644 --- a/src/libraries/System.Diagnostics.Process/tests/System.Diagnostics.Process.Tests.csproj +++ b/src/libraries/System.Diagnostics.Process/tests/System.Diagnostics.Process.Tests.csproj @@ -4,7 +4,7 @@ $(DefineConstants);TargetsWindows true $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser - true + true true - true + true @@ -17,7 +17,7 @@ - + diff --git a/src/libraries/System.Drawing.Common/tests/System.Drawing.Common.Tests.csproj b/src/libraries/System.Drawing.Common/tests/System.Drawing.Common.Tests.csproj index 1b9175f3eb5e12..7d6ef19b18410c 100644 --- a/src/libraries/System.Drawing.Common/tests/System.Drawing.Common.Tests.csproj +++ b/src/libraries/System.Drawing.Common/tests/System.Drawing.Common.Tests.csproj @@ -3,7 +3,7 @@ true true $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;net48 - true + true diff --git a/src/libraries/System.Drawing.Primitives/tests/System.Drawing.Primitives.Tests.csproj b/src/libraries/System.Drawing.Primitives/tests/System.Drawing.Primitives.Tests.csproj index 53f60dbcb90928..04f58ff0338ae1 100644 --- a/src/libraries/System.Drawing.Primitives/tests/System.Drawing.Primitives.Tests.csproj +++ b/src/libraries/System.Drawing.Primitives/tests/System.Drawing.Primitives.Tests.csproj @@ -1,7 +1,7 @@ $(NetCoreAppCurrent) - true + true diff --git a/src/libraries/System.IO.Compression.Brotli/tests/System.IO.Compression.Brotli.Tests.csproj b/src/libraries/System.IO.Compression.Brotli/tests/System.IO.Compression.Brotli.Tests.csproj index d68a7be37b621e..4134605fcc4d6e 100644 --- a/src/libraries/System.IO.Compression.Brotli/tests/System.IO.Compression.Brotli.Tests.csproj +++ b/src/libraries/System.IO.Compression.Brotli/tests/System.IO.Compression.Brotli.Tests.csproj @@ -2,7 +2,7 @@ $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser true - true + true diff --git a/src/libraries/System.IO.FileSystem.Watcher/tests/System.IO.FileSystem.Watcher.Tests.csproj b/src/libraries/System.IO.FileSystem.Watcher/tests/System.IO.FileSystem.Watcher.Tests.csproj index 67c502fa83412a..8bf5c319347efb 100644 --- a/src/libraries/System.IO.FileSystem.Watcher/tests/System.IO.FileSystem.Watcher.Tests.csproj +++ b/src/libraries/System.IO.FileSystem.Watcher/tests/System.IO.FileSystem.Watcher.Tests.csproj @@ -2,7 +2,7 @@ true $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Linux;$(NetCoreAppCurrent)-OSX;$(NetCoreAppCurrent)-iOS;$(NetCoreAppCurrent)-tvOS;$(NetCoreAppCurrent)-FreeBSD - true + true diff --git a/src/libraries/System.IO.IsolatedStorage/tests/System.IO.IsolatedStorage.Tests.csproj b/src/libraries/System.IO.IsolatedStorage/tests/System.IO.IsolatedStorage.Tests.csproj index 5765f53e6056ec..01999bdcd39e8f 100644 --- a/src/libraries/System.IO.IsolatedStorage/tests/System.IO.IsolatedStorage.Tests.csproj +++ b/src/libraries/System.IO.IsolatedStorage/tests/System.IO.IsolatedStorage.Tests.csproj @@ -1,7 +1,7 @@ $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser - true + true diff --git a/src/libraries/System.IO.Pipes/tests/System.IO.Pipes.Tests.csproj b/src/libraries/System.IO.Pipes/tests/System.IO.Pipes.Tests.csproj index b639953aff8443..6b1ea1adc080f9 100644 --- a/src/libraries/System.IO.Pipes/tests/System.IO.Pipes.Tests.csproj +++ b/src/libraries/System.IO.Pipes/tests/System.IO.Pipes.Tests.csproj @@ -3,7 +3,7 @@ true true $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent) - true + true diff --git a/src/libraries/System.Linq/tests/System.Linq.Tests.csproj b/src/libraries/System.Linq/tests/System.Linq.Tests.csproj index cd15cfbbf59d5d..a946692b7cdab5 100644 --- a/src/libraries/System.Linq/tests/System.Linq.Tests.csproj +++ b/src/libraries/System.Linq/tests/System.Linq.Tests.csproj @@ -1,7 +1,7 @@ $(NetCoreAppCurrent) - true + true diff --git a/src/libraries/System.Net.Connections/tests/System.Net.Connections.Tests/System.Net.Connections.Tests.csproj b/src/libraries/System.Net.Connections/tests/System.Net.Connections.Tests/System.Net.Connections.Tests.csproj index 7ddfadfd04df2b..cd2f10d10ed93d 100644 --- a/src/libraries/System.Net.Connections/tests/System.Net.Connections.Tests/System.Net.Connections.Tests.csproj +++ b/src/libraries/System.Net.Connections/tests/System.Net.Connections.Tests/System.Net.Connections.Tests.csproj @@ -3,7 +3,7 @@ $(NetCoreAppCurrent) - true + true diff --git a/src/libraries/System.Net.Http/tests/FunctionalTests/System.Net.Http.Functional.Tests.csproj b/src/libraries/System.Net.Http/tests/FunctionalTests/System.Net.Http.Functional.Tests.csproj index 7c9b9d6d157382..534d326afaee3f 100644 --- a/src/libraries/System.Net.Http/tests/FunctionalTests/System.Net.Http.Functional.Tests.csproj +++ b/src/libraries/System.Net.Http/tests/FunctionalTests/System.Net.Http.Functional.Tests.csproj @@ -9,15 +9,15 @@ $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Linux;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-OSX - + WasmTestOnBrowser $(TestArchiveRoot)browseronly/ $(TestArchiveTestsRoot)$(OSPlatformConfig)/ - + - + diff --git a/src/libraries/System.Net.HttpListener/tests/System.Net.HttpListener.Tests.csproj b/src/libraries/System.Net.HttpListener/tests/System.Net.HttpListener.Tests.csproj index ff51965c789584..6bfdeab2f3aae6 100644 --- a/src/libraries/System.Net.HttpListener/tests/System.Net.HttpListener.Tests.csproj +++ b/src/libraries/System.Net.HttpListener/tests/System.Net.HttpListener.Tests.csproj @@ -3,7 +3,7 @@ true ../src/Resources/Strings.resx $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-OSX - true + true diff --git a/src/libraries/System.Net.NameResolution/tests/FunctionalTests/System.Net.NameResolution.Functional.Tests.csproj b/src/libraries/System.Net.NameResolution/tests/FunctionalTests/System.Net.NameResolution.Functional.Tests.csproj index 2f9dea9c37cde4..79e3af4e35a3b9 100644 --- a/src/libraries/System.Net.NameResolution/tests/FunctionalTests/System.Net.NameResolution.Functional.Tests.csproj +++ b/src/libraries/System.Net.NameResolution/tests/FunctionalTests/System.Net.NameResolution.Functional.Tests.csproj @@ -2,7 +2,7 @@ $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser true - true + true diff --git a/src/libraries/System.Net.NameResolution/tests/PalTests/System.Net.NameResolution.Pal.Tests.csproj b/src/libraries/System.Net.NameResolution/tests/PalTests/System.Net.NameResolution.Pal.Tests.csproj index 7b2b9ee2c9fd60..f820b102497aad 100644 --- a/src/libraries/System.Net.NameResolution/tests/PalTests/System.Net.NameResolution.Pal.Tests.csproj +++ b/src/libraries/System.Net.NameResolution/tests/PalTests/System.Net.NameResolution.Pal.Tests.csproj @@ -4,7 +4,7 @@ ../../src/Resources/Strings.resx $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser annotations - true + true diff --git a/src/libraries/System.Net.NetworkInformation/tests/FunctionalTests/System.Net.NetworkInformation.Functional.Tests.csproj b/src/libraries/System.Net.NetworkInformation/tests/FunctionalTests/System.Net.NetworkInformation.Functional.Tests.csproj index 07e4ae778c3708..61f1bfdab549d6 100644 --- a/src/libraries/System.Net.NetworkInformation/tests/FunctionalTests/System.Net.NetworkInformation.Functional.Tests.csproj +++ b/src/libraries/System.Net.NetworkInformation/tests/FunctionalTests/System.Net.NetworkInformation.Functional.Tests.csproj @@ -3,7 +3,7 @@ true ../../src/Resources/Strings.resx $(NetCoreAppCurrent) - true + true diff --git a/src/libraries/System.Net.Ping/tests/FunctionalTests/System.Net.Ping.Functional.Tests.csproj b/src/libraries/System.Net.Ping/tests/FunctionalTests/System.Net.Ping.Functional.Tests.csproj index 86a7dacccaefdf..b5bd3f7af0b2a5 100644 --- a/src/libraries/System.Net.Ping/tests/FunctionalTests/System.Net.Ping.Functional.Tests.csproj +++ b/src/libraries/System.Net.Ping/tests/FunctionalTests/System.Net.Ping.Functional.Tests.csproj @@ -3,7 +3,7 @@ $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser true true - true + true diff --git a/src/libraries/System.Net.Requests/tests/System.Net.Requests.Tests.csproj b/src/libraries/System.Net.Requests/tests/System.Net.Requests.Tests.csproj index 28312f8be52a77..2e0a55119d01dd 100644 --- a/src/libraries/System.Net.Requests/tests/System.Net.Requests.Tests.csproj +++ b/src/libraries/System.Net.Requests/tests/System.Net.Requests.Tests.csproj @@ -4,7 +4,7 @@ true $(NetCoreAppCurrent) $(DefineConstants);NETSTANDARD - true + true $(NoWarn);SYSLIB0014 diff --git a/src/libraries/System.Net.Security/tests/FunctionalTests/System.Net.Security.Tests.csproj b/src/libraries/System.Net.Security/tests/FunctionalTests/System.Net.Security.Tests.csproj index bb131408de3252..c7722065c401ec 100644 --- a/src/libraries/System.Net.Security/tests/FunctionalTests/System.Net.Security.Tests.csproj +++ b/src/libraries/System.Net.Security/tests/FunctionalTests/System.Net.Security.Tests.csproj @@ -4,7 +4,7 @@ true $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-OSX;$(NetCoreAppCurrent)-iOS annotations - true + true diff --git a/src/libraries/System.Net.Security/tests/UnitTests/System.Net.Security.Unit.Tests.csproj b/src/libraries/System.Net.Security/tests/UnitTests/System.Net.Security.Unit.Tests.csproj index da4dde4e192b90..61d77ea0d96069 100644 --- a/src/libraries/System.Net.Security/tests/UnitTests/System.Net.Security.Unit.Tests.csproj +++ b/src/libraries/System.Net.Security/tests/UnitTests/System.Net.Security.Unit.Tests.csproj @@ -12,7 +12,7 @@ $(NoWarn);3021 $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-OSX;$(NetCoreAppCurrent)-iOS annotations - true + true diff --git a/src/libraries/System.Net.Sockets/tests/FunctionalTests/System.Net.Sockets.Tests.csproj b/src/libraries/System.Net.Sockets/tests/FunctionalTests/System.Net.Sockets.Tests.csproj index dbb949b29df177..152f18fefea983 100644 --- a/src/libraries/System.Net.Sockets/tests/FunctionalTests/System.Net.Sockets.Tests.csproj +++ b/src/libraries/System.Net.Sockets/tests/FunctionalTests/System.Net.Sockets.Tests.csproj @@ -3,7 +3,7 @@ true true $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser - true + true diff --git a/src/libraries/System.Net.WebClient/tests/System.Net.WebClient.Tests.csproj b/src/libraries/System.Net.WebClient/tests/System.Net.WebClient.Tests.csproj index f05e39076dabe6..addc537e4605ad 100644 --- a/src/libraries/System.Net.WebClient/tests/System.Net.WebClient.Tests.csproj +++ b/src/libraries/System.Net.WebClient/tests/System.Net.WebClient.Tests.csproj @@ -4,7 +4,7 @@ $(DefineConstants);NETSTANDARD $(NoWarn);SYSLIB0014 - true + true diff --git a/src/libraries/System.Net.WebSockets.Client/tests/System.Net.WebSockets.Client.Tests.csproj b/src/libraries/System.Net.WebSockets.Client/tests/System.Net.WebSockets.Client.Tests.csproj index 22b43cc0edcf9b..2f9f964b5e25a7 100644 --- a/src/libraries/System.Net.WebSockets.Client/tests/System.Net.WebSockets.Client.Tests.csproj +++ b/src/libraries/System.Net.WebSockets.Client/tests/System.Net.WebSockets.Client.Tests.csproj @@ -5,15 +5,15 @@ $(DefineConstants);NETSTANDARD - + WasmTestOnBrowser $(TestArchiveRoot)browseronly/ $(TestArchiveTestsRoot)$(OSPlatformConfig)/ - + - + diff --git a/src/libraries/System.Reflection.Metadata/tests/System.Reflection.Metadata.Tests.csproj b/src/libraries/System.Reflection.Metadata/tests/System.Reflection.Metadata.Tests.csproj index ac19479d9a47ef..210a2657c7d264 100644 --- a/src/libraries/System.Reflection.Metadata/tests/System.Reflection.Metadata.Tests.csproj +++ b/src/libraries/System.Reflection.Metadata/tests/System.Reflection.Metadata.Tests.csproj @@ -139,7 +139,7 @@ - + \ No newline at end of file diff --git a/src/libraries/System.Reflection.MetadataLoadContext/tests/System.Reflection.MetadataLoadContext.Tests.csproj b/src/libraries/System.Reflection.MetadataLoadContext/tests/System.Reflection.MetadataLoadContext.Tests.csproj index 62a8a2e49b35b3..514114fe6935d1 100644 --- a/src/libraries/System.Reflection.MetadataLoadContext/tests/System.Reflection.MetadataLoadContext.Tests.csproj +++ b/src/libraries/System.Reflection.MetadataLoadContext/tests/System.Reflection.MetadataLoadContext.Tests.csproj @@ -74,7 +74,7 @@ - + diff --git a/src/libraries/System.Reflection/tests/System.Reflection.Tests.csproj b/src/libraries/System.Reflection/tests/System.Reflection.Tests.csproj index 78f02cee29ad0e..5fbe76cfc1edf6 100644 --- a/src/libraries/System.Reflection/tests/System.Reflection.Tests.csproj +++ b/src/libraries/System.Reflection/tests/System.Reflection.Tests.csproj @@ -8,7 +8,7 @@ $(NoWarn),SYSLIB0013 - true + true - + diff --git a/src/libraries/System.Runtime.Loader/tests/System.Runtime.Loader.Tests.csproj b/src/libraries/System.Runtime.Loader/tests/System.Runtime.Loader.Tests.csproj index dc1a2cccd21a57..2e883a5169bcc5 100644 --- a/src/libraries/System.Runtime.Loader/tests/System.Runtime.Loader.Tests.csproj +++ b/src/libraries/System.Runtime.Loader/tests/System.Runtime.Loader.Tests.csproj @@ -42,14 +42,14 @@ - + @@ -64,7 +64,7 @@ + Condition="'$(TargetOS)' == 'Browser' or '$(TargetOS)' == 'Node'"> diff --git a/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/System.Text.Json.Tests.csproj b/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/System.Text.Json.Tests.csproj index ee45bdc5e97e9d..a986f6c808afbb 100644 --- a/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/System.Text.Json.Tests.csproj +++ b/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/System.Text.Json.Tests.csproj @@ -7,7 +7,7 @@ - true + true $(WasmXHarnessArgs) --timeout=1800 diff --git a/src/libraries/System.Text.RegularExpressions/tests/System.Text.RegularExpressions.Tests.csproj b/src/libraries/System.Text.RegularExpressions/tests/System.Text.RegularExpressions.Tests.csproj index dff58ce1bf5ce5..65435dc7636fed 100644 --- a/src/libraries/System.Text.RegularExpressions/tests/System.Text.RegularExpressions.Tests.csproj +++ b/src/libraries/System.Text.RegularExpressions/tests/System.Text.RegularExpressions.Tests.csproj @@ -4,7 +4,7 @@ $(NoWarn);xUnit2008 $(NetCoreAppCurrent);net48 - true + true diff --git a/src/libraries/System.Threading.Channels/tests/System.Threading.Channels.Tests.csproj b/src/libraries/System.Threading.Channels/tests/System.Threading.Channels.Tests.csproj index 45be5f85721731..72b41ebbd4a20d 100644 --- a/src/libraries/System.Threading.Channels/tests/System.Threading.Channels.Tests.csproj +++ b/src/libraries/System.Threading.Channels/tests/System.Threading.Channels.Tests.csproj @@ -1,7 +1,7 @@ $(NetCoreAppCurrent);net461 - true + true diff --git a/src/libraries/pretest.proj b/src/libraries/pretest.proj index 3e924e083abd51..538eea2e2fd060 100644 --- a/src/libraries/pretest.proj +++ b/src/libraries/pretest.proj @@ -21,7 +21,7 @@ - + $(TestRunNamePrefix)$(Scenario)- $(WaitForWorkItemCompletion) - true + true @@ -59,7 +59,7 @@ test/functional/cli/$(TestScope)/ - + true @@ -73,20 +73,20 @@ - + - + - + 768968 @@ -286,7 +286,7 @@ - + @@ -308,20 +308,20 @@ - + - - + + <_WorkItem Include="$(WorkItemArchiveWildCard)" Exclude="$(HelixCorrelationPayload)" /> - <_WorkItem Include="$(TestArchiveRoot)runonly/**/WebAssembly.Console.*.Test.zip" Condition="'$(TargetOS)' == 'Browser' and '$(Scenario)' != 'WasmTestOnBrowser' and '$(Scenario)' != 'BuildWasmApps'" /> - <_WorkItem Include="$(TestArchiveRoot)runonly/**/WebAssembly.Browser.*.Test.zip" Condition="'$(TargetOS)' == 'Browser' and '$(Scenario)' == 'WasmTestOnBrowser'" /> - <_WorkItem Include="$(TestArchiveRoot)browseronly/**/*.zip" Condition="'$(TargetOS)' == 'Browser' and '$(Scenario)' == 'WasmTestOnBrowser'" /> + <_WorkItem Include="$(TestArchiveRoot)runonly/**/WebAssembly.Console.*.Test.zip" Condition="('$(TargetOS)' == 'Browser' or '$(TargetOS)' == 'Node') and '$(Scenario)' != 'WasmTestOnBrowser' and '$(Scenario)' != 'BuildWasmApps'" /> + <_WorkItem Include="$(TestArchiveRoot)runonly/**/WebAssembly.Browser.*.Test.zip" Condition="('$(TargetOS)' == 'Browser' or '$(TargetOS)' == 'Node') and '$(Scenario)' == 'WasmTestOnBrowser'" /> + <_WorkItem Include="$(TestArchiveRoot)browseronly/**/*.zip" Condition="('$(TargetOS)' == 'Browser' or '$(TargetOS)' == 'Node') and '$(Scenario)' == 'WasmTestOnBrowser'" /> %(Identity) @@ -330,18 +330,18 @@ - + dotnet exec $XHARNESS_CLI_PATH $HELIX_WORKITEM_UPLOAD_ROOT/xharness-output $XHARNESS_COMMAND - + dotnet exec %XHARNESS_CLI_PATH% %HELIX_WORKITEM_UPLOAD_ROOT%\xharness-output %XHARNESS_COMMAND% - + <_RunOnlyWorkItem Include="$(TestArchiveRoot)runonly/**/*.Console.Sample.zip" /> @@ -351,7 +351,7 @@ - + <_RunOnlyWorkItem Include="$(TestArchiveRoot)runonly/**/*.Browser.Sample.zip" /> @@ -370,7 +370,7 @@ - + diff --git a/src/libraries/tests.proj b/src/libraries/tests.proj index 0d004b2dfd3c5b..0fe751068c8cb2 100644 --- a/src/libraries/tests.proj +++ b/src/libraries/tests.proj @@ -254,7 +254,7 @@ - + @@ -275,7 +275,7 @@ - + @@ -295,7 +295,7 @@ - + @@ -327,7 +327,7 @@ - + @@ -366,7 +366,7 @@ @@ -393,7 +393,7 @@ BuildInParallel="false" /> - + diff --git a/src/mono/nuget/mono-packages.proj b/src/mono/nuget/mono-packages.proj index 9403ca9fb34bf0..cdf3db0f70a027 100644 --- a/src/mono/nuget/mono-packages.proj +++ b/src/mono/nuget/mono-packages.proj @@ -3,7 +3,7 @@ - + diff --git a/src/tasks/AotCompilerTask/MonoAOTCompiler.props b/src/tasks/AotCompilerTask/MonoAOTCompiler.props index 097758ae0c783b..6e437fb86fcbdf 100644 --- a/src/tasks/AotCompilerTask/MonoAOTCompiler.props +++ b/src/tasks/AotCompilerTask/MonoAOTCompiler.props @@ -24,7 +24,7 @@ - + diff --git a/src/tests/Common/helixpublishwitharcade.proj b/src/tests/Common/helixpublishwitharcade.proj index b98bd8e8289b17..502113b6fbdca6 100644 --- a/src/tests/Common/helixpublishwitharcade.proj +++ b/src/tests/Common/helixpublishwitharcade.proj @@ -40,7 +40,7 @@ - <_PropertiesToPass Condition="'$(TargetOS)' == 'Browser' Or '$(TargetOS)' == 'Android'"> + <_PropertiesToPass Condition="'$(TargetOS)' == 'Browser' or '$(TargetOS)' == 'Node' Or '$(TargetOS)' == 'Android'"> $(_PropertiesToPass); IncludeDotNetCli=$(IncludeDotNetCli); DotNetCliRuntime=$(DotNetCliRuntime); @@ -98,7 +98,7 @@ $(HelixRuntimeRid) - + sdk $([System.IO.File]::ReadAllText('$(RepoRoot)global.json')) $([System.Text.RegularExpressions.Regex]::Match($(GlobalJsonContent), '(%3F<="dotnet": ").*(%3F=")')) diff --git a/src/tests/Common/tests.targets b/src/tests/Common/tests.targets index 639d08a0863d24..bf179816169fb5 100644 --- a/src/tests/Common/tests.targets +++ b/src/tests/Common/tests.targets @@ -55,7 +55,7 @@ $(CORE_ROOT)\corerun $(CORE_ROOT)\corerun.exe - $(DotnetRoot)/dotnet + $(DotnetRoot)/dotnet - + false false diff --git a/src/tests/Interop/ICastable/Castable.csproj b/src/tests/Interop/ICastable/Castable.csproj index 3d721d1b432e27..459ac5630e16d2 100644 --- a/src/tests/Interop/ICastable/Castable.csproj +++ b/src/tests/Interop/ICastable/Castable.csproj @@ -2,7 +2,7 @@ Exe true - true + true From d4513e88938b0140cbc5ae10d1925b21dcd7274d Mon Sep 17 00:00:00 2001 From: Daniel-Genkin Date: Mon, 21 Jun 2021 14:02:00 -0400 Subject: [PATCH 22/25] continued work on adding the new build target --- eng/Subsets.props | 2 +- eng/targetframeworksuffix.props | 2 +- src/tests/Common/CLRTest.Execute.Bash.targets | 2 +- src/tests/Common/helixpublishwitharcade.proj | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/eng/Subsets.props b/eng/Subsets.props index 3ab4fe5fb551c3..0d4240310ce7ef 100644 --- a/eng/Subsets.props +++ b/eng/Subsets.props @@ -46,7 +46,7 @@ mono.llvm+ mono.llvm+ - $(DefaultMonoSubsets)mono.wasmruntime+ + $(DefaultMonoSubsets)mono.wasmruntime+ $(DefaultMonoSubsets)mono.aotcross+ $(DefaultMonoSubsets)mono.runtime+mono.corelib+mono.packages diff --git a/eng/targetframeworksuffix.props b/eng/targetframeworksuffix.props index ccbf1aa2883664..b4afbb26e00b44 100644 --- a/eng/targetframeworksuffix.props +++ b/eng/targetframeworksuffix.props @@ -100,7 +100,7 @@ solaris - + true browser diff --git a/src/tests/Common/CLRTest.Execute.Bash.targets b/src/tests/Common/CLRTest.Execute.Bash.targets index cb28cbfac5e5a1..e7340ed11fb9a4 100644 --- a/src/tests/Common/CLRTest.Execute.Bash.targets +++ b/src/tests/Common/CLRTest.Execute.Bash.targets @@ -336,7 +336,7 @@ fi $(BashLinkerTestCleanupCmds) ]]> - + osx-$(TargetArchitecture) linux-$(TargetArchitecture) linux-musl-$(TargetArchitecture) - browser-wasm + browser-wasm android-$(TargetArchitecture) From dd3d200b56cd16bae801d914aef3c0d890f9f0f8 Mon Sep 17 00:00:00 2001 From: Daniel-Genkin Date: Mon, 21 Jun 2021 20:16:34 -0400 Subject: [PATCH 23/25] Continued working on adding node build target --- eng/testing/tests.targets | 2 +- src/libraries/sendtohelix.proj | 2 +- src/libraries/sendtohelixhelp.proj | 6 +++--- src/libraries/tests.proj | 2 +- src/mono/wasm/wasm.proj | 2 +- src/tasks/tasks.proj | 4 ++-- src/tests/Directory.Build.targets | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/eng/testing/tests.targets b/eng/testing/tests.targets index ac4171ee7b3699..2935827ed2c09a 100644 --- a/eng/testing/tests.targets +++ b/eng/testing/tests.targets @@ -63,7 +63,7 @@ - $(RunScriptCommand) $RSP_FILE + $(RunScriptCommand) $RSP_FILE $(RunScriptCommand) %RSP_FILE% diff --git a/src/libraries/sendtohelix.proj b/src/libraries/sendtohelix.proj index 940bb713331e1d..43d075c27a3006 100644 --- a/src/libraries/sendtohelix.proj +++ b/src/libraries/sendtohelix.proj @@ -108,7 +108,7 @@ - + diff --git a/src/libraries/sendtohelixhelp.proj b/src/libraries/sendtohelixhelp.proj index 434260e4124b04..302f998a6252ee 100644 --- a/src/libraries/sendtohelixhelp.proj +++ b/src/libraries/sendtohelixhelp.proj @@ -120,7 +120,7 @@ --> SetStressModes_$(Scenario).cmd - SetStressModes_$(Scenario).sh + SetStressModes_$(Scenario).sh @@ -141,7 +141,7 @@ @(HelixPreCommand) - true + true @@ -315,7 +315,7 @@ + Condition="'$(IncludeHelixCorrelationPayload)' == 'true' and '$(TargetOS)' != 'Browser' and '$(TargetOS)' != 'Node'" /> diff --git a/src/libraries/tests.proj b/src/libraries/tests.proj index f6648c5266bb8d..befdeb87ef3c61 100644 --- a/src/libraries/tests.proj +++ b/src/libraries/tests.proj @@ -13,7 +13,7 @@ false - + diff --git a/src/mono/wasm/wasm.proj b/src/mono/wasm/wasm.proj index cb376f9add8f44..3512d18dc52275 100644 --- a/src/mono/wasm/wasm.proj +++ b/src/mono/wasm/wasm.proj @@ -16,7 +16,7 @@ - + diff --git a/src/tasks/tasks.proj b/src/tasks/tasks.proj index e681cfd2740ddc..21773a387c8fd1 100644 --- a/src/tasks/tasks.proj +++ b/src/tasks/tasks.proj @@ -6,9 +6,9 @@ + Condition="'$(TargetOS)' != 'Browser' and '$(TargetOS)' != 'Node'" /> + Condition="'$(TargetOS)' != 'Browser' and '$(TargetOS)' != 'Node'" /> + Condition="'@(NativeProjectBinaries)' == '' And '$(TargetOS)' != 'Browser' And '$(TargetOS)' != 'Node' And '$(TargetOS)' != 'Android'"/> Date: Tue, 22 Jun 2021 10:26:47 -0400 Subject: [PATCH 24/25] removed hardcoded path --- src/mono/wasm/build/WasmApp.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/wasm/build/WasmApp.targets b/src/mono/wasm/build/WasmApp.targets index 26c37e382fd803..ce7109a4790515 100644 --- a/src/mono/wasm/build/WasmApp.targets +++ b/src/mono/wasm/build/WasmApp.targets @@ -232,7 +232,7 @@ - Date: Tue, 22 Jun 2021 10:35:21 -0400 Subject: [PATCH 25/25] Removed duplicate preInit --- src/mono/wasm/runtime-test.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/mono/wasm/runtime-test.js b/src/mono/wasm/runtime-test.js index 34281802779dbc..8001f14cace747 100644 --- a/src/mono/wasm/runtime-test.js +++ b/src/mono/wasm/runtime-test.js @@ -272,11 +272,7 @@ var Module = { preInit: async function() { Module.config = await Module.MONO.mono_wasm_load_config("./mono-config.json"); }, - - preInit: async function() { - Module.config = await MONO.mono_wasm_load_config("./mono-config.json"); - }, - + onAbort: function(x) { console.log ("ABORT: " + x); const err = new Error();