Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[browser][wbt] Fix not failing download for DownloadProgressFinishes test when randomly picked index is zero #98985

Merged
merged 2 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/mono/wasm/testassets/WasmBasicTestApp/App/wwwroot/README.md
Original file line number Diff line number Diff line change
@@ -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.
maraf marked this conversation as resolved.
Show resolved Hide resolved
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`.
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand All @@ -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);
Expand Down
Loading