Repository navigation
Enable MSTest/MTP test execution on wasi-wasm (#2196) #9781
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
Merged
Amaury Levé (Evangelink)
merged 7 commits into
main
from
dev/amauryleve/wasm-test-execution
Jul 9, 2026
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
acf6bff
Enable MSTest/MTP test execution on wasi-wasm (#2196)
Evangelink 99deca0
Merge branch 'main' into dev/amauryleve/wasm-test-execution
Evangelink 20cdb9f
Address review: declare new internal API, fix sample + README accuracy
Evangelink a41feff
Address review: add UTF-8 BOM to new .cs files
Evangelink 412b8f8
Merge remote-tracking branch 'origin/main' into pr9781
Evangelink c067fa5
Merge branch 'main' into dev/amauryleve/wasm-test-execution
Evangelink 9bb44a8
Address review: make telemetry a true no-op on single-threaded wasm
Evangelink File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
src/Adapter/MSTestAdapter.PlatformServices/InternalAPI/InternalAPI.Unshipped.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| #nullable enable | ||
| static Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Helpers.RuntimeContext.IsMultiThreaded.get -> bool |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/Platform/Microsoft.Testing.Platform/Helpers/RuntimeFeatureHelper.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
|
||
| namespace Microsoft.Testing.Platform.Helpers; | ||
|
|
||
| /// <summary> | ||
| /// Runtime feature detection that the platform uses to adapt its behavior to the host. | ||
| /// </summary> | ||
| internal static class RuntimeFeatureHelper | ||
| { | ||
| /// <summary> | ||
| /// Gets a value indicating whether the current runtime supports multiple threads. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// Single-threaded WebAssembly runtimes (<c>browser-wasm</c> and <c>wasi-wasm</c>) do not have a | ||
| /// thread pool: <see cref="System.Threading.Tasks.Task.Run(System.Action)"/> continuations never | ||
| /// execute while the single thread is busy, and blocking waits | ||
| /// (<c>Task.Wait</c> / <c>GetAwaiter().GetResult()</c> on an incomplete task) throw | ||
| /// <see cref="PlatformNotSupportedException"/>. Code that would otherwise offload work to a | ||
| /// background thread MUST fall back to inline/synchronous execution when this returns | ||
| /// <see langword="false"/>, otherwise the operation deadlocks or throws. | ||
| /// <para> | ||
| /// .NET 11 exposes <c>System.Runtime.CompilerServices.RuntimeFeature.IsMultithreadingSupported</c> | ||
| /// for exactly this purpose (see <see href="https://github.com/dotnet/runtime/issues/77541"/>), | ||
| /// but the platform still targets earlier frameworks, so we derive the same information from the | ||
| /// <see cref="OperatingSystem"/> single-threaded-wasm probes, which are available since .NET 8. | ||
| /// </para> | ||
| /// </remarks> | ||
| public static bool IsMultiThreaded { get; } = | ||
| #if NETCOREAPP | ||
| !OperatingSystem.IsBrowser() && !OperatingSystem.IsWasi(); | ||
|
Evangelink marked this conversation as resolved.
Resolved
|
||
| #else | ||
| // netstandard2.0 / .NET Framework builds never run on a single-threaded wasm runtime. | ||
| true; | ||
| #endif | ||
| } | ||
2 changes: 2 additions & 0 deletions
2
src/Platform/Microsoft.Testing.Platform/InternalAPI/InternalAPI.Unshipped.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.