From 41898688d457acd484af25b2b49fa6e404aeb77f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fi=C5=A1era?= Date: Tue, 27 Feb 2024 14:23:33 +0100 Subject: [PATCH 1/2] Fix failing test when randomly picked assembly is zero --- .../WasmBasicTestApp/App/wwwroot/README.md | 15 +++++++++++++++ .../WasmBasicTestApp/App/wwwroot/main.js | 5 +++-- 2 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 src/mono/wasm/testassets/WasmBasicTestApp/App/wwwroot/README.md diff --git a/src/mono/wasm/testassets/WasmBasicTestApp/App/wwwroot/README.md b/src/mono/wasm/testassets/WasmBasicTestApp/App/wwwroot/README.md new file mode 100644 index 00000000000000..efaa6360662f7d --- /dev/null +++ b/src/mono/wasm/testassets/WasmBasicTestApp/App/wwwroot/README.md @@ -0,0 +1,15 @@ +## WasmBasicTestApp + +This a test application used by various Wasm.Build.Tests. The idea is to share a common behavior (so that we don't have to maintain many test apps) and tweak it for the test case. +It typically suits scenario where you need more than a plain template app. If the test case is too different, feel free to create another app. + +### Usage + +The app reads `test` query parameter and uses it to switch between test cases. Entrypoint is `main.js`. +There is common unit, then switch based on test case for modifying app startup, then app starts and executes next switch based on test case for actually running code. + +Some test cases passes additional parameters to differentiate behavior, see `src/mono/wasm/Wasm.Build.Tests/TestAppScenarios`. + +### Running out side of WBT + +One of the benefits is that you can copy the app out of intree and run the app without running Wasm.Build.Tests with just `dotnet run`. \ No newline at end of file diff --git a/src/mono/wasm/testassets/WasmBasicTestApp/App/wwwroot/main.js b/src/mono/wasm/testassets/WasmBasicTestApp/App/wwwroot/main.js index 2e1b7ff8c84fe3..3a01053875c0a6 100644 --- a/src/mono/wasm/testassets/WasmBasicTestApp/App/wwwroot/main.js +++ b/src/mono/wasm/testassets/WasmBasicTestApp/App/wwwroot/main.js @@ -33,6 +33,7 @@ switch (testCase) { Math.floor(Math.random() * 5) + 5, Math.floor(Math.random() * 5) + 10 ]; + console.log(`Failing test at assembly indexes [${failAtAssemblyNumbers.join(", ")}]`); let alreadyFailed = []; dotnet.withDiagnosticTracing(true).withResourceLoader((type, name, defaultUri, integrity, behavior) => { if (type === "dotnetjs") { @@ -45,8 +46,8 @@ switch (testCase) { return defaultUri; } - assemblyCounter++; - if (!failAtAssemblyNumbers.includes(assemblyCounter) || alreadyFailed.includes(defaultUri)) + const currentCounter = assemblyCounter++; + if (!failAtAssemblyNumbers.includes(currentCounter) || alreadyFailed.includes(defaultUri)) return defaultUri; alreadyFailed.push(defaultUri); From f5faaa957d1afd9cdee6b1166524c957eda7bf54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fi=C5=A1era?= Date: Tue, 27 Feb 2024 19:46:08 +0100 Subject: [PATCH 2/2] Update src/mono/wasm/testassets/WasmBasicTestApp/App/wwwroot/README.md Co-authored-by: Ilona Tomkowicz <32700855+ilonatommy@users.noreply.github.com> --- src/mono/wasm/testassets/WasmBasicTestApp/App/wwwroot/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/wasm/testassets/WasmBasicTestApp/App/wwwroot/README.md b/src/mono/wasm/testassets/WasmBasicTestApp/App/wwwroot/README.md index efaa6360662f7d..996992663189fb 100644 --- a/src/mono/wasm/testassets/WasmBasicTestApp/App/wwwroot/README.md +++ b/src/mono/wasm/testassets/WasmBasicTestApp/App/wwwroot/README.md @@ -1,6 +1,6 @@ ## WasmBasicTestApp -This a test application used by various Wasm.Build.Tests. The idea is to share a common behavior (so that we don't have to maintain many test apps) and tweak it for the test case. +This is a test application used by various Wasm.Build.Tests. The idea is to share a common behavior (so that we don't have to maintain many test apps) and tweak it for the test case. It typically suits scenario where you need more than a plain template app. If the test case is too different, feel free to create another app. ### Usage